2

I currently have a Highcharts in my code, I used JavaScript to massage the data by creating JSON object, the code snippet looks like

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);

How can I write in TypeScript to have the same JavaScript result?

2
  • 1
    yearChartOptions is a JavaScript object. There's no such thing as a "JSON Object". Commented Feb 14, 2013 at 1:18
  • you mean I need to create Highcharts objects by myself? Commented Feb 14, 2013 at 1:22

1 Answer 1

4

Add a /// <reference path="highcharts.d.ts" /> tag to your file. You can get the file from DefinitelyTyped. Everything should just work from there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.