Package org.zkoss.zul

Class Chart

    • Constructor Detail

      • Chart

        public Chart()
    • Method Detail

      • setType

        public void setType​(java.lang.String type)
        Set the chart's type (Chart.PIE, Chart.BAR, Chart.LINE, etc.).

        Default: pie.

      • getType

        public java.lang.String getType()
        Get the chart's type.
      • setThreeD

        public void setThreeD​(boolean b)
        Set true to show three dimensional graph (If a type of chart got no 3d peer, this is ignored).
      • isThreeD

        public boolean isThreeD()
        Whether a 3d chart.
      • setTitle

        public void setTitle​(java.lang.String title)
        Set the chart's title.
        Parameters:
        title - the chart's title.
      • getTitle

        public java.lang.String getTitle()
        Get the chart's title.
      • getIntWidth

        public int getIntWidth()
        Get the chart int width in pixel; to be used by the derived subclass.
      • setHeight

        public void setHeight​(java.lang.String h)
        Override super class to prepare the int height.
        Overrides:
        setHeight in class HtmlBasedComponent
      • getIntHeight

        public int getIntHeight()
        Get the chart int width in pixel; to be used by the derived subclass.
      • setXAxis

        public void setXAxis​(java.lang.String label)
        Set the label in xAxis.
        Parameters:
        label - label in xAxis.
      • getXAxis

        public java.lang.String getXAxis()
        Get the label in xAxis.
      • setYAxis

        public void setYAxis​(java.lang.String label)
        Set the label in yAxis.
        Parameters:
        label - label in yAxis.
      • getYAxis

        public java.lang.String getYAxis()
        Get the label in yAxis.
      • setShowLegend

        public void setShowLegend​(boolean showLegend)
        whether show the chart's legend.
        Parameters:
        showLegend - true if want to show the legend (default to true).
      • isShowLegend

        public boolean isShowLegend()
        Check whether show the legend of the chart.
      • setShowTooltiptext

        public void setShowTooltiptext​(boolean showTooltiptext)
        whether show the chart's tooltip.
        Parameters:
        showTooltiptext - true if want to pop the tooltiptext (default to true).
      • isShowTooltiptext

        public boolean isShowTooltiptext()
        Check whether show the tooltiptext.
      • setPaneAlpha

        public void setPaneAlpha​(int alpha)
        Set the pane alpha (transparency, 0 ~ 255).
        Parameters:
        alpha - the transparency of pane color (0 ~ 255, default to 255 opaque).
      • getPaneAlpha

        public int getPaneAlpha()
        Get the pane alpha (transparency, 0 ~ 255, opacue).
      • setPaneColor

        public void setPaneColor​(java.lang.String color)
        Set the pane color of the chart.
        Parameters:
        color - in #RRGGBB format (hexadecimal).
      • getPaneColor

        public java.lang.String getPaneColor()
        Get the pane color of the chart (in string as #RRGGBB). null means default.
      • getPaneRGB

        public int[] getPaneRGB()
        Get the pane color in int array (0: red, 1: green, 2:blue). null means default.
      • setFgAlpha

        public void setFgAlpha​(int alpha)
        Set the foreground alpha (transparency, 0 ~ 255).
        Parameters:
        alpha - the transparency of foreground color (0 ~ 255, default to 255 opaque).
      • getFgAlpha

        public int getFgAlpha()
        Get the foreground alpha (transparency, 0 ~ 255, opaque).
      • setBgAlpha

        public void setBgAlpha​(int alpha)
        Set the background alpha (transparency, 0 ~ 255).
        Parameters:
        alpha - the transparency of background color (0 ~ 255, default to 255 opaque).
      • getBgAlpha

        public int getBgAlpha()
        Get the background alpha (transparency, 0 ~ 255, opaque).
      • setBgColor

        public void setBgColor​(java.lang.String color)
        Set the background color of the chart.
        Parameters:
        color - in #RRGGBB format (hexadecimal).
      • getBgColor

        public java.lang.String getBgColor()
        Get the background color of the chart (in string as #RRGGBB). null means default.
      • getBgRGB

        public int[] getBgRGB()
        Get the background color in int array (0: red, 1: green, 2:blue). null means default.
      • setOrient

        public void setOrient​(java.lang.String orient)
        Set the chart orientation.
        Parameters:
        orient - vertical or horizontal (default to vertical)
      • getOrient

        public java.lang.String getOrient()
        Get the chart orientation (vertical or horizontal)
      • getTimeZone

        public java.util.TimeZone getTimeZone()
        Returns the time zone that this Time Series Chart belongs to, or null if the default time zone is used.

        The default time zone is determined by TimeZones.getCurrent().

      • setTimeZone

        public void setTimeZone​(java.util.TimeZone tzone)
        Sets the time zone that this Time Series Chart belongs to, or null if the default time zone is used.

        The default time zone is determined by TimeZones.getCurrent().

      • getPeriod

        public java.lang.String getPeriod()
        Returns the period used in Time Series Chart. The value can be "millisecond", "second", "minute", "hour", "day", "week", "month", "quarter", and "year". default is "millisecond" if not specified.
      • setPeriod

        public void setPeriod​(java.lang.String period)
        Sets the period used in Time Series Chart. The value can be "millisecond", "second", "minute", "hour", "day", "week", "month", "quarter", and "year".
      • getDateFormat

        public java.lang.String getDateFormat()
        Returns the date format used by date related Chart.
        Returns:
        the date format used by date related Chart..
      • setDateFormat

        public void setDateFormat​(java.lang.String format)
        Sets the date format used by date related Chart.
        Parameters:
        format -
      • getModel

        public ChartModel getModel()
        Returns the chart model associated with this chart, or null if this chart is not associated with any chart data model.
      • setModel

        public void setModel​(ChartModel model)
        Sets the chart model associated with this chart. If a non-null model is assigned, no matter whether it is the same as the previous, it will always cause re-render.
        Parameters:
        model - the chart model to associate, or null to dissociate any previous model.
        Throws:
        UiException - if failed to initialize with the model
      • setModel

        public void setModel​(java.lang.String clsnm)
                      throws java.lang.ClassNotFoundException,
                             java.lang.NoSuchMethodException,
                             java.lang.IllegalAccessException,
                             java.lang.InstantiationException,
                             java.lang.reflect.InvocationTargetException
        Sets the model by use of a class name. It creates an instance automatically.
        Throws:
        java.lang.ClassNotFoundException
        java.lang.NoSuchMethodException
        java.lang.IllegalAccessException
        java.lang.InstantiationException
        java.lang.reflect.InvocationTargetException
      • getTitleFont

        public java.awt.Font getTitleFont()
        Returns the title font of this chart. If you saw squares rather than correct words in title, check whether the default title font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Returns:
        the title font
      • setTitleFont

        public void setTitleFont​(java.awt.Font font)
        Sets the title font of this chart. If you saw squares rather than correct words in title, check whether the default title font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Parameters:
        font - the title font of this chart
      • getLegendFont

        public java.awt.Font getLegendFont()
        Returns the legend font of this chart. If you saw squares rather than correct words in legend, check whether the default legend font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Returns:
        the title font
      • setLegendFont

        public void setLegendFont​(java.awt.Font font)
        Sets the legend font of this chart. If you saw squares rather than correct words in legend, check whether the default legend font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Parameters:
        font - the legend font of this chart
      • getXAxisTickFont

        public java.awt.Font getXAxisTickFont()
        Returns the tick number font of x axis of this chart. If you saw squares rather than correct words in x axis tick, check whether the default x axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Returns:
        the tick number font of x axis of this chart
      • setXAxisTickFont

        public void setXAxisTickFont​(java.awt.Font axisTickFont)
        Sets the tick number font of x axis of this chart. If you saw squares rather than correct words in x axis tick, check whether the default x axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Parameters:
        axisTickFont - the tick number font of x axis of this chart
      • getXAxisFont

        public java.awt.Font getXAxisFont()
        Returns the label font of x axis of this chart. If you saw squares rather than correct words in x axis label, check whether the default x axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Returns:
        the label font of x axis of this chart
      • setXAxisFont

        public void setXAxisFont​(java.awt.Font axisFont)
        Sets the label font of x axis of this chart. If you saw squares rather than correct words in x axis label, check whether the default x axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Parameters:
        axisFont - the label font of x axis of this chart
      • getYAxisTickFont

        public java.awt.Font getYAxisTickFont()
        Returns the tick number font of y axis of this chart. If you saw squares rather than correct words in y axis tick, check whether the default y axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Returns:
        the tick number font of y axis of this chart
      • setYAxisTickFont

        public void setYAxisTickFont​(java.awt.Font axisTickFont)
        Sets the tick number font of y axis of this chart. If you saw squares rather than correct words in y axis tick, check whether the default y axis tick font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Parameters:
        axisTickFont - the tick number font of y axis of this chart
      • getYAxisFont

        public java.awt.Font getYAxisFont()
        Returns the label font of y axis of this chart. If you saw squares rather than correct words in y axis label, check whether the default y axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Returns:
        the label font of y axis of this chart
      • setYAxisFont

        public void setYAxisFont​(java.awt.Font axisFont)
        Sets the label font of y axis of this chart. If you saw squares rather than correct words in y axis label, check whether the default y axis label font supports your characters (e.g. Chinese). You probably have to set this font accordingly.
        Parameters:
        axisFont - the tick number font of y axis of this chart
      • newChartEngine

        protected ChartEngine newChartEngine()
                                      throws UiException
        Instantiates the default chart engine. It is called, if setEngine(org.zkoss.zul.impl.ChartEngine) is not called with non-null engine.

        By default, it looks up the library property called org.zkoss.zul.chart.engine.class. If found, the value is assumed to be the class name of the chart engine (it must implement ChartEngine). If not found, UiException is thrown.

        Derived class might override this method to provide your own default class.

        Throws:
        UiException - if failed to instantiate the engine
        Since:
        3.0.0
      • setEngine

        public void setEngine​(ChartEngine engine)
        Sets the chart engine.
      • setEngine

        public void setEngine​(java.lang.String clsnm)
                       throws java.lang.ClassNotFoundException,
                              java.lang.NoSuchMethodException,
                              java.lang.IllegalAccessException,
                              java.lang.InstantiationException,
                              java.lang.reflect.InvocationTargetException
        Sets the chart engine by use of a class name. It creates an instance automatically.
        Throws:
        java.lang.ClassNotFoundException
        java.lang.NoSuchMethodException
        java.lang.IllegalAccessException
        java.lang.InstantiationException
        java.lang.reflect.InvocationTargetException
      • getAreaListener

        public ChartAreaListener getAreaListener()
        Returns the renderer to render each area, or null if the default renderer is used.
      • setAreaListener

        public void setAreaListener​(ChartAreaListener listener)
        Sets the renderer which is used to render each area.

        Note: changing a render will not cause the chart to re-render. If you want it to re-render, you could call smartDraw.

        Parameters:
        listener - the area listener, or null to ignore it.
        Throws:
        UiException - if failed to initialize.
      • setAreaListener

        public void setAreaListener​(java.lang.String clsnm)
                             throws java.lang.ClassNotFoundException,
                                    java.lang.NoSuchMethodException,
                                    java.lang.IllegalAccessException,
                                    java.lang.InstantiationException,
                                    java.lang.reflect.InvocationTargetException
        Sets the renderer by use of a class name. It creates an instance automatically.
        Throws:
        java.lang.ClassNotFoundException
        java.lang.NoSuchMethodException
        java.lang.IllegalAccessException
        java.lang.InstantiationException
        java.lang.reflect.InvocationTargetException
      • smartDrawChart

        protected void smartDrawChart()
        mark a draw flag to inform that this Chart needs update.
      • clone

        public java.lang.Object clone()
        Description copied from interface: Component
        Clones the component. All of its children and descendants are cloned. Also, ID are preserved.
        Specified by:
        clone in interface Component
        Overrides:
        clone in class XulElement
        Returns:
        the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.