I am trying to use Scichart to create a countdown circular chart using scichart. Wondering, if anyone can point me to an example.
Asked
Active
Viewed 67 times
1 Answers
2
To Create a countdown Circular chart using scichart use SciPieChartSurface
Use this code:
final SciChartBuilder sciChartBuilder = SciChartBuilder.instance();
SciPieChartSurface progressChart = findViewById(R.id.progressChart);
.........
final float donutSeriesHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, progressChart.getResources().getDisplayMetrics());
IPieRenderableSeries donutSeries = sciChartBuilder.newDonutSeries().withSegments(
sciChartBuilder.newPieSegment()
.withValue(eldChart.getPercentage())
.withFillColor(finishedColor)
.withStrokeStyle(finishedColor)
.build(),
sciChartBuilder.newPieSegment()
.withValue(100 - eldChart.getPercentage())
.withFillColor(unfinishedColor)
.withStrokeStyle(unfinishedColor)
.build()
)
.withHeightSizingModeP(SizingMode.Absolute)
.withHeight(donutSeriesHeight)
.build();
donutSeries.setSegmentSpacing(0);
donutSeries.setStartAngle(90);
Collections.addAll(progressChart.getRenderableSeries(), donutSeries);
And to update the progress only update the donutSeries Segments value
For update:
if ( progressChart.getRenderableSeries().size() > 0 ){
PieSegmentCollection segmentsCollection = progressChart.getRenderableSeries().get(0).getSegmentsCollection();
if (segmentsCollection.size() == 2) {
IPieSegment iPieSegment1 = segmentsCollection.get(0);
iPieSegment1.setValue(eldChart.getPercentage());
IPieSegment iPieSegment2 = segmentsCollection.get(1);
iPieSegment2.setValue(100-eldChart.getPercentage());
}
}
Here getRenderableSeries().get(0).getSegmentsCollection()
will return a ObservableCollection<IPieSegment>
so just updating IPieSegment
value will reflect on UI.
Hope this will help you

Abu Yousuf
- 5,729
- 3
- 31
- 50