Interactive Surface Chart

Interactive Surface Chart Example in C++ (MFC, Qt) and C# (.NET Windows Forms, WPF)

Interactive Surface Chart (C++ MFC/Qt and C# Windows Forms/WPF) This example demonstrates a surface chart that can rotate in 3D using mouse drag. An important part of this example is to illustrate continuous chart interaction in ChartDirector by using the viewport event system.

Continuous Chart Interaction and Viewport Event

When you click on a bar in a bar chart to drill down, it is a one-off interaction. In contrast, when you drag on a surface chart to rotate it, the chart needs to be updated continuously as the mouse moves. One way to do this is to update the chart in the mouse move event handler. However, modern systems can generate a large number of mouse move events very quickly. If the update is complex or the system is not fast enough, the GUI thread may not have time left to process other GUI events, and the GUI may appear sluggish.
ChartDirector has supported mouse drag for zooming and scrolling for a long time. Instead of updating the chart in the mouse move event handler, ChartDirector raises "viewport events" and updates the chart in the viewport event handler. The viewport system is designed to ensure a gap between invoking the event handler. This allows other GUI events can get processed and the GUI remains responsive.

Surface Chart Rotation using Viewport Events

Although viewport events are original developed for supporting zooming and scrolling, they are also useful in applications with continuous chart interaction. This example demonstrates using viewport events to update a surface chart on mouse drag. As ChartDirector supports multiple programming languages and GUI frameworks, we just use simplified "pseudo code" for the explanation.


*** Note *** : If you are new to ChartDirector, it is recommended you download ChartDirector from the download page to try it. It includes complete ChartDirector documentation as well as plenty of sample code designed as tutorials. The following assumes you already have some basic understanding of ChartDirector.
The sample code in this page is included as part of the "ChartDirector Extra Sample Code Pack".
ChartDirector Extra Sample Code Pack for C++ (MFC, Qt)
ChartDirector Extra Sample Code Pack for .NET (C# Windows Forms, WPF)


The original Surface Chart (1) sample code with fixed view angles.
The API to configure the gap between viewport events.