Skip to content
wxWidgets - Cross-Platform GUI Library
Stop Russia agression of Ukraine
Stop the War in Ukraine

wxWidgets is united with the people of Ukraine and the international community.

wxChartDir - Using ChartDirector in wxWidgets applications

Posted on by Ulrich Telle

Many real-world applications have the requirement to display data in a graphical form using various types of diagrams like pie, bar, line, or scatter charts, just to name a few. wxWidgets applications are no exception.

The wxWidgets library itself offers no explicit charting support, but several separate open source wxWidgets-based components exist which claim to fulfill the needs for graphical data representation - at least to a certain degree:

  • wxMathPlot
    Support for scientific x-y diagrams including zooming and panning
  • wxFreeChart
    Support for various business chart types (line, histogram, area, bar, pie, bubble, gantt, OHLC)
  • wxCharts
    Support for various business chart types (pie, donut, line, column, stacked column, bar, stacked bar, scatter, polar, radar, bubble, OHLC, candlestick)

As is unfortunately often the case for open source components the above mentioned components either support only a limited set of diagram types or suffer from lack of features or lack of continued development, although they may suffice for certain use cases.

Even resorting to a commercial charting library can be a bumpy road to success, since very few charting libraries support the wxWidgets framework directly. However, with the arrival of wxChartDir this has changed.

wxChartDir wxChartDir provides components for the integration and use of the commercial C++ library ChartDirector, a universal charting library developed by Advanced Software Engineering Ltd, in wxWidgets based applications.

ChartDirector is an extremely versatile, stable and affordable charting library, that supports many different chart types like pie, donut, bar, line, spline, step line, trend line, curve-fitting, inter-line filling, area, band, scatter, bubble, floating box, box-whisker, waterfall, contour, heat map, surface, vector, finance, gantt, radar, polar, rose, pyramid, cone, funnel and more. Charts can be created as vector graphics in PDF and SVG and as raster graphics in PNG, JPG, GIF and BMP. Please visit the ChartDirector gallery to get an impression of the capabilities of this library.

wxChartDir includes the following charting controls:

  1. wxChartViewer - a wxWidgets control that inherits from wxPanel and ViewPortManager. A viewport can be imagined as a rectangular window of an underlying rectangular surface.
  2. wxViewPortControl - a wxWidgets control that inherits from wxPanel and ViewPortControlBase. A viewport control is a user interface element to let the user visualize and manipulate the viewport managed by the ViewPortManager.

Included with wxChartDir are wxWidgets based versions of all sample applications coming with ChartDirector. Many of them demonstrate the various types of interactive charts.

Figure 1 shows a crosshair cursor with a tooltip for data points and data value labels on the axes.

Crosshair Cursor
Figure 1: Crosshair Cursor

Figure 2 shows the display of realtime data allowing to measure the distance between data points selected by positioning 2 track lines.

Track Lines
Figure 2: Measuring data between 2 track lines

Figure 3 shows the zooming and scrolling of the viewport via a viewport control.

Viewport Control
Figure 3: Controling the viewport

Figure 4 shows the visualization of 3D data.

3D Surface
Figure 4: 3D surface

Figure 5 shows the feature to zoom and scroll in 2 dimensions.

X-Y Zoom/Scroll
Figure 5: Horizontal and vertical zooming and scrolling

All relevant parts of the ChartDirector trial version for C++ are included in the wxChartDir distribution. This allows to compile and test the sample applications without having to download and install ChartDirector separately.

The ChartDirector trial version is fully functional, but will produce yellow banner messages at the bottom of the generated chart images. To eliminate these banners the purchase of a ChartDirector license is required.

Comments

Blog Archive