wxCharts Basics

Introduction

This tutorial describes the general principles common to all types of charts.

It starts by showing the class structure that is followed by all the chart types.

Class Structure

Each chart follows the structure shown on the diagram below. The diagram uses the column chart as an example.

{ "elements": [ { "class": { "name": "wxControl", "attributes": [ ], "operations": [ ] } }, { "class": { "name": "wxChartCtrl", "attributes": [ ], "operations": [ ] } }, { "class": { "name": "wxColumnChartCtrl", "attributes": [ ], "operations": [ ] } }, { "class": { "name": "wxChart", "attributes": [ ], "operations": [ ] } }, { "class": { "name": "wxColumnChart", "attributes": [ ], "operations": [ ] } }, { "class": { "name": "wxChartOptions", "attributes": [ ], "operations": [ ] } }, { "class": { "name": "wxColumnChartOptions", "attributes": [ ], "operations": [ ] } }, { "class": { "name": "wxChartsCategoricalData", "attributes": [ ], "operations": [ ] } }, { "relationship": { "type": "inheritance", "baseclass": "wxControl", "derivedclass": "wxChartCtrl" } }, { "relationship": { "type": "inheritance", "baseclass": "wxChartCtrl", "derivedclass": "wxColumnChartCtrl" } }, { "relationship": { "type": "inheritance", "baseclass": "wxChart", "derivedclass": "wxColumnChart" } }, { "relationship": { "type": "inheritance", "baseclass": "wxChartOptions", "derivedclass": "wxColumnChartOptions" } }, { "relationship": { "type": "composition", "containingclass": "wxColumnChartCtrl", "containedclass": "wxColumnChart" } }, { "relationship": { "type": "composition", "containingclass": "wxColumnChart", "containedclass": "wxColumnChartOptions" } }, { "relationship": { "type": "composition", "containingclass": "wxColumnChart", "containedclass": "wxChartsCategoricalData" } } ] }

Each chart has a class derived from wxChartCtrl that allows the chart to be used as a typical wxWidgets control. This class is only a small wrapper around the a class derived from wxChart which implements most of the chart logic. This class can be used directly when it is not desirable to use the chart as a control. The last class each chart type has to implement is a class that derives from wxChartOptions and defines the various configuration options for the chart.

And finally each chart is associated with some kind of data that it is able to display. In general the same kind of data can be displayed by multiple type of charts. For instance the wxChartsCategoricalData type can be displayed by the wxColumnChartCtrl as shown on the diagram but also the wxBarChartCtrl and others.