javascript - How to make plotline appear on line chart when data is same highcharts? -


im trying add plot line line chart. when data same e.g [7.0, 7.0, 7.0] plot line doesn't show. when data , down plot line shows e.g [7.0, 8.0, 7.0]. there way make plot line show when data same? jsfiddle

my high chart set is:

$(function () {     $('#container').highcharts({         title: {             text: 'monthly average temperature',             x: -20 //center         },         subtitle: {             text: 'source: worldclimate.com',             x: -20         },         xaxis: {             categories: ['jan', 'feb', 'mar', 'apr', 'may', 'jun',                 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']         },         yaxis: {             title: {                 text: 'temperature (°c)'             },             plotlines:[{                     value:10,                     color: '#ff0000',                     width:2,                     zindex:4,                     label:{text:'goal'}                 }]         },         tooltip: {             valuesuffix: '°c'         },         legend: {             layout: 'vertical',             align: 'right',             verticalalign: 'middle',             borderwidth: 0         },         series: [{             name: 'tokyo',             data: [7.0, 7.0, 7.0, 7.0]         }]     }); }); 

your problem connected how yaxis right now. when have same y value of data, yaxis has same min , max. example if have data: [7.0, 7.0, 7.0, 7.0], yaxis min , max equal 7.

if plotline has value:10, cannot see in chart. see plotline can manually set min , max of yaxis:

yaxis: {   min: 5,   max: 10,   title: {     text: 'temperature (°c)'   },   plotlines: [{     value: 10,     color: '#ff0000',     width: 2,     zindex: 4,     label: {       text: 'goal'     }   }] }, 

here can see example: http://jsfiddle.net/g34pk5tc/3/

to make possibility of changing extremes in yaxis, better idea add series invisible point, y value of point equal value of plotline. here can see example how can work:

function(chart) {     chart.addseries({       showinlegend: false,       enablemousetracking: false,       data: [10],       marker: {         enabled: false       }     })   } 

http://jsfiddle.net/g34pk5tc/4/


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -