Thursday 2 August 2012

BI Publisher Charts Advanced Tags – Horizontal Bar Example


Following my previous blog on using advanced tags in BI Publisher charts, here’s another example, this time with horizontal bar charts.
Start with a standard horizontal bar chart, this time showing % of responses from a customer survey. The biggest issue here is that the x-axis scaling goes over 100, so we want to restrict it to just 100.

Now in the Advanced tab we make the following changes to the XML:
Move the legend to the bottom by adding automaticPlacement="AP_NEVER" and position="LAP_BOTTOM" to the LegendArea tag.
<LegendArea visible="true" automaticPlacement="AP_NEVER" position="LAP_BOTTOM" />
Now add a title to the chart by adding the Title tag with a GraphFont subtag after the LegendArea tag:
<Title text="Customer Survey Response Summary" visible="true" horizontalAlignment="CENTER">
<GraphFont bold="false" italic="false" underline="false" fontColor="#000000" />
</Title>

Specify our own colours on the bars by adding a section of <SeriesItems> tag and sub-tags, adding this after the Title tag.
<SeriesItems>
<Series id="0" color="#000080" />
<Series id="1" color="#FF80FF" />
<Series id="2" color="#00C0C0" />
</SeriesItems>

Set the X-Axis scaling. Note that BIP calls the X-Axis the Y-Axis in horizontal charts and also the documentation for these tags is incorrect in this case as it claims the tag is “y1axis” when actually it must be upper case Y and A – “Y1Axis”. We add this tag after the <SeriesItems> tag above.
<Y1Axis axisMinAutoScaled="false" axisMinValue="0" axisMaxAutoScaled="false" axisMaxValue="100" />
Finally specify a title for the X-Axis – again note the Y-Axis tag name – Y1Title:
<Y1Title text="% Positive Reponses" visible="true">
<GraphFont size="12" bold="false" italic="false" underline="false" fontColor="#000000" />
</Y1Title>

The resulting bar chart then looks like this:

The entire XML from the advanced tag is:

<Graph seriesEffect="SE_AUTO_GRADIENT" graphType="BAR_HORIZ_CLUST">
<LegendArea visible="true" automaticPlacement="AP_NEVER" position="LAP_BOTTOM" />
<Title text="Customer Survey Response Summary" visible="true" horizontalAlignment="CENTER">
<GraphFont bold="false" italic="false" underline="false" fontColor="#000000" />
</Title>
<SeriesItems>
<Series id="0" color="#000080" />
<Series id="1" color="#FF80FF" />
<Series id="2" color="#00C0C0" />
</SeriesItems>
<Y1Axis axisMinAutoScaled="false" axisMinValue="0" axisMaxAutoScaled="false" axisMaxValue="100" />
<Y1Title text="% Positive Reponses" visible="true">
<GraphFont size="12" bold="false" italic="false" underline="false" fontColor="#000000" />
</Y1Title>
<LocalGridData colCount="{count(xdoxslt:group(.//G_33,  'SURVEYQUESTION'))}"
rowCount="{count(xdoxslt:group(.//G_33,  'YEAR'))}">
<RowLabels>
<xsl:for-each-group select=".//G_33" group-by="YEAR" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<Label><xsl:value-of select="current-group()/YEAR" /></Label>
</xsl:for-each-group></RowLabels><ColLabels>
<xsl:for-each-group select=".//G_33" group-by="SURVEYQUESTION" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<Label><xsl:value-of select="current-group()/SURVEYQUESTION" /></Label>
</xsl:for-each-group></ColLabels><DataValues><xsl:for-each-group select="//G_33"
group-by="./YEAR" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="G1" select="current-group()" />
<RowData><xsl:for-each-group select="//G_33" group-by="./SURVEYQUESTION"><Cell>
<xsl:value-of select="sum($G1[(./SURVEYQUESTION=current()/SURVEYQUESTION)]/COLUMN3_16[.!='']) div
count($G1[(./SURVEYQUESTION=current()/SURVEYQUESTION)]/COLUMN3_16[.!=''])" /></Cell>
</xsl:for-each-group></RowData></xsl:for-each-group>
</DataValues>
</LocalGridData>
</Graph>


4 comments:

  1. Can you explain how to control the font size of the values on the x-axis? For example: "Happy with service received"
    Thanks.

    ReplyDelete
  2. Hi,

    Nice presentation. Please provide XML for the above presentation. It will be useful for us.

    Thanks,

    ReplyDelete
  3. Please provide the XML?

    ReplyDelete