How do you add slice spacing to just the selected item of a pie chart with iOS Charts in Swift 3? - swift

I am using the Charts library by Daniel Gindi.
I am able to set my delegate and have a function run whenever a slice is selected, but the line pieChartDataSet.sliceSpace sets the spacing for the entire chart instead of just one slice.
Here is an example of what I want to achieve:
Thanks for your help.

chartView.highlightValue(x: 0, dataSetIndex: 0)

This pieChartDataSet.sliceSpace is for highlight feature, and you just have to write code to highlight the slice you want.
Take a look at drawHighlighted() in pie chart renderer.

Related

ag-grid Pie Chart - change the colors of the slices

I would like change the colors of the slices in an ag-grid Pie Chart. Is it possible? I am using React.
https://www.ag-grid.com/javascript-charts-pie-series/
I figured out the solution, which was actually obvious but I was not correctly looking. The API reference lists "fills?: string[]". All set.

How to achieve this kind of heatmap / bar chart with Chart.js

I have to build a horizontal bar with chartjs. I already built a few of them but its a bit different. The chart has 2 labels for the yAxis ("Storm Risk", "Ice Risk") and hours for the xAxes. I have to print out for every hour one of these different options with different colors ("Low", "Medium", "Hight") as ye can see in the screenshot attached.
This kind of bar chart usually the values are represented by the length of the bar and its a bit different.
Any suggestion?.
Thanks
The chart you want to implement is a sort of a "heatmap". As of now (Sep. 2018), Heatmap charts are not supported out of the box by Chart.js. However, you can make one out of a stacked bar chart (in this case, probably stacked horizontal bar chart?): make each stack size equal to one another and each item backgroundColor depending on the actual values being represented. Once this is done, you can override ticks and tooltips using with according callbacks. Legend can be implemented by one more bar chart with sample values and colors.
More details can be found in a related GitHub issue: https://github.com/chartjs/Chart.js/issues/4627
Another alternative would be to use a BubbleChart. The strategy would be similar - you would need to make all bubbles same size, but override their colors. However, provided the look in the question, stacked horizontal bar chart will be more suitable.
Another option for those who are still looking is to use chartjs-chart-matrix https://chartjs-chart-matrix.pages.dev/usage.html plugin.
Example of implementation with Chart.js v3: https://www.youtube.com/watch?v=bi04BgvNY6U

About MPAndroidChart-piechart with lines

I am using mpandroidchart library for my project ,my IDE is eclipse. I imported the lib mpandroidchartlibrary_2.2.4.jar to my project.I want to realize the image like the mpandroidchart demo of piechart with lines ,but I only realize the piechart without lines,I don't know how to do. and the method
dataSet.setValueLinePart1OffsetPercentage(20.f);
dataSet.setValueLinePart1Length(10f);
dataSet.setValueLinePart2Length(10f);
in my project don't show.
Do you refer slice space as lines in piechart ? If yes, then use the following line.
// Set spacing between pie slices
pieDataSet.setSliceSpace(5);
Add color to your dataSet.
dataSet.setColors(ColorTemplate.COLORFUL_COLORS);
This will separate your slices in pie Chart
Else with the same color if you want to create separation, add space between slices
dataSet.setSliceSpace(5f);

Not showing all of the label on the x-axis in Swift 2

I am using the Charts framework (danielgindi/Charts). My line chart is not showing all of the text on the x-axis on the last value. See image below.
How can I ensure that the whole text is shown?
chartView.xAxis.avoidFirstLastClippingEnabled = true
Other way: chartView.xAxis.setLabelsToSkip(0)

Round y-axis values: Dojo Chart vs Chart.js

I am using Dojo Charts to create some line graphs, and this is how the chart looks,
this id chartData: 0,0,0,0,65,223
And when I create the graph using Chart.js, this is how it is rendered
Ignore the x-axis and other things, If we look at the y-axis, the values are rounded in chart.js, looks much nicer when compared to dojo charts.
Is there an option to achieve the same in dojo charts?
Try adjusting majorTickStep, or optionally also set minorTickMarks to true and adjust minorTickStep as well.
See http://dojotoolkit.org/reference-guide/1.10/dojox/charting.html#enabling-and-disabling-tick-marks and "Axis Stepping" two sections later.