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

Support a way to get Charts JSON data without ZK execution available

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Normal Normal
    • 3.0.2
    • 3.0.1
    • Security Level: Jimmy
    • None

      Use Case

      Users need to generate a report periodically in a working thread at the server without rendering a ZK Charts in a browser. highcharts provides a nodejs export server, and it accepts Charts JSON to produce an image/PDF. But there is no API to get Charts JSON.
      Let users compose JSON manually is a burden for them.

      Workaround

          public String generateChartJson() throws NoSuchFieldException, IllegalAccessException {
              Charts chart = new Charts();
              PlotData plotData = new PlotData(chart) {
                  @Override
                  public void onChange(OptionDataEvent event) {
                      //on purpose do nothing to avoid accessing an Execution
                  }
              };
              Field field = Charts.class.getDeclaredField("_plotData");
              field.setAccessible(true);
              field.set(chart, plotData);
      
              chart.setModel(model);
              return chart.getPlotData().toJSONString();
          }
      

            rudyhuang rudyhuang
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 2 hours
                1d 2h