set an empty data causes a javascript error

XMLWordPrintable

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Critical
    • 10.2.1.0
    • Affects Version/s: 7.2.2.0
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      1. run

          <button onClick="setEmptyData()"/>
          <charts id="chart"/>
          <zscript><![CDATA[
          import org.zkoss.chart.*;
      
      public void setEmptyData(){
          chart.getSeries().setData(new Point[0]);
      }
          ]]></zscript>
      

      2. click the button

      Current Result

      • click 1st time
        TypeError: this.addSeries is not a function
      • click the 2nd time
        TypeError: Cannot read properties of undefined (reading '0')

      Expected Result

      no error

      Debug Information

      • key statement chart.getSeries().setData(new Point[0]);
      • the original use case:
        The dev doesn't plan to pass an empty array on purpose. He creates an array from a query result
        Point[] pointArray = new Point[queryResult];
        chart.getSeries().setData(pointArray);
        

      Propose solution

      The method should check the size and render nothing for an empty array. So this will benefit callers.

            Assignee:
            jumperchen
            Reporter:
            hawk
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: