Class JFreeChartEngine

  • All Implemented Interfaces:
    java.io.Serializable, ChartEngine

    public class JFreeChartEngine
    extends java.lang.Object
    implements ChartEngine, java.io.Serializable
    A chart engine implemented with JFreeChart.

    Available in ZK PE and ZK EE.

    This is the JFreeChart base chart engine implementation. All chart would support drilldown by providing Area hot spots. Each Area would callback to ChartAreaListener class that application developers can do processing on each area.

    Note that useful ChartModel information is put in Area's custom attribute Map so you can retrieve them by calling Area's getAttribute(key) method and use them in drilldown function. Following is the table of keys for different ChartModel.

    modelkey
    PieModelentity
    category
    value
    CategoryModelentity
    series
    category
    value
    XYModelentity
    series
    x
    y
    XYZModelentity
    since 3.5.0series
    x
    y
    z
    HiLoModelentity
    series
    date
    open
    high
    low
    close
    volumn

    Following is the explanation for each key:

    • entity: entity is used to distinguish the different entities on a chart. It might be TITLE, CATEGORY, DATA, LEGEND. The most important entity might be DATA entity where the real chart data point is located. For example, the DATA Area is each slice in a Pie chart.
    • category: category name of the associated data.
    • value: value of the associated data.
    • series: series name of the associated data.
    • x: x value of the XYModel and XYZModel
    • y: y value of the XYModel and XYZModel
    • z: z value of the XYZModel
    • date, open, high, low, close, volumn: data of the HiLoModel

    See also jFreeChart.

    Since:
    3.0.0
    Author:
    henrichen
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] drawChart​(java.lang.Object data)
      Draw the chart and render into image format as an byte array.
      protected java.lang.String getGanttTaskTooltip​(java.util.Date start, java.util.Date end, java.lang.Number percent)
      Returns data tooltiptext of the GanttTask.
      protected boolean prepareJFreeChart​(org.jfree.chart.JFreeChart jfchart, Chart chart)
      Developers with special needs can override this method to apply own rendering properties on the created JFreeChart.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JFreeChartEngine

        public JFreeChartEngine()
    • Method Detail

      • prepareJFreeChart

        protected boolean prepareJFreeChart​(org.jfree.chart.JFreeChart jfchart,
                                            Chart chart)
        Developers with special needs can override this method to apply own rendering properties on the created JFreeChart. The original implementation of this method simply return false to tell the engine to apply its default rendering properties. Return true tells the engine NOT to apply its default rendering properties.
        Parameters:
        jfchart - the created JFreeChart
        chart - the ZK chart component associated with this ChartEngine.
        Returns:
        true to tell this engine NOT to apply its default rendering properties; false to tell this engine TO apply its default rendering properties.
        Since:
        3.0.1
      • drawChart

        public byte[] drawChart​(java.lang.Object data)
        Description copied from interface: ChartEngine
        Draw the chart and render into image format as an byte array.
        Specified by:
        drawChart in interface ChartEngine
        Parameters:
        data - the data used in drawing a chart; depends on implementation.
      • getGanttTaskTooltip

        protected java.lang.String getGanttTaskTooltip​(java.util.Date start,
                                                       java.util.Date end,
                                                       java.lang.Number percent)
        Returns data tooltiptext of the GanttTask.
        Parameters:
        start - the starting date
        end - the ending date
        percent - the complete percentage
        Returns:
        data tooltiptext of the GanttTask.