function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
twtx61twtx61 

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>

Best Answer chosen by Admin (Salesforce Developers) 
twtx61twtx61

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.

All Answers

twtx61twtx61

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.

This was selected as the best answer
Vadm SfVadm Sf
Hello Txt
Can you just help me on below requirement of VF Chart.
Based on the data, If i click on each row of First Table, It has to show Line  & bar Chart.
User-added image

Thank you in advance