Reply
Contributor
twtx61
Posts: 3
0
Accepted Solution

Dynamic titles in VF Charts

I'm able to create a Visuaforce bar chart that's either stacked or grouped with multiple series similar to the example below.  However, I'm trying to figure out how to make the series title a little more dynamic so it could be data driven.  Any suggestions on how to make that happen?

 

<apex:chart data="{!data}" height="400" width="500">
<apex:legend position="left"/>
<apex:axis type="Numeric" position="left" title="Closed Won" grid="true"
fields="data1,data2,data3" dashSize="2">
<apex:chartLabel/>
</apex:axis>
<apex:axis type="Category" position="bottom" fields="name" title="Stacked Bars">
<apex:chartLabel rotate="315"/>
</apex:axis>
<apex:barSeries orientation="vertical" axis="left" stacked="true"
xField="name" yField="data1,data2,data3" title="MacDonald,Promas,Worle"/>
</apex:chart>

Contributor
twtx61
Posts: 3
0

Re: Dynamic titles in VF Charts

I found a solution for this and it was surprisingly simple.  While you can't use the following:

 

<apex:barSeries orientation="vertical" axis="left" stacked="true" xField="name" yField="data1,data2,data3" title="{!titleString}"/>

where titleString contains a comma separated list of values, you can use 

 

<apex:barSeries orientation="vertical" axis="left" stacked="true" xField="name" yField="data1,data2,data3" title="{!titleString1},{!titleString2},{!titleString3}"/>

 

and you'll a corresponding title value in the legend for each series that contains the contents of titleString1, titleString2 and titleString3.