简体   繁体   English

根据 B4A 中的用户输入变化动态绘制折线图

[英]Dynamically plot line graphs based on user input change in B4A

Is there a way to plot line graphs in B4A dynamically?有没有办法在 B4A 中动态绘制折线图? 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.我的意思是,输入两个编辑框,其中第一个编辑框表示 x 轴值,第二个编辑框表示 y 轴值,并且通过按钮事件,图形会使用新值重新绘制。 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.我使用 matplotlib 在 python 中编写了一个程序,它允许我们做这样的事情,但在这里我找不到任何关于如何处理这个问题的例子。

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.我得到了可以在活动开始时绘制图形的部分(MPAndroid 图表等),但它似乎是静态的,我无法理解当有人添加时如何重绘或插入新数据(x/y 值)到现有图形编辑框中的新值并单击按钮。

Do we have any example code from where I can take reference from?我们是否有任何可以参考的示例代码?

It can be done in mpAndroidCharts. 可以在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 轴值,并且通过按钮事件,图表会使用新值重新绘制。”如果您不介意并且您还有代码,请帮帮我好吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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