JFreeChart Outlining of bars with HighLowRenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
roshaan_riaz
Posts: 2
Joined: Thu Oct 13, 2016 3:33 pm
antibot: No, of course not.

JFreeChart Outlining of bars with HighLowRenderer

Post by roshaan_riaz » Thu Oct 13, 2016 3:48 pm

Hello there!

I want to outline bars of OHLC dataset, but I couldn't find any good approach to do so. I have tried using HighLowRenderer for setting the outlines of bars using this:

Code: Select all

HighLowRenderer render = (HighLowRenderer) chart.getXYPlot().getRenderer();
renderer.setSeriesOutlineStroke(0, new BasicStroke(4));
renderer.setSeriesOutlinePaint(0, Color.RED);
But it doesn't seem to be working. I have seen other renderers have methods:

Code: Select all

renderer.setDrawBarOutline(true);
renderer.setUseOutlinePaint(true);
But HighLowRenderer doesn't have these methods which allow using outlines on bars.

Can anyone help me to outline bars of OHLC dataset by any other method?

Thanks in advance!

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: JFreeChart Outlining of bars with HighLowRenderer

Post by paradoxoff » Thu Oct 13, 2016 5:15 pm

I do not understand the question. A HighLowRenderer doesnt draw any bars.
If you want to visualize an OHLCDataset usikng bars, you will probably have to write your own renderer.

roshaan_riaz
Posts: 2
Joined: Thu Oct 13, 2016 3:33 pm
antibot: No, of course not.

Re: JFreeChart Outlining of bars with HighLowRenderer

Post by roshaan_riaz » Fri Oct 14, 2016 6:49 am

Sorry for being not so clear. Let me explain it visually.
Here is what I have made already:

https://imagebin.ca/v/2yPSwETRCJAa

In this I have bars for each data point. Now what I want to do is to outline a bar with a color. Like this:

https://imagebin.ca/v/2yPToFKBU7Lw

I couldn't find a way to do so. I have tried using HighLowRenderer but it didn't work as explained earlier.

Thanks.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: JFreeChart Outlining of bars with HighLowRenderer

Post by paradoxoff » Fri Oct 14, 2016 11:53 am

What look like "bars" in your screenshot are simply lines drawn in a thick stroke. Visually, a thick line and a bar might by similar, but from a mathematical or rendering point of view, they are different.
When you study the source of HighLowRenderer.drawItem, you will see that it generates the visual appearance only by drawing lines on the Graphics2D, not by drawing rectangles.
As I said above, you will have to write your own renderer.

Locked