【问题标题】:How to create a count down circular chart using android scichart如何使用 android scichart 创建倒计时圆形图表
【发布时间】:2019-11-17 02:53:45
【问题描述】:

我正在尝试使用 Scichart 创建倒计时圆形图表。想知道是否有人可以举个例子。

【问题讨论】:

    标签: java android scichart


    【解决方案1】:

    要使用 scichart 创建倒计时圆形图表,请使用SciPieChartSurface

    使用此代码:

    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);
    

    并且要更新进度只更新 donutSeries Segments 值

    更新:

    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());
        }
    } 
    

    这里getRenderableSeries().get(0).getSegmentsCollection() 将返回ObservableCollection<IPieSegment>,因此只需更新IPieSegment 值就会反映在UI 上。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2020-07-27
      • 2023-03-29
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多