Anychart不接受变量
我正在Android Studio中使用图表。在教程中,数字41、56和93像这样直接放入了估算值。
data.add(new ValueDataEntry("BUB", 41));
data.add(new ValueDataEntry("KP", 56));
data.add(new ValueDataEntry("SP", 93));
但是,当我尝试将用户输入编号输入到RetureataEntry时,它就无法正常工作。因此,我尝试将输入直接设置为以下代码,但仍无法使用。我试图将整数更改为浮动,也将其加倍,但仍然无法正常工作。我怀疑我不熟悉dowerudataentry的参数,因为double,integer和float不起作用,但是它接受了上述代码的数字。通过变量帮助我将值插入饼图中。非常感谢帮助。
private void makeChart() {
ArrayList<DataEntry> data= new ArrayList<>();
int test=41;
int test2=56;
int test3=93;
data.add(new ValueDataEntry("BUB", test));
data.add(new ValueDataEntry("KP", test2));
data.add(new ValueDataEntry("SP", test3));
Pie pie = AnyChart.pie();
pie.data(data);
anyChart.setChart(pie);
}
p/s我还尝试使用其他名为mpandroidchart的图表库,它的问题非常类似。如果我知道dowerudataentry提取了哪些参数。顺便说一句,在Android Studio中,上面的代码片段没有丢弃错误,所以我不知道为什么它没有显示派。
I am playing with charts in Android Studio. In the tutorial, the number 41, 56 and 93 is being put directly into the ValueDataEntry like so and it is working.
data.add(new ValueDataEntry("BUB", 41));
data.add(new ValueDataEntry("KP", 56));
data.add(new ValueDataEntry("SP", 93));
But when I try to make user input number to the ValueDataEntry, it is not working. So I try to set the input directly to the below code but it is still not working. I tried to change the integer to float and also double but it is still not working. I suspected the parameter of ValueDataEntry is something I'm not familiar with because double, integer and float are not working but it is accepting numbers like the code above. Help me to insert values into the pie chart through variables. Help is very much appreciated.
private void makeChart() {
ArrayList<DataEntry> data= new ArrayList<>();
int test=41;
int test2=56;
int test3=93;
data.add(new ValueDataEntry("BUB", test));
data.add(new ValueDataEntry("KP", test2));
data.add(new ValueDataEntry("SP", test3));
Pie pie = AnyChart.pie();
pie.data(data);
anyChart.setChart(pie);
}
p/s I also had try using the other chart library called MPAndroidChart and it has a problem very much like this. If only I can know what parameters are taken by ValueDataEntry. By the way, in Android Studio, the code snippet above is not throwing error so I don't know why it is not showing the pie.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论