Social Icons

среда, 1 мая 2013 г.

Drawing charts with wxWidgets. Part I - Introduction.


I developed wxFreeChart to provide wxWidgets the flexible and comprehensive framework for building charting applications with support of the various chart types, with various data sources, and control of the most visual representation attributes (fonts, axes configuration, titles, background, etc). wxFreeChart is using model-controller-view pattern. It’s design allows to easily integrate various data sources (files, sensors, calculated by application, database, received by network, etc). Data source is abstract, e.g. it’s no sense for framework of how data received. Rendering system enables application developer to make many different chart types with the same approach. Almost every aspect of visual representation can be controlled, this allow you, for example, to make as many axes, as you need, change their colors and fonts, set markers and their appearance, set gradient backgrounds, change legend, chart title and it’s font and color. wxFreeChart is like a set of many building blocks, that developer configure and links them together. Project has wxWidgets license. You can use wxFreeChart in your applications (even commercial) for free.

Supported chart types.

wxFreeChart supports the following chart types:
  1. Line XY charts.
  2. Histogram XY charts.
  3. Area XY charts.
  4. Bar charts.
  5. Stacked bar charts.
  6. Layered bar charts.
  7. OHLC bars financial charts.
  8. OHLC candlesticks financial charts.
  9. Bubble charts.
  10. Gantt charts.
  1. Markers.
  2. Crosshair.
  3. Dynamic charts.
  4. Unlimited amount of axes. 
  5. Gradient backgrounds and bars.
  6. Legend.
  7. Bars and candlestick colors can be controlled by various conditions (e.g. indicators, etc).
  8. Zoom and pan for charts.
wxFreeChart design.

Main concepts are:
  1.  Dataset.
  2. Renderer.
  3. Axis.
  4. Plot.
  5. Chart.         
  6. wxChartPanel.

Dataset is a data access interface. It's a model in Model-Controller-View pattern. It doesn't hold data by itself, it only defines data interface. There are different implementations (they are described below). You can write your own Dataset implementation, if noone provided classes fits your needs.

Datasets can be following types:

  1. XYDataset. Provides data for charts, based on XY coordinates.
  2. CategoryDataset. For charts with numeric/string information on one axis, and string information on another, and pie plots.
  3. OHLCDataset. For financial quote charts.
  4. XYZDataset. For bubble charts.


Renderer is object, that performs data drawing. For one dataset type, can be many renderer, for example: XYDataset can be rendered as lines, histogram or area, OHLCDataset can be drawn as bars or candlesticks.

Renderers can be following types:

  1. XYRenderer. For drawing XY data.
  2. BarRenderer. For drawing bars: normal, stacked, layered.
  3. OHLCRenderer. For drawing financial quote data.
  4. XYZDataset. For drawing XYZ data.

Axis is an object, that performs data scaling and axis rendering.
  1. NumberAxis. For displaying numeric labels, and scaling numeric data.
  2. CategoryAxis. For string labels.
  3. DateAxis. For date/time labels.
  4. CompDateAxis. Interval axis for date/time labels.


Plot is an object, that connects axes, datasets, visual objects (markers, crosshairs). It contains title, background, etc.


Chart is an object, that contains title, plot.

Other objects.
  1. Markers.
  2. Area draws.
  3. Legend.
  4. AxisShare.
  5. Multiplot.

Markers are used to mark data values and/or intervals. Markers are connected with dataset. There are following marker types:

  1. Point marker. Marks single point value.
  2. Line marker. Uses to mark the specified value as line.
  3. Range marker. Used to mark the specified range of values.

Area draws. 

Area draws are objects, that performs drawing background (plot, chart), bars in bars plots, legend symbols, etc. There two area draw types: fill and gradient.


Legend draws legend symbols and serie names. It has position within plot, font to draw labels, etc. Legend can be vertical or horizontal.


AxisShare is helper object, that makes it possible to create combined axis plots.


Multiplot is a special kind of plot, that contains many subplots. It's used to 


In this part of article, i introduced wxFreeChart design. In the next parts i will provide you an example of how to create a simple chart, more detailed explanation for wxFreeChart objects, dataset-renderers configurations for each chart type.


Комментариев нет:

Отправить комментарий