1

Currently looking at Providing Chart Data via a JavaScript Array

As per the example, data is embedded and returned by the JavaScript's dataArray property.

However, the chart does not seem to do anything with the data.

Here is my VisualForce page:

    <apex:page >
    <script>
        // Build the chart data array in JavaScript
        var dataArray = [
                         {'data1':33,'data2':66,'data3':80,'name':'Jan'},
                         {'data1':33,'data2':66,'data3':80,'name':'Feb'}
                       ];
    </script>
    <apex:chart height="350" width="450" data="dataArray">
        <apex:pieSeries dataField="data" labelField="name" />
        <apex:legend position="right" />
    </apex:chart>
</apex:page>

What am I missing?

1 Answer 1

2

The apex:pieSeries renders a single set of values where each value can have a label. So this will render:

var dataArray = [
        {'data':33, 'name':'Jan'},
        {'data':66, 'name':'Feb'},
        {'data':80, 'name':'Mar'}
        ];

If you want multiple values at per label you will need to use e.g. a bar chart where a comma-separated list of JSON field names are supported.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .