I was looking at https://www.b4x.com/android/help/mpchartlib.html#linechart and was wondering if it is possible to insert new graph data when a button is pressed. One odd thing that I found in this and other graphs, I cannot mention any particular coordinate on a graph, unlike matplotlib. I am looking for a way to draw a graph and then placing (or appending new coordinates) to the graph when a user presses a button, the plot points (x and y values) could be in an array, when a button is pressed, new coordinates are appended to the existing plot.
I am attaching a sample graph which I made in python, I am looking for something like it.
In that graph, I can change the pointer's location (the one with "+" symbol) by feeding new data (x, y values) from input boxes.
I can also plot line graph from one location to the other, by appending two x,y values one after another.
I looked a lot for an example in this forum which would even slightly resemble what I am trying to do, but I could not find.
Can you provide me a simple example of how I can insert new data to a canvas with button press, I looked into the UserGuide, and perhaps, I can do it but just that I need a hint of where to start? Thank you!
You cannot.
A canvas is a tool to draw graphics, it is not a charts tool.
You need to memorize the coordinates of the points.
You need to draw everything on your own.
You would need three canvases.
One for the 'background' graphic with the scales.
One for the points, if you dont want them on the background graph.
One for the cursor.
Then you have a tricky point, the logarithmic x scale.
Is the background graph alway the same?
How is your data structure to memorize the points?
How do you determine the lines to draw?
When ever the button is pressed it would save the current point in a database (sqlite3) file, the sqlite file would have both the xaxis and yaxis points.
Not that I know.
I don't know Python, but you can show us how you did it. It's always interesting to learn.
I explain more in detail my question on about how you determine the lines to draw.
You say that you have points and you want do draw lines. Could you elaborate this sentance: I can also plot line graph from one location to the other, by appending two x,y values one after another.
Yeah, it is but can you point me at any direction of where to start, like how to add points using keypress. I am willing to share the whole project here if I could start with it.
Attached you find a demonstrator project.
It does what you want, but only for one graph.
It is easy to make it for two graphs, working with arrays.
If you want, I can do it for you.
I suppose that your project is dedicated for tablets only.
I developped this project on a phone.
Bravo! That's just what I needed. Thank you very much! Yes, I believe I can do it with both the graphs. I am going to release the whole project here once it is completed. Thank you once again!
Attached you find a demonstrator project.
It does what you want, but only for one graph.
It is easy to make it for two graphs, working with arrays.
If you want, I can do it for you.
I suppose that your project is dedicated for tablets only.
I developped this project on a phone.