javascript - How can I add both plotLines and plotBands to a HighStocks graph using HighChart? -
i've been trying add plotlines graph , i've followed syntax online; however, plotline not appear.
the plotbands appear fine, trying see may missing work.
below link jsfiddle: https://jsfiddle.net/fbmoju7f/75/
$.getjson('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) { highcharts.stockchart('container', { title: { text: 'morphine' }, xaxis: { type: 'datetime', floor: date.utc(2017, 2, 2), ceiling: date.utc(2017, 2, 9), plotline: { value: date.utc(2017, 2, 8), color: '#3a1231', //purple width: 2, dashstyle: 'solid' } }, yaxis: { //keep yaxis ---------------------------------------- floor: 0, ceiling: 100, plotbands: [{ color: '#f9f98e', //yellow from: 0, to: 10 }, { color: '#9df98e', //green from: 10, to: 30 }, { color: '#f9958e', //red from: 30, to: 100 }] }, rangeselector: { buttons: [{ type: 'day', count: 8, text: '-7d' }, { type: 'day', count: 4, text: '-3d' }, { type: 'day', count: 3, text: '-2d' }, { type: 'day', count: 2, text: '-1d' }], selected: 2 //initial view upon opening application }, series: [{ type: 'spline', color: '#4c91fa', data: [ //test data set [date.utc(2017, 2, 1), 5.7], [date.utc(2017, 2, 2), 7.3], [date.utc(2017, 2, 3), 10.3], [date.utc(2017, 2, 3), 15.6], [date.utc(2017, 2, 4), 12.7], [date.utc(2017, 2, 4), 14.0], [date.utc(2017, 2, 4), 17.8], [date.utc(2017, 2, 5), 19.1], [date.utc(2017, 2, 5), 18.4], [date.utc(2017, 2, 6), 19.5], [date.utc(2017, 2, 6), 22.7], [date.utc(2017, 2, 6), 25.1], [date.utc(2017, 2, 7), 28.2], [date.utc(2017, 2, 7), 30.4], [date.utc(2017, 2, 8), 29.6], [date.utc(2017, 2, 9), 29.0], [date.utc(2017, 2, 10), 27.8] ] }] }); }); <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script src="https://code.highcharts.com/stock/highstock.js"></script> <script src="https://code.highcharts.com/modules/stock/exporting.js"></script> <div id="container" style="height: 400px; min-width: 310px"></div>
you have wrong property name , not enclosing plotlines in brackets. should like:
xaxis: { type: 'datetime', floor: date.utc(2017, 2, 2), ceiling: date.utc(2017, 2, 9), plotlines: [{ value: date.utc(2017, 2, 8), color: '#3a1231', //purple width: 2, dashstyle: 'solid' }] },
Comments
Post a Comment