XY dot renderer point size

Is it possible to increase the dot size beyond one pixel? Single pixels are difficult to see, but I don’t see a custom property in the chart customizer.

Thanks,

Tom

I would echo this request. I am using the dot plot to show flaws captured by an imaging system on our non-woven fabric line. I would like to show flaw size represented by the dot size.

-Chris

This feature is in process of being implemented.

I would request that the feature be flexible enough to use any shape, size and color graphic to represent a data point.

Thank you for reading our requests!

An update: Dot thickness is adjustable (from Edit Pen settings/Line Weight) as of 7.6.3-rc4.
Setting color for the dot and choosing shape instead of the dot was already possible.

The Chart component does not use pens like the Easy Chart, is it possible to adjust the dot size on that component?

If this helps anyone, here is what I used to increase dot size on the Chart XY Dot Render:

from org.jfree.chart.renderer.xy import XYDotRenderer

plot = chart.getXYPlot()

dotRenderer = XYDotRenderer()
dotRenderer.setDotWidth(4)
dotRenderer.setDotHeight(4)

plot.setRenderer(dotRenderer)

[quote=“denji26”]If this helps anyone, here is what I used to increase dot size on the Chart XY Dot Render:

from org.jfree.chart.renderer.xy import XYDotRenderer

plot = chart.getXYPlot()

dotRenderer = XYDotRenderer()
dotRenderer.setDotWidth(4)
dotRenderer.setDotHeight(4)

plot.setRenderer(dotRenderer)[/quote]


This fails and tells me .getXYPlot() is npot a valid function, any ideas?
Thanks

You need to grab the underlying Jfree chart first:

[code]from org.jfree.chart.renderer.xy import XYDotRenderer

chart=event.source.parent.getComponent(‘Chart’)
plot = chart.getChart().getXYPlot()

dotRenderer = XYDotRenderer()
dotRenderer.setDotWidth(4)
dotRenderer.setDotHeight(4)

plot.setRenderer(dotRenderer)[/code]

I’ve got an XY plot rendered with the XY Dot Renderer. Im having similar problems increasing the dot size.
Looking in the Chart Customizer there still doesn’t seem to be any pen customization still, besides the series colors.

I’ve tried the code posted above, which worked, but I’ve had to use a button on click script to get it to invoke.

I wanted to put the code under the Charts Extension Function “Configure Chart” but couldn’t figure out why the function wasn’t getting invoked. Can anyone tell me when this extension is supposed to be invoked?

I don’t want to have to put the code to increase button size on a window initialize script or something silly, when it should be configurable on the chart itself. Cheers

I put my script on the configureChart extension function where it executes properly. For reference this is my full configureChart code. Hope it helps! :slight_smile:

from org.jfree.chart.renderer.xy import XYDotRenderer
from java.awt import Color

plot = chart.getXYPlot()

gridColor = Color(85,85,85,192)
dotColor = Color(117,117,117,255)
dotSize = 4

plot.setDomainGridlinePaint(gridColor);
plot.setRangeGridlinePaint(gridColor);
                    
dotRenderer = XYDotRenderer()
dotRenderer.setDotWidth(dotSize)
dotRenderer.setDotHeight(dotSize)
dotRenderer.setPaint(dotColor)

plot.setRenderer(0, dotRenderer)
1 Like

Thanks, i managed to get it working. Few questions though.

  1. What is the 1st argument in setRenderer(0,dotRenderer) doing?

  2. Also I get an error now “Null ‘paint’ argument” when trying to use the setPaint() function. Any idea why this might be? what are the components of Color()? is it Color(Red, Blue, Green, ??).

  3. When i used: plot = self.getChart().getXYPlot() the changes would be made, then revert back to what it was previously. Why does it behave this way?
    It works fine (permanently) if i use: plot = chart.getXYPlot()

Thanks!

Richard,

I am not sure this is still relevant for you, but I will still answer these questions - at least for posterity’s sake.

  1. According to JFree Chart API docs (here: jfree.org/jfreechart/api/jav … YPlot.html )

[quote]setRenderer(int index, XYItemRenderer renderer)
Sets the renderer for the datasetwith the specified index and sends a change event to all registered listeners.[/quote]
You are working with only one dataset, so you do not have to specify its index, and can use this instead:

[quote]setRenderer(XYItemRenderer renderer)
Sets the renderer for the primary dataset and sends a change event to all registered listeners.[/quote]
So the last line in denji26’s code can also be:

plot.setRenderer(dotRenderer)

When working with JFree chart API (or any API for that matter), make sure to always check the API documentation as the first step towards understanding what a method does and what the parameters are. For example, in this case, do a web search for something like “JFree chart setRenderer”, which will bring up the page I gave a link to above.

  1. The first three values are indeed RGB (red-green-blue) values. This last argument is the so called alpha channel (opacity).
    If you do a search for “Java Color”, you will be able to find the documentation for the java.awt.Color class: docs.oracle.com/javase/8/docs/a … Color.html
    According to the documentation,

[quote]Color(int r, int g, int b, int a)
Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0 - 255).[/quote]
Looking at the constructor list on the same page, you will also notice that you can use the constructor without the alpha channel parameter:

[quote]Color(int r, int g, int b)
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).[/quote]
So if you did not want to work with opacity, you could modify the code as follows:

gridColor = Color(85,85,85) dotColor = Color(117,117,117)
If you are getting an error setting paint, pease show us your code adn the complete error text.

  1. There is no reason to use self.getChart().getXYPlot() in the configureChart extension function: the function already has the chart parameter, so using self.getChart() is redundant.
1 Like

how would this work for multiple subplots? Above code only seems to work for one plot in a chart.