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

set an empty data causes a javascript error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Critical Critical
    • 10.2.1.0
    • 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.

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

              Created:
              Updated:
              Resolved: