Skip to content
Advertisement

How to customise line graph ( LineAndShapeRenderer ) — set line graph colour and hide data point shapes

Currently, the below chart is being created using JFreeChart library.

enter image description here

The code to generate the above image is as follows: However, even though, I set the plot as black color using: plot.getRenderer().setSeriesPaint(2,new Color(0, 0, 0) ); The graph always appears red.

JavaScript

How do I change the color from red to black and how do I remove/hide the “square data points”, such that it becomes a simple line graph?

Advertisement

Answer

Note that CategoryPlot::getRenderer, without an index parameter, returns the first renderer. As there there is no series with index 2, use the renderer directly to alter its series for index 0:

JavaScript

To hide the shapes, as shown here and noting the API change, you could use either of these on your LineAndShapeRenderer instance:

JavaScript

image

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement