The examples in this menu and the other charting menus Scatter plot and Pie chart demonstrate some of the capabilities of the Wt charting widgets. These widgets are implemented using the Wt painting API WPaintedWidget which provides cross-browser native painting, using VML, SVG, or the HTML5 canvas tag.
The two main chart widgets are
A cartesian chart is either a CategoryChart or a ScatterPlot.
setModel(), set the model column that holds the X data using
setXSeriesColumn(int modelColumn), and add one or more series using
addSeries(const WDataSeries&). Each series corresponds to one data column that holds Y data.
Many aspects of the charts may be customized. By default, style information for rendering data series are taken from a WChartPalette. It is straightforward to specialize this class to provide different styles from the standard styles provided by WStandardPalette.
The cartesian chart has support for dual Y axes. Each data series may be
bound to one of the two Y axes. By default, only the first Y axis is
displayed. To show the second Y axis you will need to call
By default a chart has a horizontal X axis and a vertical Y axis, which
corresponds to a
Vertical orientation. The orientation may be
The styling of the data series are defined by a palette which may be set
setPalette(WChartPalette *), but may be overridden by
settings in each data series.
A category chart has different categories on the X axis, and displays values of one or more data series on the Y axes as a series of bars. The values corresponding to each category are plotted consecutively in model row order. Each data series corresponds to a column from the model and may be rendered differently (This is configured in the data series - See Chart::WDataSeries for more information).
As a cartesian chart it provides automatic configuration of the axes, and support for a second Y axis. In addition, you may use a simple built-in legend, or extend the class to provide a specialized legend. In the example below, we use a manual Y axis configuration, with a break as would be commonly used when your data has a few outliers.
The table view allows editing of the model, which is automatically reflected in the chart.