Jfree chart help with SPC

Hi everyone,

I am having a heck of a time figuring out the last piece of adding a custom SPC chart. I have a dataset with 6 series (actual, target, LSpec, USpec, LCL, UCL) and was able to get shapes to appear on only the actual series and get the others to be the correct colors with the following code:

[code] # JFree Chart customizations (these also need to be done in the configureChart event):
# - Show Actual in black, Target in green, UCL & LCL in yellow, USpec & LSpec in red
# - Show data point shapes only on Actual series
# - This overrides defaults in chart customizer so manually set stroke to something a little thicker than the default
plot = event.source.parent.getComponent(‘chPV’).getChart().getPlot()
line_shape = XYLineAndShapeRenderer()
stroke = BasicStroke(2)
line_shape.setStroke(stroke)
line_shape.setSeriesShapesVisible(0, 1)
line_shape.setSeriesShape(0, Ellipse2D.Double(-2, -2, 4, 4))
line_shape.setSeriesShapesFilled(0, 0)
line_shape.setSeriesShapesVisible(1, 0)
line_shape.setSeriesShapesVisible(2, 0)
line_shape.setSeriesShapesVisible(3, 0)
line_shape.setSeriesShapesVisible(4, 0)
line_shape.setSeriesShapesVisible(5, 0)

plot.setRenderer(line_shape)

line_shape.setShapesFilled(1)
line_shape.setUseOutlinePaint(1)

plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(0, Color.black)
plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(1, Color.green)
plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(2, Color.red)
plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(3, Color.red)
plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(4, Color(217,217,0))
plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(5, Color(217,217,0))[/code]

The last piece I’m trying to do is get the shapes on the actual series to display a different color when they exceed the LCL or UCL.

I’ve seen lots of Java posts referring to getItemPaint or drawFirstPassShape but I am not making the connection between those posts and how to do it in my script. I also saw the XYShapeRenderer but that seems to override anything I do with the XYLineAndShapeRenderer.

Any help is greatly appreciated.

Thanks,
Steve

1 Like

In case it helps anyone in the future I accomplished this by looping through my existing dataset and copied any out-of-control records into a new dataset. I then had complete control over that new dataset to do shapes only.

I’m still curious if it can be done with one dataset and scripting :scratch: