A new implementation for Ternary Graphs

Ideas and wishes for TeeChart
Post Reply
Errol
Newbie
Newbie
Posts: 29
Joined: Mon Jul 08, 2019 12:00 am

A new implementation for Ternary Graphs

Post by Errol » Thu Nov 21, 2019 1:07 am

The current Ternary Series implementation in TeeChart needs a revamp. It does not suit a lot of users who wish to plot data in a similar format to a regular X-Y plot, without having to implement a lot of special code. A ternary plot is basically an X-Y plot, as there are only 2 independent variables (Z is always equal to 100 - X% - Y% where X% = X/(X+Y+Z)*100 and Y% = Y/(X+Y+Z)*100). This means there is no need to use 3D charting code. In fact, ternary data can be plotted on a simple X-Y chart, but it doesn't look so good and is less easy to understand, so special triangular axes are employed.

I have attached a spreadsheet which shows my thinking. On the first spreadsheet, data is plotted on a simple X-Y plot. The Z-axis is in the direction of the blue arrow, at right-angles to the diagonal edge of the chart. As you can see, the Z-values are correctly located at 80, 60 and 40% respectively, as shown below.
Ternary_XY_Plot.jpg
Ternary_XY_Plot.jpg (95.05 KiB) Viewed 48197 times
In the second sheet, I have drawn sloping "axes", and again plotted X-Y data. To do this, the X% and Y% values need to be recalculated using the following formulae:
X% Ternary = X% + Y% * cos(60°)
Y% Ternary = Y% * sin(60°)

Examining the chart, it is clear that the X%, Y% and Z% values are plotted correctly.
Ternary_Triangle.jpg
Ternary_Triangle.jpg (69.81 KiB) Viewed 48197 times
Finally, XValues (in TeeChart) should always correspond to the value at the right vertex of the graph, and YValues to the top vertex of the graph. In the current formulation, XValues corresponds to the top vertex and YValues to the right vertex, apparently following the clockwise rotation of the axes in one configuration. however, the order or rotation of the axes is arbitrary, and the true axis direction for each vertex is a line from the mid-point of the side opposite the vertex to the corresponding vertex. It is just convention to draw the axis on one adjacent side of the triangle or the other. In the third spreadsheet, I have shown three axis configurations commonly in use, an apparent clockwise rotation, and anti-clockwise rotation and where just the x-axis and the y-axis are shown. The data is plotted in exactly the same place for all three configurations. The important aspect is the location of the vertex, so whatever is at the right vertex uses XValues and whatever is at the top axis uses YValues.

The advantage of an implementation like this is that Custom Line Series, Point Series and FastLine Series should be able to be used, just as for a regular XY plot. The implementation should offer the choice of the three axis configurations, and hopefully the chart will be able to be zoomed just like a regular X-Y plot. Also, many special ternary graphs require a template of lines demarcating different areas of interest on the graph. These will be able to be drawn as simple line series, with all the tools to change colours, line widths and symbols, rather than having to implement a series after draw for such details.

Best regards

Errol
Attachments
TernaryPlot_Steema.zip
(22.26 KiB) Downloaded 2437 times

Post Reply