Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Visual Studio中生成时出现错误的剑道UI图表_Javascript_Angularjs_Kendo Ui_Typescript_Visual Studio 2015 - Fatal编程技术网

Javascript 在Visual Studio中生成时出现错误的剑道UI图表

Javascript 在Visual Studio中生成时出现错误的剑道UI图表,javascript,angularjs,kendo-ui,typescript,visual-studio-2015,Javascript,Angularjs,Kendo Ui,Typescript,Visual Studio 2015,我有一个剑道UI折线图,可以从后端端点获取和显示信息。图表有3个按钮,用于获取3个时间范围(7天、30天和365天)的信息。下面给出了HTML和JS代码 HTML 在VisualStudio中,上面的实现给出了带有 类型“ChartCategoryAxisItem[]上不存在属性“baseUnit” 但是,当运行应用程序时,它工作正常,当点击按钮时,图表更新没有任何问题。生成错误后,我将实现更改为以下内容 $scope.changeTimeframe = time => {

我有一个剑道UI折线图,可以从后端端点获取和显示信息。图表有3个按钮,用于获取3个时间范围(7天、30天和365天)的信息。下面给出了HTML和JS代码

HTML

在VisualStudio中,上面的实现给出了带有

类型“ChartCategoryAxisItem[]上不存在属性“baseUnit”

但是,当运行应用程序时,它工作正常,当点击按钮时,图表更新没有任何问题。生成错误后,我将实现更改为以下内容

$scope.changeTimeframe = time => {
                    $scope.timeFrame = time;
                    kendo.ui.progress($(".auth-chart-loading"), true);
                    if ($("#authChart").data('kendoChart') && $("#authChart").data('kendoChart').options) {
                        if (time === 7) {
                            $("#authChart").data("kendoChart").options.categoryAxis[0].baseUnit = "days";
                        }
                        if (time === 30) {
                            $("#authChart").data("kendoChart").options.categoryAxis[0].baseUnit = "weeks";
                        }
                        if (time === 365) {
                            $("#authChart").data("kendoChart").options.categoryAxis[0].baseUnit = "months";
                            $("#authChart").data("kendoChart").options.categoryAxis[0].labels = { dateFormats: { months:"M/yy"} };
                        }
                    }
                    $scope.authAttempts.read();
                };
我将categoryAxis更改为数组,然后构建问题就消失了。但在运行应用程序时,当我单击按钮将图表更新为30天或1年时,会弹出以下控制台错误,图表将挂起

TypeError:无法设置未定义的属性“baseUnit”

我们正在使用的剑道UI库的版本是2014.3.1119,我们正在脚本文件中使用
TypeScript
。我的开发环境有Visual Studio 2015和TypeScript 1.6版。Visual studio项目文件包括1.0的TypeScriptTools版本。我将其更新为1.6,但不起作用。我还尝试更新剑道UI的typescript定义文件。但这也失败了

我可以做些什么来修复此问题。我是否需要将剑道UI库更新为最新版本。或者还有别的什么

我应该怎么做才能解决这个问题

$scope.changeTimeframe = time => {
                    $scope.timeFrame = time;
                    kendo.ui.progress($(".auth-chart-loading"), true);
                    if ($("#authChart").data('kendoChart') && $("#authChart").data('kendoChart').options) {
                        if (time === 7) {
                            $("#authChart").data("kendoChart").options.categoryAxis.baseUnit = "days";
                        }
                        if (time === 30) {
                            $("#authChart").data("kendoChart").options.categoryAxis.baseUnit = "weeks";
                        }
                        if (time === 365) {
                            $("#authChart").data("kendoChart").options.categoryAxis.baseUnit = "months";
                            $("#authChart").data("kendoChart").options.categoryAxis.labels = { dateFormats: { months:"M/yy"} };
                        }
                    }
                    $scope.authAttempts.read();
                };

                $scope.authAttempts = new kendo.data.DataSource({
                    transport: {
                        read: {
                            url: "/api/reporting/SuccessfulAuthenticationAttempts",
                            dataType: "json",
                            data: () => { return { TimeFrame: $scope.timeFrame } }
                        }
                    },
                    sort: {
                        field: "Date",
                        dir: "asc"
                    }
                });

                $scope.authChart = {
                    dataSource: $scope.authAttempts,
                    legend: {
                        position: "bottom"
                    },
                    seriesDefaults: {
                        type: "line",
                        style: "smooth",
                        tooltip: {
                            visible: true
                        }
                    },
                    series: [
                        {
                            field: "Field 1",
                            name: "FIELD 1",
                            aggregate: "sum",
                        }, {
                            field: "Field 2",
                            name: "FIELD 2",
                            aggregate: "sum",
                        }],
                    categoryAxis: {
                        field: "Date",
                        baseUnit: "days",
                        type: "date"
                    },
                    valueAxis: {
                        labels: {
                            template: (obj) => {
                                return removeDoubleLabels(obj.value);
                            }
                        }
                    },
                    render: e => {
                        // Clear up the loading indicator for this chart
                        kendo.ui.progress($(".auth-chart-loading", e.sender.element.parent()), false);
                    }
                };
$scope.changeTimeframe = time => {
                    $scope.timeFrame = time;
                    kendo.ui.progress($(".auth-chart-loading"), true);
                    if ($("#authChart").data('kendoChart') && $("#authChart").data('kendoChart').options) {
                        if (time === 7) {
                            $("#authChart").data("kendoChart").options.categoryAxis[0].baseUnit = "days";
                        }
                        if (time === 30) {
                            $("#authChart").data("kendoChart").options.categoryAxis[0].baseUnit = "weeks";
                        }
                        if (time === 365) {
                            $("#authChart").data("kendoChart").options.categoryAxis[0].baseUnit = "months";
                            $("#authChart").data("kendoChart").options.categoryAxis[0].labels = { dateFormats: { months:"M/yy"} };
                        }
                    }
                    $scope.authAttempts.read();
                };