Show stopper in Box Plot
Posted: Wed Jun 25, 2008 7:16 pm
Hello,
I have come across a critical bug in Box Plot.
It does not behave well if I happen to give it only two values to plot in a series.
Am I doing something wrong? I understand that two values is not a normal number of values for a Box, but I feel like TeeChart should not throw an exception. Rather it should degrade gracefully.
One of my co-workers found that setUseCustomValues seems to fix things. I don't think this is applicable though. I am not needing to override the standard algorithm for calculating the structure of the box.
Here is the failing code:
Here is the Exception:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at com.steema.teechart.styles.CustomBox.percentile(CustomBox.java:194)
at com.steema.teechart.styles.CustomBox.reconstructFromData(CustomBox.java:217)
at com.steema.teechart.styles.CustomBox.doBeforeDrawValues(CustomBox.java:262)
at com.steema.teechart.styles.Series.drawSeries(Series.java:2215)
at com.steema.teechart.Chart.internalDraw(Chart.java:670)
at com.steema.teechart.Chart.paint(Chart.java:1807)
at com.steema.teechart.TChart.paintComponent(TChart.java:568)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I have come across a critical bug in Box Plot.
It does not behave well if I happen to give it only two values to plot in a series.
Am I doing something wrong? I understand that two values is not a normal number of values for a Box, but I feel like TeeChart should not throw an exception. Rather it should degrade gracefully.
One of my co-workers found that setUseCustomValues seems to fix things. I don't think this is applicable though. I am not needing to override the standard algorithm for calculating the structure of the box.
Here is the failing code:
Code: Select all
public static void main(String[] args){
JFrame frame = new JFrame("Unhappy Box");
TChart teeChart = new TChart();
teeChart.setBackColor(new Color(255, 255, 255));
teeChart.getAspect().setView3D(false);
Box box1 = new Box(teeChart.getChart());
double[] yvals = new double[] { 10.0,30.0 };
box1.setPosition(1.0);
box1.add(yvals);
frame.getContentPane().add(teeChart);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at com.steema.teechart.styles.CustomBox.percentile(CustomBox.java:194)
at com.steema.teechart.styles.CustomBox.reconstructFromData(CustomBox.java:217)
at com.steema.teechart.styles.CustomBox.doBeforeDrawValues(CustomBox.java:262)
at com.steema.teechart.styles.Series.drawSeries(Series.java:2215)
at com.steema.teechart.Chart.internalDraw(Chart.java:670)
at com.steema.teechart.Chart.paint(Chart.java:1807)
at com.steema.teechart.TChart.paintComponent(TChart.java:568)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)