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

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

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 3.0.1
    • Fix Version/s: 3.0.2
    • Security Level: Jimmy
    • Labels:
      None

      Description

      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();
          }
      

        Activity

        Hide
        rudyhuang rudyhuang added a comment -

        Ready since 2017/12/20

        Show
        rudyhuang rudyhuang added a comment - Ready since 2017/12/20
        Show
        rudyhuang rudyhuang added a comment - https://www.zkoss.org/javadoc/latest/zkcharts/org/zkoss/chart/ChartsEngine.html

          People

          • Assignee:
            rudyhuang rudyhuang
            Reporter:
            hawk hawk
          • Votes:
            0 Vote for this issue
            Watchers:
            2 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 - 1 day, 2 hours
              1d 2h