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
  • Property Details

  • Constructor Details

    • Chart

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

    • getTitle

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

      public final void setTitle(String value)
      Sets the value of the title property.
      Property description:
      The chart title
      Parameters:
      value - the value for the title property
      See Also:
    • titleProperty

      public final StringProperty titleProperty()
      The chart title
      Returns:
      the title property
      See Also:
    • getTitleSide

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

      public final void setTitleSide(Side value)
      Sets the value of the titleSide property.
      Property description:
      The side of the chart where the title is displayed
      Default value:
      Side.TOP
      Parameters:
      value - the value for the titleSide property
      See Also:
    • titleSideProperty

      public final ObjectProperty<Side> titleSideProperty()
      The side of the chart where the title is displayed
      Default value:
      Side.TOP
      Returns:
      the titleSide property
      See Also:
    • getLegend

      protected final Node getLegend()
      Gets the value of the legend property.
      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
      Returns:
      the value of the legend property
      See Also:
    • setLegend

      protected final void setLegend(Node value)
      Sets the value of the legend property.
      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
      Parameters:
      value - the value for the legend property
      See Also:
    • 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
      Returns:
      the legend property
      See Also:
    • isLegendVisible

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

      public final void setLegendVisible(boolean value)
      Sets the value of the legendVisible property.
      Property description:
      When true the chart will display a legend if the chart implementation supports a legend.
      Parameters:
      value - the value for the legendVisible property
      See Also:
    • legendVisibleProperty

      public final BooleanProperty legendVisibleProperty()
      When true the chart will display a legend if the chart implementation supports a legend.
      Returns:
      the legendVisible property
      See Also:
    • getLegendSide

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

      public final void setLegendSide(Side value)
      Sets the value of the legendSide property.
      Property description:
      The side of the chart where the legend should be displayed
      Default value:
      Side.BOTTOM
      Parameters:
      value - the value for the legendSide property
      See Also:
    • legendSideProperty

      public final ObjectProperty<Side> legendSideProperty()
      The side of the chart where the legend should be displayed
      Default value:
      Side.BOTTOM
      Returns:
      the legendSide property
      See Also:
    • 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 animated property.
      Property description:
      When true any data changes will be animated.
      Parameters:
      value - the value for the animated property
      See Also:
    • animatedProperty

      public final BooleanProperty animatedProperty()
      When true any data changes will be animated.
      Returns:
      the animated property
      See Also:
    • 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()
      Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
      Returns:
      the CssMetaData
      Since:
      JavaFX 8.0
    • getCssMetaData

      public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
      This method should delegate to Node.getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.
      Specified by:
      getCssMetaData in interface Styleable
      Overrides:
      getCssMetaData in class Region
      Returns:
      The CssMetaData associated with this node, which may include the CssMetaData of its superclasses.
      Since:
      JavaFX 8.0