Highcharts Demo

author(s): Torstein Hønsi

by Fusher

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="width: 400px; height: 400px"></div>

JavaScript

$(function () {
    var chart = new Highcharts.Chart({
    
        chart: {
            renderTo: 'container',
            marginTop: 50,
            marginBottom: 50,
            marginLeft: 50,
            marginRight: 50
        },     
        xAxis: {
            gridLineWidth: 1,
            min: -5,
            max: 5,
            tickInterval: 1,
            lineColor: 'black',
            offset: -150
        },
        yAxis: {
            min: -5,
            max: 5,
            tickInterval: 1,
            lineWidth: 1,
            lineColor: 'black',
            offset: -150,
            title: {
                text: null
            }
        },
        plotOptions: {
            series: {
                dataLabels: {
                    enabled: true,
                    formatter: function(){
                        var tex = '';
                        if($.inArray(this.point,this.series.data) == 0){
                            tex = this.series.name;
                        }
                        return tex;
                    }
                }
            }
        },
    
        series: [{
            name: 'y=x^2',
            data: [
                [-3, 3],
                [-2, 2],
                [-1, 1],
                [0, 0],
                [1, 1],
                [2, 2],
                [3, 3]
                
            ]
        },{
            name: 'y=x^2+1',
            data: [
                [-3, 4],
                [-2, 3],
                [-1, 2],
                [0, 1],
                [1, 2],
                [2, 3],
                [3, 4]
                
            ]
        }]
    
    });
});