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

Refresh a chart with new DataSource?

1 Answer 605 Views
Charts
This is a migrated thread and some comments may be shown as answers.
mike
Top achievements
Rank 1
mike asked on 06 Jul 2012, 09:24 PM
I am needing to reset my datasource to grab parameters from my page to reload the chart. Is there a way to make this happen?

Here is my code for the chart currently. I need change the querystring that goes back on the url for the remote datasource based on page values.

$("#chart").kendoChart({
  dataSource:
  {
      transport:{
          read:{
              url: "@Url.Action("BusinessUnitCompareChart")" + "?date=" + $("#DateFilter").val() + "&StructureId=" + "@ViewData["StructureId"].ToString()" + "&buids=" + "@ViewData["buids"].ToString()",
              dataType:"json"
          }
      },
      group:{ field:"Name"},
  
      sort:{
          field:"Name",
          dir:"asc"
      }
  },
  
  series:[{type:"column", field:"Count"}],
  seriesColors:["#C81717","#8E908F","#0098DB"],
  
  categoryAxis:{ field:"CategoryName"},
  
  theme:  "Metro",
  title: {
  text: "Open/ Aging/ Closed"
  },
                        
  tooltip: {
  visible: true
  },
  seriesClick: onSeriesClick
  });

1 Answer, 1 is accepted

Sort by
0
Robin
Top achievements
Rank 1
answered on 16 Jul 2012, 06:48 PM
I create my datasource outside my chart constructor like
var dataSource = new kendo.data.DataSource({
// Fill in all your options here
});

Then you can call dataSource.read(); and it will refetch the data. So you can manipulate the filter etc. on the dataSource, then call .read() to get the different data.
Tags
Charts
Asked by
mike
Top achievements
Rank 1
Answers by
Robin
Top achievements
Rank 1
Share this question
or