我正在使用Android上的AnyChart库。我尝试了circularGauge.animation(true, 3000)
,但似乎不起作用。
下面的代码段
fun setCircularChart(anyChartView: AnyChartView, progress_bar: ProgressBar, chartIndex: Int, data: ArrayList<Score>, chartTitle: String) {
APIlib.getInstance().setActiveAnyChartView(anyChartView)
val circularGauge = AnyChart.circular()
if (data.size == 0) {
return
}
anyChartView.setProgressBar(progress_bar)
anyChartView.visibility = View.VISIBLE
progress_bar.visibility = View.INVISIBLE
val list = arrayListOf<Any>()
val labels = arrayListOf<String>()
//considering only first 3 fields here
for (i in 0..2) {
val progress = getNormalizedValue(data[i].value).toInt().toString()
list.add(progress)
labels.add(StringBuilder().append(data[i].name).append(" ").append(progress).append("%").toString())
}
//below data is to show the secondary progress
list.add("100")
list.add("100")
list.add("100")
circularGauge.data(SingleValueDataSet(list))
circularGauge.fill(chartBg)
.stroke(null)
.padding(0.0, 0.0, 0.0, 0.0)
.margin(100.0, 100.0, 100.0, 100.0)
circularGauge.startAngle(0.0)
circularGauge.sweepAngle(270.0)
val xAxis = circularGauge.axis(0)
.radius(100.0)
.width(1.0)
.fill(null as Fill?)
xAxis.scale()
.minimum(0.0)
.maximum(100.0)
xAxis.ticks("{ interval: 2 }")
.minorTicks("{ interval: 1 }")
xAxis.labels().enabled(false)
xAxis.ticks().enabled(false)
xAxis.minorTicks().enabled(false)
circularGauge.label(0.0)
.text(labels[0])
.fontSize(10.0f)
.useHtml(true)
.hAlign(HAlign.CENTER)
.vAlign(VAlign.MIDDLE)
circularGauge.label(0.0)
.anchor(Anchor.RIGHT_CENTER)
.padding(0.0, 10.0, 0.0, 0.0)
.height((17.0 / 2.0).toString() + "%")
.offsetY(100.0.toString() + "%")
.offsetX(0.0)
val bar0 = circularGauge.bar(0.0)
bar0.dataIndex(0.0)
bar0.radius(100.0)
bar0.width(radialBarWidth)
bar0.fill(SolidFill(getColors(chartIndex)[0], 1.0))
bar0.stroke(null)
bar0.zIndex(5.0)
val bar100 = circularGauge.bar(100.0)
bar100.dataIndex(5.0)
bar100.radius(100.0)
bar100.width(radialBarWidth)
bar100.fill(SolidFill(secondaryProgressColor, 1.0))
bar100.stroke(null)
bar100.zIndex(4.0)
circularGauge.label(1.0)
.text(labels[1])
.fontSize(10.0f)
.useHtml(true)
.hAlign(HAlign.CENTER)
.vAlign(VAlign.MIDDLE)
circularGauge.label(1.0)
.anchor(Anchor.RIGHT_CENTER)
.padding(0.0, 10.0, 0.0, 0.0)
.height((17.0 / 2.0).toString() + "%")
.offsetY(80.0.toString() + "%")
.offsetX(0.0)
val bar1 = circularGauge.bar(1.0)
bar1.dataIndex(1.0)
bar1.radius(75.0)
bar1.width(radialBarWidth)
bar1.fill(SolidFill(getColors(chartIndex)[1], 1.0))
bar1.stroke(null)
bar1.zIndex(5.0)
val bar101 = circularGauge.bar(101.0)
bar101.dataIndex(5.0)
bar101.radius(75.0)
bar101.width(radialBarWidth)
bar101.fill(SolidFill(secondaryProgressColor, 1.0))
bar101.stroke(null)
bar101.zIndex(4.0)
circularGauge.label(2.0)
.text(labels[2])
.fontSize(10.0f)
.useHtml(true)
.hAlign(HAlign.CENTER)
.vAlign(VAlign.MIDDLE)
circularGauge.label(2.0)
.anchor(Anchor.RIGHT_CENTER)
.padding(0.0, 10.0, 0.0, 0.0)
.height((17.0 / 2.0).toString() + "%")
.offsetY(60.0.toString() + "%")
.offsetX(0.0)
val bar2 = circularGauge.bar(2.0)
bar2.dataIndex(2.0)
bar2.radius(50.0)
bar2.width(radialBarWidth)
bar2.fill(SolidFill(getColors(chartIndex)[2], 1.0))
bar2.stroke(null)
bar2.zIndex(5.0)
val bar102 = circularGauge.bar(102.0)
bar102.dataIndex(5.0)
bar102.radius(50.0)
bar102.width(radialBarWidth)
bar102.fill(SolidFill(secondaryProgressColor, 1.0))
bar102.stroke(null)
bar102.zIndex(4.0)
circularGauge.margin(20.0, 20.0, 20.0, 20.0)
circularGauge.title()
// .text(" '<br/><span style=\"color:#ffffff; font-size:
12px;\">" + getTitle(chartIndex) + " < / span >")
.text(chartTitle).fontColor("#fff")
.hAlign(HAlign.CENTER).vAlign(VAlign.BOTTOM)
circularGauge.title().enabled(true)
// circularGauge.title().hAlign(HAlign.CENTER).vAlign(VAlign.BOTTOM)
circularGauge.title()
.padding(0.0, 0.0, 0.0, 0.0)
.margin(0.0, 0.0, 20.0, 0.0)
circularGauge.animation(true, 3000)
circularGauge.background(chartBg)
anyChartView.setChart(circularGauge)
anyChartView.setBackgroundColor(chartBg)
}`
答案 0 :(得分:0)
不幸的是,当前版本的AnyChart库8.3.0和Android版本1.0.4不提供圆规的动画功能。