Class Chart

  • All Implemented Interfaces:
    Styleable, EventTarget
    Direct Known Subclasses:
    PieChart, XYChart

    public abstract class Chart
    extends Region
    Base class for all charts. It has 3 parts the title, legend and chartContent. The chart content is populated by the specific subclass of Chart.
    Since:
    JavaFX 2.0
    • Constructor Detail

      • Chart

        public Chart()
        Creates a new default Chart instance.
    • Method Detail

      • getTitle

        public final String getTitle()
        Gets the value of the property title.
        Property description:
        The chart title
      • setTitle

        public final void setTitle​(String value)
        Sets the value of the property title.
        Property description:
        The chart title
      • getTitleSide

        public final Side getTitleSide()
        Gets the value of the property titleSide.
        Property description:
        The side of the chart where the title is displayed
        Default value:
        Side.TOP
      • setTitleSide

        public final void setTitleSide​(Side value)
        Sets the value of the property titleSide.
        Property description:
        The side of the chart where the title is displayed
        Default value:
        Side.TOP
      • getLegend

        protected final Node getLegend()
        Gets the value of the property legend.
        Property description:
        The node to display as the Legend. Subclasses can set a node here to be displayed on a side as the legend. If no legend is wanted then this can be set to null
      • setLegend

        protected final void setLegend​(Node value)
        Sets the value of the property legend.
        Property description:
        The node to display as the Legend. Subclasses can set a node here to be displayed on a side as the legend. If no legend is wanted then this can be set to null
      • legendProperty

        protected final ObjectProperty<Node> legendProperty()
        The node to display as the Legend. Subclasses can set a node here to be displayed on a side as the legend. If no legend is wanted then this can be set to null
        See Also:
        getLegend(), setLegend(Node)
      • isLegendVisible

        public final boolean isLegendVisible()
        Gets the value of the property legendVisible.
        Property description:
        When true the chart will display a legend if the chart implementation supports a legend.
      • setLegendVisible

        public final void setLegendVisible​(boolean value)
        Sets the value of the property legendVisible.
        Property description:
        When true the chart will display a legend if the chart implementation supports a legend.
      • getLegendSide

        public final Side getLegendSide()
        Gets the value of the property legendSide.
        Property description:
        The side of the chart where the legend should be displayed
        Default value:
        Side.BOTTOM
      • setLegendSide

        public final void setLegendSide​(Side value)
        Sets the value of the property legendSide.
        Property description:
        The side of the chart where the legend should be displayed
        Default value:
        Side.BOTTOM
      • getAnimated

        public final boolean getAnimated()
        Indicates whether data changes will be animated or not.
        Returns:
        true if data changes will be animated and false otherwise.
      • setAnimated

        public final void setAnimated​(boolean value)
        Sets the value of the property animated.
        Property description:
        When true any data changes will be animated.
      • getChartChildren

        protected ObservableList<Node> getChartChildren()
        Modifiable and observable list of all content in the chart. This is where implementations of Chart should add any nodes they use to draw their chart. This excludes the legend and title which are looked after by this class.
        Returns:
        Observable list of plot children
      • animate

        protected void animate​(Animation animation)
        Play the given animation on every frame of the animation the chart will be relayed out until the animation finishes. So to add a animation to a chart, create a animation on data model, during layoutChartContent() map data model to nodes then call this method with the animation.
        Parameters:
        animation - The animation to play
      • requestChartLayout

        protected void requestChartLayout()
        Call this when you know something has changed that needs the chart to be relayed out.
      • shouldAnimate

        protected final boolean shouldAnimate()
        This is used to check if any given animation should run. It returns true if animation is enabled and the node is visible and in a scene.
        Returns:
        true if animation is enabled and the node is visible and in a scene
      • layoutChartChildren

        protected abstract void layoutChartChildren​(double top,
                                                    double left,
                                                    double width,
                                                    double height)
        Called to update and layout the chart children available from getChartChildren()
        Parameters:
        top - The top offset from the origin to account for any padding on the chart content
        left - The left offset from the origin to account for any padding on the chart content
        width - The width of the area to layout the chart within
        height - The height of the area to layout the chart within
      • layoutChildren

        protected void layoutChildren()
        Invoked during the layout pass to layout this chart and all its content.
        Overrides:
        layoutChildren in class Parent
      • computeMinHeight

        protected double computeMinHeight​(double width)
        Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So minimum height is a constant 150.
        Overrides:
        computeMinHeight in class Region
        Parameters:
        width - the width that should be used if min height depends on it
        Returns:
        the computed minimum height for this region
      • computeMinWidth

        protected double computeMinWidth​(double height)
        Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So minimum width is a constant 200.
        Overrides:
        computeMinWidth in class Region
        Parameters:
        height - the height that should be used if min width depends on it
        Returns:
        the computed minimum width of this region
      • computePrefWidth

        protected double computePrefWidth​(double height)
        Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So preferred width is a constant 500.
        Overrides:
        computePrefWidth in class Region
        Parameters:
        height - the height that should be used if preferred width depends on it
        Returns:
        the computed preferred width for this region
      • computePrefHeight

        protected double computePrefHeight​(double width)
        Charts are sized outside in, user tells chart how much space it has and chart draws inside that. So preferred height is a constant 400.
        Overrides:
        computePrefHeight in class Region
        Parameters:
        width - the width that should be used if preferred height depends on it
        Returns:
        the computed preferred height for this region
      • getClassCssMetaData

        public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
        Returns:
        The CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
        Since:
        JavaFX 8.0