Bubblin' Charts

Got a chartin' question today, 'can we build Bubble charts with BIP' - the short answer is 'Yes.' Those of you that have spoken to me will know Im no good at short answers - so here comes the long answer and a 'how-to' 

For those of you that have not seen or heard of them.


Bubble1:


A Bubble chart is a variation of a Scatter chart (if you dont know what a scatter chart is ... go look it up :) in which the data points are replaced with bubbles. A Bubble chart can be used instead of a Scatter chart if your data has three data series, each of which contains a set of values.

For example, the following XML contains values for three types of data not including the product line name: number of products in product line, dollar value of sales for the product line, and percentage size of market share for the line - not grate data but you get the idea, I hope.


<BUBBLES>
 <BUBBLE>
  <PROD_LINE>Electronics</PROD_LINE>
  <PROD_NUM>10</PROD_NUM>
  <SALES>100000</SALES>
  <MKT_SHARE>15</MKT_SHARE>
 </BUBBLE>
 <BUBBLE>
  <PROD_LINE>Household</PROD_LINE>
  <PROD_NUM>13</PROD_NUM>
  <SALES>135000</SALES>
  <MKT_SHARE>25</MKT_SHARE>
 </BUBBLE>
 <BUBBLE>
  <PROD_LINE>Garden</PROD_LINE>
  <PROD_NUM>20</PROD_NUM>
  <SALES>200000</SALES>
  <MKT_SHARE>30</MKT_SHARE>
 </BUBBLE>
</BUBBLES>


Now, we can plot these as a bubble chart - there are 3 components to the bubble plot the x-axis and y-axis position and the diameter of the bubble. Sadly, the charting wizard in the Template Builder does not handle Bubble charts so we have to get our hands dirty and get into the chart XML definition. We need to pass the data above to the charting engine, its needs to be in a specific format.


<DataValues>
 <RowData>
  <Cell></Cell>
 <RowData>
</DataValues>


The RowData group needs to repeat for as many data points or bubbles we need to plot. For our data, we have 3 bubbles so we would need to pass.


<DataValues>
 <RowData>
  <Cell>10</Cell>
  <Cell>100000</Cell>
  <Cell>15</Cell>
 <RowData>
 <RowData>
  <Cell>13</Cell>
  <Cell>135000</Cell>
  <Cell>25</Cell>
 <RowData>
 <RowData>
  <Cell>20</Cell>
  <Cell>20000</Cell>
  <Cell>30</Cell>
 <RowData>
</DataValues>


The first Cell value maps to the x-axis - the Number of Products in the product line
The second Cell value maps to the y-axis - the total sales
The third Cell value maps to the diameter of the bubble - the market share
These are all bound to the product lines in the chart legend.


Now its not so tough to get the data we have mapped to the required format in the chart: definition. Heres the bubble chart definition.


chart:
<Graph graphType="BUBBLE">
<X1Title text="No of Products" visible="true"/>
<Y1Title text="Sales" visible="true"/>
<Title text="Market Share Analysis" visible="true" horizontalAlignment="CENTER"/>

 <LocalGridData colCount="{count(.//BUBBLE)}" rowCount="{count(.//BUBBLE)}">
 <RowLabels>
  <xsl:for-each select=".//BUBBLE">
   <Label>
    <xsl:value-of select="PROD_LINE"/>
   </Label>
  </xsl:for-each>
 </RowLabels>
 <ColLabels>
  <xsl:for-each select=".//BUBBLE">
   <Label>
    <xsl:value-of select="PROD_LINE"/>
   </Label>
  </xsl:for-each>
 </ColLabels>
 <DataValues>
  <xsl:for-each select=".//BUBBLE">
   <RowData>
    <Cell><xsl:value-of select="PROD_NUM"/></Cell>
    <Cell><xsl:value-of select="SALES"/></Cell>
    <Cell><xsl:value-of select="MKT_SHARE"/></Cell>
   </RowData>
  </xsl:for-each>
 </DataValues>
 </LocalGridData>
</Graph> 

Ignore the top part right now and focus on the <DataValues> section:


 <DataValues>
  <xsl:for-each select=".//BUBBLE">
   <RowData>
    <Cell><xsl:value-of select="PROD_NUM"/></Cell>
    <Cell><xsl:value-of select="SALES"/></Cell>
    <Cell><xsl:value-of select="MKT_SHARE"/></Cell>
   </RowData>
  </xsl:for-each>
 </DataValues>


This XSL will map the current data into the required format for the charting engine. The rest of the XML for the chart is regular stuff just need to set the graphType to "BUBBLE" and we're done.


Yes, bubble charts are possible - just requires some effort, that I hope we'll eliminate in a future release of the Template Builder but at least you now know how to build em. Template, XML and output here. Before you ask, I have tested bubbles back to release 5.5 - not so good quality as SVG output was not supported back then but it works.


Update


A couple of follow ups ensued which are worth sharing:


How do I remove the grid lines and big quadrant lines?

To remove the regular gridlines:


<O1MajorTick visible="false"/>
<X1MajorTick visible="false"/>
<Y1MajorTick visible="false"/>
<Y2MajorTick visible="false"/>

These will turn off all grid lines - but not the 'quadrant' lines. For those you need:


<QuadrantLine lineColor="#64ff" visible="false"/> - I just left the lineColor attribute in there for those of you wanting to chage the color rather than remove them.

How can I change the Bubble colors?


Inside the graph tag you can create a set of 'series' to hold the colors.

<SeriesItems>
<Series id="0" color="#cc0000"/>
<Series id="1" color="#ffcc00"/>
</SeriesItems>

You'll need as many id's as data points or as you want different colored bubbles. If there are more bubbles than colors then the colors will loop around again.

Comments:

Hi Tim, I see that this is a topic from the archives, but still very useful to me. Can you tell me if it is possible to have a Bubble chart with text-label / attributes on the axes, instead of the numeric one you show in this sample. For instance strategic alignment vs sponsor. If it possible can you give a tip / sample. Thanks in advance, Jan

Posted by Jan Vogel on July 11, 2010 at 11:44 PM MDT #

how do i change the size and shape of the bubble?

Posted by guest on December 19, 2013 at 04:47 AM MST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Follow bipublisher on Twitter Find Us on Facebook BI Publisher Youtube ChannelDiscussion Forum

Join our BI Publisher community to get the most and keep updated with the latest news, How-to, Solutions! Share your feedback and let us hear your voice @bipublisher on Twitter, on our official Facebook page, and Youtube!

Search

Archives
« August 2015
SunMonTueWedThuFriSat
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     
Today