Class WAbstractChart

Direct Known Subclasses:
WCartesianChart, WPieChart

public abstract class WAbstractChart
extends WPaintedWidget
Abstract base class for MVC-based charts.

This is an abstract class and should not be used directly.

As an abstract base for MVC-based charts, this class manages the model setModel() and provides virtual methods that listen to model changes. In addition, it gives access to generic chart properties such as the title setTitle() and title font setTitleFont(), the chart palette setPalette(), plot area padding setPlotAreaPadding(), and the background fill color setBackground().

CSS

Styling through CSS is not applicable.

See Also:
WCartesianChart, WPieChart
  • Method Details

    • remove

      public void remove()
      Destructor.
      Overrides:
      remove in class WPaintedWidget
      See Also:
      WContainerWidget.removeWidget(WWidget widget)
    • setModel

      public void setModel​(WAbstractItemModel model)
      Sets the model.

      The model is used by the chart to get its data. Ownership of the model is not transferred, and if a previous model was set it is not deleted.

      The default model is a null model.

      This creates an internal proxy model that presents the WAbstractItemModel as a WAbstractChartModel. Use setModel() directly for highest performance (avoiding the overhead of boost::any for numeric data).

      Note: Setting a new model on a WCartesianChart causes the WCartesianChart.XSeriesColumn() and all series to be cleared

      See Also:
      getModel()
    • setModel

      public void setModel​(WAbstractChartModel model)
      Sets the model.

      The model is used by the chart to get its data. Ownership of the model is not transferred, and if a previous model was set it is not deleted.

      The default model is a null model.

      Note: Setting a new model on a WCartesianChart causes the WCartesianChart.XSeriesColumn() and all series to be cleared

      See Also:
      getModel()
    • getModel

      public WAbstractChartModel getModel()
      Returns the model.

      See Also:
      setModel(WAbstractChartModel model)
    • getItemModel

      public WAbstractItemModel getItemModel()
      Returns the model.

      If a model was set using setModel(), then this model will be returned by this call.

      See Also:
      setModel(WAbstractChartModel model)
    • setBackground

      public void setBackground​(WBrush background)
      Sets a background for the chart.

      Set the background color for the main plot area.

      The default is a completely transparent background.

      See Also:
      getBackground()
    • getBackground

      public WBrush getBackground()
      Returns the background of the chart.

      See Also:
      setBackground(WBrush background)
    • setPalette

      public void setPalette​(WChartPalette palette)
      Set a palette for the chart.

      A palette is used to provide the style information to render the chart series. Ownership of the palette is transferred to the chart.

      The default palette is dependent on the chart type.

      See Also:
      getPalette()
    • getPalette

      public WChartPalette getPalette()
      Returns the palette for the chart.

      See Also:
      setPalette(WChartPalette palette)
    • setPlotAreaPadding

      public void setPlotAreaPadding​(int padding, java.util.EnumSet<Side> sides)
      Set an internal margin for the main plot area.

      This configures the area (in pixels) around the plot area that is available for axes, labels, and titles.

      The default is dependent on the chart type.

      Alternatively, you can configure the chart layout to be computed automatically using setAutoLayoutEnabled().

      See Also:
      setAutoLayoutEnabled(boolean enabled)
    • setPlotAreaPadding

      public final void setPlotAreaPadding​(int padding, Side side, Side... sides)
      Set an internal margin for the main plot area.

      Calls setPlotAreaPadding(padding, EnumSet.of(side, sides))

    • setPlotAreaPadding

      public final void setPlotAreaPadding​(int padding)
      Set an internal margin for the main plot area.

      Calls setPlotAreaPadding(padding, Side.All)

    • getPlotAreaPadding

      public int getPlotAreaPadding​(Side side)
      Returns the internal margin for the main plot area.

      This is either the paddings set through setPlotAreaPadding() or computed using setAutoLayoutEnabled()

      See Also:
      setPlotAreaPadding(int padding, EnumSet sides)
    • setAutoLayoutEnabled

      public void setAutoLayoutEnabled​(boolean enabled)
      Configures the chart layout to be automatic.

      This configures the plot area so that the space around it is suited for the text that is rendered (axis labels and text, the title, and legend).

      The default value is false, and the chart layout is set manually using values set in setPlotAreaPadding().

    • setAutoLayoutEnabled

      public final void setAutoLayoutEnabled()
      Configures the chart layout to be automatic.

      Calls setAutoLayoutEnabled(true)

    • isAutoLayoutEnabled

      public boolean isAutoLayoutEnabled()
      Returns whether chart layout is computed automatically.

      See Also:
      setAutoLayoutEnabled(boolean enabled)
    • setTitle

      public void setTitle​(java.lang.CharSequence title)
      Set a chart title.

      The title is displayed on top of the chart, using the getTitleFont().

      The default title is an empty title ("").

      See Also:
      getTitle()
    • getTitle

      public WString getTitle()
      Return the chart title.

      See Also:
      getTitle()
    • setTitleFont

      public void setTitleFont​(WFont titleFont)
      Set the font for the chart title.

      Changes the font for the chart title.

      The default title font is a 15 point Sans Serif font.

      See Also:
      getTitleFont(), setTitle(CharSequence title)
    • getTitleFont

      public WFont getTitleFont()
      Returns the font for the chart title.

      See Also:
      setTitleFont(WFont titleFont)
    • paint

      public abstract void paint​(WPainter painter, WRectF rectangle)
      Paint the chart in a rectangle of the given painter.

      Paints the chart inside the painter, in the area indicated by rectangle. When rectangle is a null rectangle, the entire painter WPainter.getWindow() is used.

    • paint

      public final void paint​(WPainter painter)
      Paint the chart in a rectangle of the given painter.

      Calls paint(painter, null)

    • modelChanged

      protected void modelChanged()
    • modelReset

      protected void modelReset()