Uploaded image for project: 'ZK Charts'
  1. ZK Charts
  2. ZKCHARTS-53

DefaultXYModel removeValue() causes model data error after B-ZKCHARTS-19

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 3.0.2
    • Security Level: Jimmy
    • Labels:
      None

      Description

      Steps to Reproduce

      Run attached example (chartremoveitem.zul and ChartRemoveItemVM.java)
      Click on the get chart data button
      chart data is "{"chart":

      {"type":"spline"}

      ,"series":[

      {"data":[[1,10],[2,15],[3,20],[4,15],[5,5],[6,1],[7,9]],"name":"Test"}

      ]}"

      Click the remove button
      Click the get chart data button
      Chart data is "{"chart":

      {"type":"spline"}

      ,"series":[]}"

      Click remove again, fails with NPE because chart data is empty

      Current Result

      1st click delete the expected value but also delete the whole serie on chart data side
      2nd click fails due to serie model not existing on server side

      Expected Result

      removing 1 point shouldn't delete the whole serie

      Debug Info

      Root Cause

      Chart point deletion event is modified by org.zkoss.chart.Series.onChange(OptionDataEvent):931
      event.setCurrentTarget(this);
      Which cause the event target to become the series rather than the point itself.

      Then in org.zkoss.chart.PlotData.onChange(OptionDataEvent):196
      list.remove(target);
      The target of the event is removed from the model

      This cause the series to be removed from data instead of the point

      Workaround

      Download attached PlotData.java, and add it to classPath while maintaining package structure

        Attachments

        1. chartremoveitem.zul
          0.4 kB
        2. ChartRemoveItemVM.java
          1.0 kB
        3. PlotData.java
          27 kB

          Issue Links

            Activity

              People

              • Assignee:
                rudyhuang rudyhuang
                Reporter:
                MDuchemin MDuchemin
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 10 minutes
                  4h 10m