| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Highstock Example</title>
- <style type="text/css">
- </style>
- </head>
- <body>
- <script src="../../code/highstock.js"></script>
- <script src="../../code/modules/exporting.js"></script>
- <script src="../../code/modules/export-data.js"></script>
- <div id="container" style="height: 400px; min-width: 310px"></div>
- <script type="text/javascript">
- var seriesOptions = [],
- seriesCounter = 0,
- names = ['MSFT', 'AAPL', 'GOOG'];
- /**
- * Create the chart when all data is loaded
- * @returns {undefined}
- */
- function createChart() {
- Highcharts.stockChart('container', {
- rangeSelector: {
- selected: 4
- },
- yAxis: {
- labels: {
- formatter: function () {
- return (this.value > 0 ? ' + ' : '') + this.value + '%';
- }
- },
- plotLines: [{
- value: 0,
- width: 2,
- color: 'silver'
- }]
- },
- plotOptions: {
- series: {
- compare: 'percent',
- showInNavigator: true
- }
- },
- tooltip: {
- pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
- valueDecimals: 2,
- split: true
- },
- series: seriesOptions
- });
- }
- function success(data) {
- var name = this.url.match(/(msft|aapl|goog)/)[0].toUpperCase();
- var i = names.indexOf(name);
- 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();
- }
- }
- Highcharts.getJSON(
- 'https://cdn.jsdelivr.net/gh/highcharts/highcharts@v7.0.0/samples/data/msft-c.json',
- success
- );
- Highcharts.getJSON(
- 'https://cdn.jsdelivr.net/gh/highcharts/highcharts@v7.0.0/samples/data/aapl-c.json',
- success
- );
- Highcharts.getJSON(
- 'https://cdn.jsdelivr.net/gh/highcharts/highcharts@v7.0.0/samples/data/goog-c.json',
- success
- );
- </script>
- </body>
- </html>
|