2

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

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 结果?

4

1 回答 1

4

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

于 2013-02-14T01:27:59.600 回答