Adding support for triangular diagrams - input welcome

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Adding support for triangular diagrams - input welcome

Post by paradoxoff » Sun Mar 20, 2011 11:26 am

Since I needed the described plot type for phase diagrams, I have written up a couple of classes that allow to construct these ternary XYPlots. The classes have been uploaded in form of a patch, artifact id 3228589.
No changes to existing JFreeChart classes have been made, however, the following changes could improve the support for ternary XYPots with less code:
- The XYPlot class presently supports only grid lines for the primary domain and the primary range axis. A ternary xy plot would also need grid lines for the "right" axis. If the support of gridlines could be extended to more domain and range axes and if the drawing of both domain and range gridlines was delegated to a single protected method, the draw() method of the TriangularXYPlot class would be much shorter.
- The drawBackground() and fillBackground() methods of the XYPlot and Plot classes receive a Rectangle2D as plotArea which is to be filled. This would need to be generalized to a Shape.
- The main difference of the new TriangularXYItemRenderer is that it is using a slightly different way for converting the data coordinates to screen or device coordinates. If this conversion was delegated to a protected method (e. g. convertValueToJava2DCoordinates(double dataX, double dataY, ValueAxis domainAxis, ValueAxis rangeAxis, ...)), an arbitrary XYItemRenderer could be extended by simply overriding this new method to support triangular plots. At present, suport for triangular xy plots by a more complex renderer such as the XYBlockRenderer or the XYBubbleRenderer would require that the drawItem() method is overriden and most of the advanced rendering logic reimplemented by copy-paste.
- The support for AxisEntities needs to be changed to take the "skewed" orientation of the axis into account. At present, Axis.createAndAddEntity() assumes that the data area is rectangular and that the axis are either strictly vertical or horizontal.

Locked