Simply put I am looking for a way to set two or more plotLines in highcharts/highstocks. The API doccuments do a good job of showing how to set one although I am not sure if there is a way to set two of them.
Yes it is possible, just declare multiple plotLine configurations in the array:
plotLines: [{
color: '#FF0000',
width: 2,
value: 4.5
}, {
color: '#00FF00',
width: 2,
value: 5.5
}]
Example on jsfiddle
Is there a method where i can supply an array of points to value ? Instead of new tags
{
color: '#00FF00',
width: 2,
value: 5.5
}
for each point .
Related
I have 2 plotlines in highchart. When I select (for zoom & reset) some range before and after the plotline area some cases having plotlines even it's not in the selected range. So decided to remove the plotlines after validating the selected range and plotline dates . When I tried to set it back after the reset button click . It's not working.
Removing:
selection(event) {
if((fDate < mCurrentDate && tDate < mCurrentDate)||(fDate > mCurrentDate && tDate > mCurrentDate)){
this.xAxis[0].removePlotLine('mCurrentDate');
}
if((pDate < mCurrentDate && pDate < mCurrentDate)||(pDate > mCurrentDate && pDate > mCurrentDate)){
this.xAxis[0].removePlotLine('mSaleDate');
}
}
When the reset Button is clicked I want to set the plotlines again .
render() {
id:'mCurrentDate',
value: currentDate.getTime(),
color: 'pink',
width: 4,
zIndex: 3},
{
id:'mSaleDate',
value: SaleStartedDate,
color: 'Green',
width: 4,
zIndex: 6})
So the thing is when we do a zoom I need to remove the plotlines if the plotline dates are not in the selected range and when user clicks on the reset zoom button I want to set the plotlines back.
can anyone help me to fix it.
Use update option to recreate the plot line
Here i use the merge of lodash to merge current option and add your plotlines:
merge(options, {
xAxis: {
plotLines: [
{
id:'mCurrentDate',
value: currentDate.getTime(),
color: 'pink',
width: 4,
zIndex: 3
},{
id:'mSaleDate',
value: SaleStartedDate,
color: 'Green',
width: 4,
zIndex: 6
}
]
}
});
this.chart.update(options, true);
Update : you don't absolutely need to get all your opions when you call update. You just need to pass an object with the changed options
I'm trying to graphic some values, I have this part, then I want to add some max and min line, I could do this creating another series and adding the min/max value that I want, the problem here is that my value series is an array of n elements so I want to know if I could create the min/max series for example just doing data: [2] and put the line in all the width of my chart. Something like this:
If there is no way to do this, just if is possible doing: data[2, 2, 2,.... n] is possible to show only the first and the last point and hide the rest of them?
Here is my working code
You can use plotLines for this.
Example:
yAxis: {
softMax: max,
min: 0,
plotLines: [{
value: min,
width: 1,
color: 'rgba(204,0,0,0.75)'
},{
value: max,
width: 1,
color: 'rgba(204,0,0,0.75)'
}]
}
Updated pen:
http://codepen.io/jlbriggs/pen/LbJQEV
Alternatively, if you really want it to be a series, you can grab the min and max x values, and provide your data as arrays of [x,y] pairs. Something like:
series: [{
name: 'Actual Series'
...
},{
name: 'Max',
data: [[xMin,yMax],[xMax,yMax]]
},{
name: 'Min',
data: [[xMin,yMin],[xMax,yMin]]
}]
I've a pie chart with drilldown data and like to change the chart.options.colors. Is there a way to replace the whole color array in chart.options.colors on drilldown, and restore the old color array to chart.options.colors on drillup?
Tried to change the array in chart.options.colors and to call redraw(), but it does not work correctly.
Thank you
Torben
You can do this in a quite old fashioned way by giving the color to every point you wish to have.
in data section:
data: [24,28,{
y: 40,
color: 'red'
}, 10, 30, 40
]
here I've worked out a example : http://jsfiddle.net/tbjuq/
I hope this will help you to achieve what you are looking for.
You can replace every element of the series array
{
name: 'sampleName',
id: 'sampleId',
data: [
['subElement1', value1],
['subElement2', value2]
]
}
with
{
name: 'sampleName',
id: 'sampleId',
data: [{
name: 'subElement1',
y: value1,
color: '#123456'
},
{
name: 'subElement2',
y: value2,
color: '#123456'
}
]}
I am trying to show more labels on yAxis, but I couldn't get it to work. My yAxis properties are as follows:
yAxis : {
title : {
text : '%CPU Utilization'
},
labels: {
enabled: true,
step: 5,
zIndex: 10
},
showLastLabel: true,
min:0,
max: 100,
plotLines : [{
value : 70,
color : '#FF3300',
dashStyle : 'shortdash',
width : 2,
label : {
text : 'Threshold',
align: 'right',
style: {
fontWeight: 'bold'
}
}
}]
},
I followed the documentation but does not seem to be working. I need a label at 0, 10, 20, 30, 40 (in 10 increments). Any idea whether this is doable in highcharts?
what you want to look at is the tickInterval property:
http://api.highcharts.com/highcharts#yAxis.tickInterval
If you need irregular intervals, you can instead use the tickPositions property:
http://api.highcharts.com/highcharts#yAxis.tickPositions
Or, if you need something even more complex, the tickPositioner function:
http://api.highcharts.com/highcharts#yAxis.tickPositioner
{{Edit:
remove the step property from your labels though - the step property tells the chart how many labels to skip when it draws them, not where to draw them.
I'm trying to add a plotLine to my chart, but always get this error:
(intermediate value).concat is not a function
I've prepared a jsfiddle: (intermediate value).concat is not a function
Any suggestions, what I'm doing wrong here?
Please take look at examples: http://jsfiddle.net/ge3fg/ http://jsfiddle.net/47zgw/
plotLines: [{
color: '#FF0000',
width: 2,
value: 5.5
}]