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.


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.


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.


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.


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.

<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)}">
  <xsl:for-each select=".//BUBBLE">
    <xsl:value-of select="PROD_LINE"/>
  <xsl:for-each select=".//BUBBLE">
    <xsl:value-of select="PROD_LINE"/>
  <xsl:for-each select=".//BUBBLE">
    <Cell><xsl:value-of select="PROD_NUM"/></Cell>
    <Cell><xsl:value-of select="SALES"/></Cell>
    <Cell><xsl:value-of select="MKT_SHARE"/></Cell>

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

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

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.


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.

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

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.


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

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!


« June 2016