Refresh a chart with new DataSource?

2 posts, 0 answers
  1. mike
    mike avatar
    23 posts
    Member since:
    Nov 2010

    Posted 06 Jul 2012 Link to this post

    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
      });
  2. Robin
    Robin avatar
    46 posts
    Member since:
    Jul 2012

    Posted 16 Jul 2012 Link to this post

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