• ankitsfdc
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi

 

I have what I thought would be a simple thing but can’t work out how, or if, Visualforce charts can do it.

 

I have a set of data derived in Apex code which has:

 

  1. User Name
  2. Category
  3. Number (in category)

… and would like to graph it as such (using X, Y, Z to represent colour bars):

 

  5                             Legend
N 4   XY         Z              User X
u 3   XY         Z      Y       User Y
m 2   XYZ       YZ     XY       User Z
  1   XYZ      XYZ     XYZ
      Good     Bad     Ugly
           Category

The problem I have is that both the number of users and number of categories is not fixed (they are determined in the controller's Apex code). I can ensure every User has a value for every category (even if it is 0) so that is not a problem. In the sparse examples in the docs, I can only see how to do it when the number of categories is indetermined. They show data structures as such:

 

graph data {

    user_x

    user_y

    user_z

    category_label

    number

}

 

But since I don't know how many users I'll have (nor their names) until the code has run, I am not sure how to put the data nor the visualforce code together. I tried experimenting with things like:

 

<apex:chart height="300" width="700" data="{!activityGraph}" id="actChart">
    <apex:legend position="right"/>
    <apex:axis type="Numeric" position="left" fields="numberM" title="# Ms"/>
    <apex:axis type="Category" position="bottom" fields="catLabel" />
    <apex:barSeries title="{!activityGraph[0].userName}" axis="left" xField="catLabel" yField="{!activityGraph[0].numberM}" orientation="vertical"/>
</apex:chart>

…with the hope of embedding the barSeries into a <apex:repeat> loop. But that doesn't work.

 

I am really hoping that I am missing something simple here. Anyone got any ideas?

 

Regards

MellowRen