XYBubble chart .. how do i use it

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

XYBubble chart .. how do i use it

Post by develop » Wed May 09, 2007 5:02 pm

how can i use XYBubbleRenderer in following case.

I need to draw circles on price chart. so i have domain axis as time
Range axis will be my price axis (normal double values)

i tried to use following dataset for XYBubbleRenderer.. but it does not work.

Can please any one tell me how do specify Z (radius) values for circles.?

Code: Select all

double[] xvalues = new double[2];
        double[] yvalues = new double[2];
        double[] zvalues = new double[2];
        
        xvalues[0] = new Day(14, MonthConstants.JANUARY, 2002).getFirstMillisecond();
        yvalues[0] = 96.290;
        zvalues[0] = 94.653;
        
        xvalues[1] = new Day(11, MonthConstants.FEBRUARY, 2002).getFirstMillisecond();
        yvalues[1] = 96.265;
        zvalues[1] = 90.1578;
        
        DefaultXYZDataset dataset = new DefaultXYZDataset();
        dataset.addSeries("Series 1", 
                new double[][] { xvalues, yvalues, zvalues });

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Wed May 09, 2007 6:39 pm

You specify the scaleType in the constructor.

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Wed May 09, 2007 9:09 pm

i tried. i specified scale to be Range axis, but then it does not show circles.

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Wed May 09, 2007 9:21 pm

develop wrote:i tried. i specified scale to be Range axis, but then it does not show circles.
It probably does show the circles, but they are only about 90 ms wide

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Thu May 10, 2007 4:03 pm

no. Actually it shows big big circle .. like my whole chart becomes red (circle series color). and i can see that series to be added in legend also.

Any idea ?

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 » Fri May 11, 2007 11:16 am

If the z-value is 90.0, and you specified SCALE_ON_RANGE_AXIS, you should see a circle with diameter 90.0 (when measured against the range axis).
David Gilbert
JFreeChart Project Leader

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

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

Post by wzwei28 » Tue Oct 28, 2008 9:13 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 switch(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 9 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?

ozonew4m
Posts: 2
Joined: Wed Oct 29, 2008 2:04 pm
Contact:

wow

Post by ozonew4m » Wed Oct 29, 2008 5:27 pm

I can not believe the information on this site... Im like a kid in a sweet shop ;)

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

Post by wzwei28 » Thu Oct 30, 2008 7:19 am

True, when I look back what I had written, I oso get blur...

In short(only 1 statment)...
Diameter of bubble = Z-value.
Hence, different range axis value will have different meaning in Z-value if using SCALE_ON_RANGE_AXIS
.

This is why we use dRatio with certain percentage of confidence interval to trim/truncate extreme bubble.

In addition, we can use the largest bubbles become standard of the z-value, so that all bubbles appear significantly not too big/small.
*This is useful, for instance: user search various stock from all major stock exchange. And yet, bubbles size is a concern if using default calculation (some might too large cover whole chartPanel, some too small hard to be seen).

Code: Select all

Formula of confidence interval as follow:
Confidence Interval(CI) = MeanX +- Zc *(S/Math.root(n,2)).
Mean = Sum from i to n of Xi divided by N
S^2 = Sum from i to n of (Xi-MeanX)^2 / (n-1)
or S^2 = [Sum from i=1 to n of X^2 - n(MeanX ^2) ] / (n-1) 

 Abbrevation: where 100%-MeanX, 99%-2.576, 95%-1.96, 90%-1.645 from tableS is standard deviation, V is Varians. Sqrt is square root.

Locked