[Axis X and Axis Y] setting 1 unit = 1 dot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
NaggingDaivy
Posts: 21
Joined: Mon Jan 09, 2017 2:04 pm
antibot: No, of course not.

[Axis X and Axis Y] setting 1 unit = 1 dot

Post by NaggingDaivy » Tue Feb 07, 2017 9:10 am

Hello again,

My aim is to make a graph of pixels, but the main problem is that the values are not "glued" to each other, because the axis X and axis Y unit is not 1 unit = 1 dot
To be more clear, here is my current graph (the dots are at a resolution of 10x10 pixels) :


Here, the pixels are not glued :

http://imgur.com/a/1tLhz

Here, the pixels are glued (I made an unzoom)

http://imgur.com/a/42dPu

I want the graph to be exactly as an image would be : pixels next to each others.

Thanks in advance !

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

Re: [Axis X and Axis Y] setting 1 unit = 1 dot

Post by paradoxoff » Tue Feb 07, 2017 7:54 pm

THe major problem ist that with a fixed symbol size, the data points will only be "glued together" if you use a specific zoom level.
I do not think that there is an easy solution to achieve what you want. I had almost suggested to look at this thread and see whether you would like to write a renderer and dataset to create a heat map, but then I noted that your data popints do not form a regular grid.

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

Re: [Axis X and Axis Y] setting 1 unit = 1 dot

Post by paradoxoff » Wed Feb 08, 2017 1:58 pm

Alternatively, you could use an XYBlockRenderer and set the blockWidth to 1.0. Note that an XYBlockRenderer will also scale the symbol height to a user defined value.

NaggingDaivy
Posts: 21
Joined: Mon Jan 09, 2017 2:04 pm
antibot: No, of course not.

Re: [Axis X and Axis Y] setting 1 unit = 1 dot

Post by NaggingDaivy » Wed Feb 08, 2017 3:02 pm

The problem is that I need a LookupPaintScale and I can't use it with a DotRenderer :/

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

Re: [Axis X and Axis Y] setting 1 unit = 1 dot

Post by paradoxoff » Thu Feb 09, 2017 12:52 pm

I was suggesting XYBlockRenderer, not XYDotRenderer.

NaggingDaivy
Posts: 21
Joined: Mon Jan 09, 2017 2:04 pm
antibot: No, of course not.

Re: [Axis X and Axis Y] setting 1 unit = 1 dot

Post by NaggingDaivy » Thu Feb 09, 2017 1:18 pm

paradoxoff wrote:I was suggesting XYBlockRenderer, not XYDotRenderer.
Sorry for that, I confused Dot and Block.
However, the unit of Axis Y is half the unit of Axis X (http://imgur.com/a/9OS9O).
So,how to set the unit of Axis Y the same as X (to have a square, as I asked)?

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

Re: [Axis X and Axis Y] setting 1 unit = 1 dot

Post by paradoxoff » Thu Feb 09, 2017 5:32 pm

Ok, I think I have understood you requriement.
In general, I see two approaches:
- Make sure that the "aspect ratio" (length in data space divided by length in Java2D space) is the same for both axes. If the x axis has a value range from 0-100, and the data area has a width of 400 pixel anda height of 300 pixel, the y axis would need to have a value range of 75. Synchronizing the value range might be possible with an AxisChangeListener, but I do not see an easy way to keep the apsect ratio of the data area in sync.
- Write your own renderer that first determines the width of a data symbol in Java2D dependent on the current zoom level and then use the same Java2D length to draw a Rectangle at the given data coordinate.

Locked