This is a migrated thread and some comments may be shown as answers.

Additional data in server response

1 Answer 47 Views
Charts
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 17 Feb 2015, 07:02 PM
The titles for my charts are dependent on the data. I would prefer to create the data-dependent title on the server when the chart dataSource does a "read". Is there a way to add additional data in the JSON stream (in addition to the array of data items) that is sent down to the client and have the client process it properly? Off the top of my head, would it make sense to put that in the parse function of the dataSource schema? Would that work - how would I point the chart to the data.chartData and can I set the title in the parse function? I'm thinking the JSON from the server would be something like:

var data = {
  additionalData: {
    title: 'this is the data dependent title'
  },
  chartData: [] // typical chart data here
};

Currently, we are iterating through the received data in the dataBound. This function is getting unnecessarily complex and I want to move some of the processing to the server. This includes generating tooltips, the title, the axisCrossingValues, min, max, majorUnit, categoryAxis title, valueAxis titles, etc.

Thanks in advance,
--John

1 Answer, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 19 Feb 2015, 03:48 PM
I figured out my own answer.
It is in the parse: function. If "e" is the parameter to the parse function, return e.ChartData (based on the data structure above). I can then (in the same parse function, before I return the ChartData) set the titles, Y Axis steps, etc.
Thanks,
--John
Tags
Charts
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Share this question
or