Ternary plot / Triangular XYPlot
Ternary plot / Triangular XYPlot
Hello guys,
I searched for ternary plots made by JFreeChart, and I found this post and this patch. When I try the TriangularPlotDemo from the patch archive, I got some errors in TriangleLeftAxis and TriangleRightAxis at line #152 cannot find symbols getTextAsLines and at line #160 the same thing.
Somebody knows why? That method is missing?
I searched for ternary plots made by JFreeChart, and I found this post and this patch. When I try the TriangularPlotDemo from the patch archive, I got some errors in TriangleLeftAxis and TriangleRightAxis at line #152 cannot find symbols getTextAsLines and at line #160 the same thing.
Somebody knows why? That method is missing?
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Ternary plot / Triangular XYPlot
Sorry for that. That method was introduced by this patch.. I integrated it into my local JFreeChart installation.
You can add the mssing method manually to the org.jfree.chart.axis.Tick class:
You can add the mssing method manually to the org.jfree.chart.axis.Tick class:
Code: Select all
public String[] getTextAsLines() {
return text.split("\\n");
}
Re: Ternary plot / Triangular XYPlot
Solved the errors, but now I have one more error: for the same classes (TriangleLeftAxis and TriangleRightAxis): at line #43~45, method isLabelVisible doesn't exist. Any suggestion?
Thanks fro your time!
Thanks fro your time!
Re: Ternary plot / Triangular XYPlot
I saw that in the 1.0.15 version, that lines was added in the org.jfree.chart.axis.Tick class. Now, when I try to run the example from that ternary patch I got an exception:
@paradoxoff you get the same exception?
@paradoxoff you get the same exception?
Code: Select all
run:
In TriangularXYPlot.draw
Required height 488.27594797121367
Available height 325.5078125
New height 325.5078125
New width 375.8640463404026
Available width 563.8125
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.jfree.chart.axis.ValueTick.getTextAsLines()[Ljava/lang/String;
at org.jfree.chart.axis.TriangleLeftAxis.drawTickMarksAndLabels(TriangleLeftAxis.java:147)
at org.jfree.chart.axis.NumberAxis.draw(NumberAxis.java:659)
at org.jfree.chart.plot.XYPlot.drawAxes(XYPlot.java:3694)
at org.jfree.chart.plot.TriangularXYPlot.draw(TriangularXYPlot.java:133)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1226)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1612)
at javax.swing.JComponent.paint(JComponent.java:1054)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5228)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1413)
at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
at javax.swing.JComponent.paint(JComponent.java:1040)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
at java.awt.Container.paint(Container.java:1967)
at java.awt.Window.paint(Window.java:3877)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Ternary plot / Triangular XYPlot
The reason for the exception is that the missing getTextAsLines() method is still not present in the Tick class.
I am still working with (a heavily modified) 1.0.13 version of JFreeChart, so I am not seeing it.
The method isLabelVisible() of the Axis class is also a special feature of my local installation. To fix that bug, you just need to add a private boolean labelVisible flag to the Axis class and a setter/getter.
I will upload a new patch for the TriangularPlotDemo that makes this patch runnable with a standard JFreeChart installation.
Sorry that I didn´t care about that earlier.
I am still working with (a heavily modified) 1.0.13 version of JFreeChart, so I am not seeing it.
The method isLabelVisible() of the Axis class is also a special feature of my local installation. To fix that bug, you just need to add a private boolean labelVisible flag to the Axis class and a setter/getter.
I will upload a new patch for the TriangularPlotDemo that makes this patch runnable with a standard JFreeChart installation.
Sorry that I didn´t care about that earlier.
Re: Ternary plot / Triangular XYPlot
Looking forward for the new patch. Why this was not integrated in the last release 1.0.15? Another question regarding the possibility to inverse the right axis (in terms of values).
Let's assume the general rule of a ternary diagram: A,B,C are the corners. If I wanna do a representation of a point in a ternary diagram, the A, B, and C values must be 100% / 100 / 0.1. So. for example if I have A = 60 , B = 20, and C = 20, the points must be in the same point (geometrically). But in my example the right axis must be inverted. How can I do this?
Note: the plotted points are rectangles with 1000 width and for the right and left axes, are rotated 60, respectively 120 degrees, to be parallel with opposite axis.
I tried to change this lines from TriangularXYPlot class:
with this
But remain the same.
Later edit:
I also tried to put this code in the main method without any changes:
Let's assume the general rule of a ternary diagram: A,B,C are the corners. If I wanna do a representation of a point in a ternary diagram, the A, B, and C values must be 100% / 100 / 0.1. So. for example if I have A = 60 , B = 20, and C = 20, the points must be in the same point (geometrically). But in my example the right axis must be inverted. How can I do this?
Note: the plotted points are rectangles with 1000 width and for the right and left axes, are rotated 60, respectively 120 degrees, to be parallel with opposite axis.
I tried to change this lines from TriangularXYPlot class:
Code: Select all
public void setRangeAxis(int index, ValueAxis axis) {
if (axis instanceof TriangleLeftAxis && index == 0) {
super.setRangeAxis(index, axis);
} else if (axis instanceof TriangleRightAxis && index > 0) {
axis.setInverted(true);
super.setRangeAxis(1, axis);
}
}
Code: Select all
public void setRangeAxis(int index, ValueAxis axis) {
if (axis instanceof TriangleLeftAxis && index == 0) {
super.setRangeAxis(index, axis);
} else if (axis instanceof TriangleRightAxis && index > 0) {
axis.setInverted(false); //I supposed that is inverted by default, so I cancel it - nothing happens
super.setRangeAxis(1, axis);
}
}
Later edit:
I also tried to put this code in the main method without any changes:
Code: Select all
plot.getRangeAxis(1).setInverted(true);
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Ternary plot / Triangular XYPlot
I have uploaded an new patch that removes the incompatibilities with a standard JFreeChart installation.
Maybe you can try this. If it doesn´t behave as expected, please provide a compilable and runnable example.
Maybe you can try this. If it doesn´t behave as expected, please provide a compilable and runnable example.
Re: Ternary plot / Triangular XYPlot
Now, with the newest patch it works like a charm! Big thanks for your time. I really appreciate it!
Regarding your patch, how can I attach a letter/text for each corners? Fixed text, without any change in position/scale, when I use zoom in/out. Can you help me to obtain this?
Regarding your patch, how can I attach a letter/text for each corners? Fixed text, without any change in position/scale, when I use zoom in/out. Can you help me to obtain this?
Re: Ternary plot / Triangular XYPlot
It is possible to add line between points using this TriangularXYPlot ?
I'm trying but without success. Thanks!
I'm trying but without success. Thanks!