1
votes

I wish everybody is doing great.

I am really confuse with this "High Chart".

My data:

string '[{"name":"Line001","data":[1,2,3,4]}, 
{"name":"Line002","data":[1,2,3,4]}, 
{"name":"Line003","data":[1,2,3,4]}, 
{"name":"Line004","data":[1,2,3,4]}]'

xAxis = [2000,2001,2002,2003];

I can create the chart without problems, but I would like to create a High Stock, and then begins THE doubt.

How can I put these series and these values in a High Stock?

Remembering that I already have the JSON and I do not want to go on another page, since I already have it available for the High Chart.

I tried examples, but I'm really confused.

I will be very grateful for the help.

Below you can see the example I am using.

$(function () {
    var seriesOptions = [],
        seriesCounter = 0,
        names = ['MSFT', 'AAPL', 'GOOG'],
        // create the chart when all data is loaded
        createChart = function () {

            $('#container').highcharts('StockChart', {

                rangeSelector: {
                    selected: 4
                },

                yAxis: {
                    labels: {
                        formatter: function () {
                            return (this.value > 0 ? ' + ' : '') + this.value + '%';
                        }
                    },
                    plotLines: [{
                        value: 0,
                        width: 2,
                        color: 'silver'
                    }]
                },

                plotOptions: {
                    series: {
                        compare: 'percent'
                    }
                },

                tooltip: {
                    pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
                    valueDecimals: 2
                },

                series: seriesOptions
            });
        };

    $.each(names, function (i, name) {

        $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=' + name.toLowerCase() + '-c.json&callback=?',    function (data) {

            seriesOptions[i] = {
                name: name,
                data: data
            };

            // As we're loading the data asynchronously, we don't know what order it will arrive. So
            // we keep a counter and create the chart when all the data is loaded.
            seriesCounter += 1;

            if (seriesCounter === names.length) {
                createChart();
            }
        });
    });
});
2
Well, for me works fine: jsfiddle.net/nf7ne/56, could you point me how can I replciate your issue? Do you receive any errors in the console ?Sebastian Bochan

2 Answers

0
votes

Have you included the highstock.js file?
<script src="http://code.highcharts.com/stock/highstock.js"></script>

I often find it's easier to test and build examples from their JS Fiddle examples. For Example.

0
votes

I just need to bring the date from PHP with a JAVASCRIPT format.

After bringing int UTC format the chart is working.

Closed.