Menu

problem with delete series and chart rerender

Mike H
2012-05-02
2012-05-30
  • Mike H

    Mike H - 2012-05-02

    Hi,

    I have another problem, which only appears when the chart is rerendered. This time the problem occurs when deleting a series from the chart, or only if the chart is rerendered after that. (e.g. switched to another panel) I added an example project to show what I mean. This is my example scenario to show this strange behaviour:
    1. switch to other panel (you can do here whatever you want, the problems starts after switching)
    2. add 2 series (3 series are now in the chart)
    3. switch to other panel (the 3 series still in the chart)
    4. delete 2 series (1 series are now in the chart)
    5. switch to other panel (there are 3 series in the chart, where 2 are "ghost"-series; with getSeries() you get the correct number of series in the chart, namely 1)
    6. add 2 series (now there are 5 series in the chart (2 are still "ghosts")
    7. switch to other panel (there are 3 series in the chart, because the 2 new series "overwrite(?)" the "ghosts")
    8. delete all series (chart is empty)
    9. switch to other panel (the 3 series are back as "ghosts",but the chart is still empty when you try to use getSeries())

    It looks like the number of "ghosts" is equal to the number of maximum series that were in the chart when the chart was rerendered.

    I also observed this (or a similar) behaviour with the setPoints method. e.g.: I have a series with 8 points. After that I use the setPoints methode with only 5 points. The chart shows everything correct. Then I switched to another panel and it shows a series with 8 points again, while the first 5 points are the points I used with the setPoints method and the others the points[5-7] from the original series. (I have an example project for this as well and could also upload it if desired.)

    Is there any way to solve this problem (or problems)?

    Thanks in advance,
    Mike

     

    Last edit: Mike H 2012-05-02
  • Mike H

    Mike H - 2012-05-30

    Hi,

    Finally I found a solution for my problems. I had to change the BaseChart.java as follows:

    2705,2715c2705,2710
    <       if (seriesList.size() > 0) {
    <           final JSONValue seriesValue = options.get("series");
    <           if (seriesValue == null || seriesValue.isArray() == null) {
    <               options.put("series", new JSONArray());
    <           }
    <           final JSONArray seriesArray = (JSONArray) options.get("series");
    <           for (int i = 0, seriesListSize = seriesList.size(); i < seriesListSize; i++) {
    <               Series series = seriesList.get(i);
    <               JSONObject seriesOptions = convertSeriesToJSON(series);
    <               seriesArray.set(i, seriesOptions);
    <           }
    ---
    >       options.put("series", new JSONArray());
    >       final JSONArray seriesArray = (JSONArray) options.get("series");
    >       for (int i = 0, seriesListSize = seriesList.size(); i < seriesListSize; i++) {
    >           Series series = seriesList.get(i);
    >           JSONObject seriesOptions = convertSeriesToJSON(series);
    >           seriesArray.set(i, seriesOptions);
    2753,2756c2748
    <       JSONValue dataValue = seriesOptions.get("data");
    <       if (dataValue == null || dataValue.isArray() == null) {
    <           seriesOptions.put("data", new JSONArray());
    <       }
    ---
    >       seriesOptions.put("data", new JSONArray());
    

    I also don't understand, why you have to check if the values are null before creating an fresh array, because afterwards all the data is rewritten anyway. But if you check if the values are null and there is already data, you have this problems with the "ghost" data, if the new values are smaller than the old ones, because you cannot delete the old data that is too much from the array.

    If I have misunderstood something, then please let me know.

    Thanks,
    Mike

     

Log in to post a comment.