简体   繁体   中英

Dynamically plot line graphs based on user input change in B4A

Is there a way to plot line graphs in B4A dynamically? What I mean is, taking inputs of two editbox where the first edit box would represent x axis value and the second edit box would represent y axis value, and with a button event the graph replots with the new values. And when the app starts it would always be a blank graph with no plots. I wrote a program in python using matplotlib which allows us to do such things, but here I could not find any example of how to proceed with the problem.

I get the part where we can plot a graph when the activity starts (MPAndroid Charts etc), but it seems to be static, I cannot understand how to redraw or insert new data (x/y values) to the existing graph when someone adds new values in an editbox and clicks a button.

Do we have any example code from where I can take reference from?

It can be done in mpAndroidCharts. All you need to do is on button click you need to provide new values to dataset and after that you need to refresh your chart. For that you have to do as follow:

chart.notifyDataSetChanged();
chart.invalidate(); 

我在寻找一种绘制动态图形的方法时偶然发现了这篇文章,该方法类似于您所说的“获取两个编辑框的输入,其中第一个编辑框表示 x 轴值,第二个编辑框表示 y 轴值,并且通过按钮事件,图表会使用新值重新绘制。”如果您不介意并且您还有代码,请帮帮我好吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM