【问题标题】:Create JSON object using TypeScript使用 TypeScript 创建 JSON 对象
【发布时间】:2013-01-29 18:00:31
【问题描述】:

我的代码中目前有一个 Highcharts,我使用 JavaScript 通过创建 JSON 对象来处理数据,代码 sn-p 看起来像

var yearChartOptions = {
    chart: {
        renderTo: 'YearChartContainer',
        type: 'column',
        margin: [ 50, 50, 50, 50]
    },
    title: {
        text: ''
    },
    xAxis: {
        categories: [],
        labels: {
            rotation: -90,
            align: 'right'
        }
    },
    yAxis: {
        title: {
            text: ''
        },
        plotLines: [{
            color: '#FF0000',
            width: 2,
            label: {
                style: {
                    color: 'blue',
                    fontWeight: 'bold',
                    zIndex: -1
                },
                formatter: function () {
                    return '$' + Highcharts.numberFormat(this.value/1000, 0) +'k ';
                }
            },
            zIndex: 10
        }]
    },
};

// Create the chart
var yearChart = new Highcharts.Chart(yearChartOptions);

如何在 TypeScript 中编写以获得相同的 JavaScript 结果?

【问题讨论】:

标签: javascript typescript


【解决方案1】:

在您的文件中添加/// <reference path="highcharts.d.ts" /> 标签。您可以从DefinitelyTyped 获取文件。一切都应该从那里开始。

【讨论】:

    猜你喜欢
    • 2019-11-26
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    • 2016-10-27
    • 2023-03-30
    • 1970-01-01
    • 2018-05-05
    • 2018-11-05
    相关资源
    最近更新 更多