Additional data in server response

2 posts, 0 answers
  1. John
    John avatar
    23 posts
    Member since:
    Jan 2015

    Posted 17 Feb 2015 Link to this post

    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
  2. John
    John avatar
    23 posts
    Member since:
    Jan 2015

    Posted 19 Feb 2015 in reply to John Link to this post

    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
Back to Top