首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在KendoUI/角窗口上调整高图表的大小

如何在KendoUI/角窗口上调整高图表的大小
EN

Stack Overflow用户
提问于 2015-03-09 04:17:39
回答 1查看 1.3K关注 0票数 0

在这个沉重的 -- AngularJS上有一个包含高级图表的KendoWindow。如果您调整窗口的大小,图表不会调整大小以适应。High图表元素是包装在指令中的jQuery。

这在纯Jquery中起作用,方法是使用样式height:100%;width:100%;position:absolute设置High图表容器。KendoWindow和容器之间有更多的div,这可能就是问题所在。

有什么想法吗?

HTML:

代码语言:javascript
复制
<div kendo-window="win" style="width:600px;height:400px">
  <div dir-highcharts render="render"></div>
</div>

Javascript

代码语言:javascript
复制
var app = angular.module("app", [ "kendo.directives" ]);

function MyCtrl($scope) {

    $scope.render = 0;

        $scope.$on("kendoWidgetCreated", function(event, widget){
          if (widget === $scope.win) {
              $scope.render++;  // add 1 to render the chart when the window is created
          }
      });

}


app.directive("dirHighcharts", function() {

    var directive = {};

    directive.replace = true;

    directive.restrict = 'AE';

    directive.scope = {
                     render: '='
                  };

    directive.template = '<div id="container" style="height:100%;width:100%;position:absolute;"></div>';


    directive.link = function (scope, element, attrs) { 

            scope.$watch('render', function(newValue,oldValue) {
                if ( newValue != oldValue ) {
                    renderChart();
                }
             });


        var renderChart = function() {
            var settings = {             
                    chart: {
                    renderTo: 'container',
                    type: 'line'
                }
                ,xAxis: {
                  categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                      'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
               },
              series: [{
                      name: 'Tokyo',
                      data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
                  }, {
                      name: 'London',
                      data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
               }]
            };

            scope.chart = new Highcharts.Chart(settings);

        };
    };

    return directive;

});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-10 04:39:07

这对我有用,当KendoWindow调整大小时,重新绘制图表.

代码语言:javascript
复制
    $scope.options = {
            resize: function() {
                $scope.render++;
                $scope.$apply();
            }
        };

扑通

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28935178

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档