Hi Sharon,
If your chart only have a few bubbles (less than 1000), I think the easiest method is to use one scatter layer for each bubble. In this way, you can easily control the position, size and color of each bubble.
The x-axis and y-axis labels can be set up as:
c.xAxis().setLabels(myArrayOfLabels);
c.yAxis().setLabels(myArrayOfLabels);
c.xAxis().setIndent(true);
c.yAxis().setIndent(true);
No matter what are in the text strings, the x-coordinates of the labels are 0, 1, 2, 3, ...., and the y-coordinates of the labels are 0, 1, 2, 3 .... So your bubbles should be at (0, 0), (0, 1), (0, 2), ...(1, 0), (1, 1), (1, 2), ..... You would need to have two double arrays that contains the x-coordinates and y-coordinates of your bubbles.
I am not sure how the size of your bubbles depend on the "the percentage of calculating of numbers". In any case, you would need to determine the size of the bubbles and store them in an array of integers (representing the pixels of the bubbles).
For the color of the bubbles, I am not too sure how it is related to the volume of alerts. In any case, you would need to determine the size of the bubbles and store them in an array of integers (representing the colors of the bubbles). For example, if the color depends linearly on the number range 0 to 1000000, the code to prepare the colors array would be like:
int[] myColorArray = new int[myAlertArray.length];
for (int i = 0; i < myAlertArray.length; ++i)
myColorArray[i] = getColor(myAlertArray[i]);
where the getColor function is:
//change from 0xffcccc to 0xc00000 for 0 to 1000000
int getColor(double myAlert) {
double ratio = Math.min(myAlert / 1000000, 1);
int red = (int)(0xff * (1 - ratio) + 0xc0 * ratio);
int green = (int)(0xcc * (1 - ratio) + 0x00 * ratio);
int blue = (int)(0xcc * (1 - ratio) + 0x00 * ratio);
return (red << 16) | (green << 8) | bluel;
}
After prepare the data (the x-coordinates and y-coordinates array, the size array and the color array), the code is like:
for (int i = 0; i < myXCoor.length; ++i)
c.addScatterLayer(new double[] { myXCoor[i] }, new double[] { myYCoor[i] }, "", Chart.CircleSymbol, mySize[i], myColorArray[i]);
For the legend box showing the symbol size, you may add an empty scatter layer for the legend box entry. For example:
c.addLegend(.........); //add legend box to the space you want
//add a legend entry with the symbol being a 15 pixel grey circle and the label being 15.00%
c.addScatterLayer(null, null, "15.00%", Chart.CircleSymbol, 15, 0xcccccc, 0x888888);
... repeat the above code for more legend entry ...
For the color legend that shows the gradient from 0xffcccc to 0xc00000, you may add an empty contour layer just for the color legend. It is like:
//Put the color axis at the position you want
ColorAxis cAxis = c.addContourLayer(null, null, null).setColorAxis(.....);
cAxis.setLinearScale(0, 1000000, 1000000); //scale 0 to 1000000
cAxis.setColorGradient(true, new int[] {0xffcccc, 0xcc0000}); //color 0xffcccc to 0xcc0000
Hope this can help.
Regards
Peter Kwan |