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

Chart type(k-series-defaults) 2 way binding with AngularJS

1 Answer 159 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Salim
Top achievements
Rank 1
Salim asked on 09 Feb 2016, 05:04 AM

I have reproduced this issue in here ... http://dojo.telerik.com/@Salmal/OcALi 

I am implementing Kendo Charts for my AngularJS application . I have a scenario where i need to change the type of the Chart when user clicks on a button .

For this i am using k-series-defaults attribute directive and for its value i am binding a scope variable from controller . Please see below code snippets.

 View.html

<div class="demo-section k-content wide">
    <div>
        <h4>Hover some series</h4>
        <div kendo-chart
             k-legend="{ position: 'bottom' }"
             k-series-defaults="{ type: 'pie' }"
             k-series="[{ field: 'amount', categoryField: 'name'}]"
             k-data-source="chartData"
             k-rebind="chartData">
        </div>
    </div>
</div>

 Ctrl.js

$scope.chartData = [
        {
            "name": "Books",
            "amount": 200
        },
        {
            "name": "Newspapers",
            "amount": 320
        },
        {
            "name": "Magazines",
            "amount": 225
        },
        {
            "name": "Shoes",
            "amount": 400
        }
      ];
 
      $scope.update = function () {
          $scope.ChartType = { type: 'bar' };
      };
 
      $scope.ChartType = { type: 'pie' };

 

My problem is that , the ChartType variable change doesn't reflect in the chart rendered in the view . Which means that the AngularJS 2 way binding doesn't work with the kendo ui charts . Is there something i am missing here , or can we use some alternatives such as ObservableArray  as specified here http://docs.telerik.com/kendo-ui/AngularJS/data-source#update-the-datasource-object . ?

 

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 11 Feb 2016, 09:43 AM
Hi Salim,

I am not quite sure if I understand correctly what the actual issue is - could you please elaborate a bit more what the expected outcome is?

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Salim
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or