PDA

View Full Version : Click to add point



andresantos
5 Sep 2011, 2:36 PM
Hi,
I need to develop a chart with some user interaction to manipulate de data. One of the interaction is click (or tap) the chart to add a point. There is any way to do this with sencha touch charts?
The interaction will work this way:
The app will show a blank chart, with 1 year of axis (12 months). The user will tap the chart to add one or more point (in the months that he want data) and I will process this data inserted by user to server.
There is any way to do this? The solution is similar to:
http://www.highcharts.com/demo/dynamic-click-to-add

but with fixed intervals.

Thanks for now,

philogb
6 Sep 2011, 9:24 AM
You can add a listener to the surface of the chart, and update the store when someone clicks there, then re-render the line chart. This method would only be useful for non parametric line charts (lines that don't go backwards, just regular lines).

Would that be useful to you?

Try basing your example on a line chart example, adding a time axis with only groupBy: 'month' and set an empty store with dates month_number/01/year and try rendering that. After that you can get the chart surface by doing:



chart.getSurface().on({
tap: function() {
console.log(arguments);
}
});


and append an event to it. That event should trigger modifying the store and re-rendering the chart.

I hope this helps,

andresantos
7 Sep 2011, 5:43 AM
I will try it. Really thanks.

jbishop
7 Sep 2011, 4:33 PM
I am not a programmer myself but I am very interested in this thread. Phil, can you please answer some more questions so I can better understand the possibilities.

Can you "listen" to the chart in the case of a bar chart? Specifically I want to record values for both bar and line charts where the x-axis represents dates. I would need to be able to add new points for the current date, or any past date with a null entry (which is not necessarily the latest entry).

By extension, if the above is possible then I assume that deletion would also be possible. Is that correct?

Is it possible to modify existing points on the bar and/or line chart by dragging - again for the current date or a past date that is not necessarily the most recent data point. Naturally the dragging could only be up or down since the point would correspond to a single date.

Is it possible to specify a fixed region on the chart for a button to enable or disable the add / delete and edit functionality. I think I'm asking if you can segment the chart into areas that "listen" for gestures.

If you are willing to provide any code snippets, like you did below, then I'm sure it would be a great help to the programmer.

I appreciate any advice you can give.