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

2 posts, 0 answers
  1. Salim
    Salim avatar
    1 posts
    Member since:
    Feb 2016

    Posted 08 Feb Link to this post

    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 . ?

     

  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 11 Feb Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top