Bubble chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
tony

Bubble chart

Post by tony » Mon Sep 26, 2005 5:57 pm

hi,

How to change the range for z Axis in bubble.
The problem now is bubbles in my chart are entirely covering my chart.
I just wanted to reduce the scale for z-Axis.


Thanks,
tony

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Sep 28, 2005 12:26 pm

You'll need to scale the z-values in your dataset, since the size of the bubbles is taken from the z-value but displayed relative to the x and y axes.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

gaea
Posts: 4
Joined: Mon Apr 21, 2008 1:20 pm

Post by gaea » Mon Apr 21, 2008 2:35 pm

how to scale the the z axis value . for the same dataset i m having perfect chart in excel .but in jfree bubble chart ,the size of the bubble doesnt fits perfect.

i found that if the difference b/w the largest value and the smallest on either the domain or range axis is too large ,then my bubbles are bad.


plz any one post the answer.....

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Apr 21, 2008 2:49 pm

I don't have Excel, so perhaps you could post a sample dataset and the resulting chart from Excel so I could see what the difference is.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

gaea
Posts: 4
Joined: Mon Apr 21, 2008 1:20 pm

Post by gaea » Mon Apr 21, 2008 3:55 pm

much happy at ur reply.

here s my dataset .though the variation are too much .still i m getting good bubbles in excel.
but jfree does not.

i have set my ranges dynamically from min and max values of the domain and range axis.

my dataset



x y z
6.02 17.14 93.46
9.8 43.8 118.928
18.53 0.1 13.83
25.02 1.5 6.05
14.78 499.6 3.2
13.479 -7.4 16.404

gaea
Posts: 4
Joined: Mon Apr 21, 2008 1:20 pm

dataset in clear

Post by gaea » Mon Apr 21, 2008 4:00 pm

x ------------------ y ---------------------------------z
6.02------------------- 17.14------------------------------ 93.46
9.8 ---------------------43.8----------------------------- 118.928
18.53 ------------------0.1 ---------------------------------13.83
25.02 ---------------1.5------------------------------------- 6.05
14.78---------------- 499.6--------------------------------- 3.2
13.479 ----------------(-7.4)------------------------------- 16.404


how can i scale the z-axis range values relative to domain or range axis value

wzwei28
Posts: 105
Joined: Wed Mar 16, 2005 9:17 am
Location: Malaysia, Earth
Contact:

Post by wzwei28 » Tue Oct 28, 2008 9:10 am

JFreeChart 1.0.10 and 1.0.11
The equation is quite simple.(XYZDataset, DefaultXYZDataset)

When we instantiate renderer for bubble chart. We declare as follow:
XYItemRenderer xyItemRendererBubble = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_BOTH_AXIS);
XYItemRenderer xyItemRendererBubble = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_DOMAIN_AXIS);
XYItemRenderer xyItemRendererBubble = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
or
XYItemRenderer xyItemRendererBubble = new XYBubbleRenderer(); //default SCALE_ON_BOTH_AXIS

Let's us open the XYBubbleRenderer class at package org.jfree.chart.renderer.xy
Goto method: public void drawItem(Graphics2D g2, ...etc.)
At swtich(getScaleType()), u will observe 3 case: SCALE_ON_DOMAIN_AXIS, SCALE_ON_RANGE_AXIS and default
default equal to SCALE_ON_BOTH_AXIS.

In this example, I use SCALE_ON_RANGE_AXIS as sample, cause relative easy to understand.
In ur chart, on range-axis maybe form by 100. And it divide into 10 dotted lines which 1 interval is 10.
Then, when u Want to draw a bubble which the Z-value (equal to diameter of bubble=2 radius).
If diameter = 10, then the z-value for the seriesItem should be 10.0 If u dataset range axis is 10000,
then u want a bubble conquer 10% of the chart range, the z-axis(diameter) should be 1000 indeed.
*To automatic calculate to fit the best z-value on various chart type. U will need a double value called dRatio.

dZ * dRatio will equal to the Z-value if in SCALE_ON_RANGE_AXIS type.
How to determine dRatio? U may use ur talented brain to think about it.
(CLUE:based on dataset on different stock)

Pretty easy, ya?

Locked