How to add image to High-chart? - highcharts

I have plot in high-chart with 1000 polygon series but i cannot show all legends. So i just want to keep four legend(after grouping multiple polygon series) and want to write their legends.
1. case 1. Red color box
2. case 2. Blue color box
3. case 3. Green color box
4. case 4. white color box
But how can i put that legend in highchart as high chart only generate legend based on series data. Or can i add static image already generated seperately in highchart multi-polygon series (showinlegend: flase) so that it should appear as legend in polygon series?

As per your requirement , if you just want to show four non-clickable legend like indicators you can use renderer like below :
function(chart) {
chart.renderer.rect(80, 75, 10, 10).attr({
fill: '#C5FFC5',
}).add(); chart.renderer.text("Series 1" ,100, 85).add();
chart.renderer.rect(80, 95, 10, 10).attr({
fill: 'red'
}).add();
chart.renderer.text("Series 2" ,100, 105).add();
chart.renderer.rect(80, 115, 10, 10).attr({
fill: 'green'
}).add();
chart.renderer.text("Series 3" ,100, 125).add();
}
Edit in your code ,place this code like below:
$.getJSON('data10.json', function(data) {
options.series=data;
options.chart.zoomType='x';
chart = new Highcharts.Chart(options);
chart.renderer.rect(80, 75, 10, 10).attr({
fill: '#C5FFC5',
stroke: 'black',
'stroke-width': 1
}).add();
chart.renderer.text("Series 1", 100, 85).add();
chart.renderer.rect(80, 95, 10, 10).attr({
fill: 'red',
stroke: 'black',
'stroke-width': 1
}).add();
chart.renderer.text("Series 2", 100, 105).add();
chart.renderer.rect(80, 115, 10, 10).attr({
fill: 'green',
stroke: 'black',
'stroke-width': 1
}).add();
chart.renderer.text("Series 3", 100, 125).add();
});
See the working fiddle here

Related

Highcharts small columns inside area

I would like to add columns inside the area of chart red for negative and green for positive like attaching screenshot.
https://prnt.sc/psk7ge
You need to create a chart with area and column series. The set the colors, use negativeColor and color options:
series: [{
type: 'area',
data: [10, 20, 10, 20, 10],
threshold: -20
}, {
type: 'column',
data: [-10, 10, -15, 10, 15],
color: 'green',
negativeColor: 'red'
}]
Live demo: http://jsfiddle.net/BlackLabel/owh16dzL/
API Reference: https://api.highcharts.com/highcharts/series.column.negativeColor

Customize halo of a scatter chart so that the center is intransparently colored

This is what I mean by halo:
http://api.highcharts.com/highcharts/plotOptions.area.states.hover.halo
It seems that "fill", "fillColor" and "color" in or not in "attributes" does not do the job.
As you can see from this jsfiddle: jsfiddle.net/s7ff806c/1 The halos are hallow circles which one can see through. I would like the circle to be solid (i.e not be able to be see through).
I think intransparently colored means full opaque see here how to achieve
in each series give color: 'rgba(223, 83, 83, 1.0)', 1.0 means full opaque, in rgba format
series: [{
name: 'Female',
color: 'rgba(223, 83, 83, 1.0)',
data: [
[161.2, 51.6],....]
}, {
name: 'Male',
color: 'rgba(119, 152, 191, 1.0)',
data: [
[174.0, 65.6],...]}
]
Fiddle link with Customize halo
Update
halo opacity can be adjusted see Opacity from highcharts docs
Fiddle Demo with Opacity adjusted to full
plotOptions: {
series: {
states: {
hover: {
halo: {
size: 9,
opacity:1,
attributes: {
fill: Highcharts.getOptions().colors[2],
'stroke-width': 2,
stroke: Highcharts.getOptions().colors[1]
}
}
}
}
}
},
Update ->set the opacity of stroke independently of the opacity of the fill
give 'stroke-opacity': .5, inside attribute
Fiddle link
plotOptions: {
series: {
states: {
hover: {
halo: {
size: 9,
opacity: 1,
attributes: {
fill: Highcharts.getOptions().colors[2],
'stroke-width': 5,
'stroke-opacity': .5,
stroke: Highcharts.getOptions().colors[1]
}
}
}
}
}
},

Highcharts. How to set interval for PlotBand?

I have multiseries spline chart. All series has own plotBand.
Is it possible to limit the plotBand interval by the length of the series?
Example, edited image:
plotLines can't help too:
plotLines: [{
value: 12345,
width: 10
}]
plotBands: [{
from: 30,
to: 45
}],
http://jsfiddle.net/r00tGER/1nuw4fqs/
This is not possible, but you can use Renderer.rect to add custom shape
chart.renderer.rect(100, 100, 100, 100, 5)
.attr({
'stroke-width': 2,
stroke: 'red',
fill: 'yellow',
zIndex: 3
})
.add();
Second solution is using annotation which allows to add rectangles.
Add one more range-type series as plot for every series.
series: [
{
name: 'as Plot',
type: 'areasplinerange',
data: [
[1434620400000, 58.0, 68.0], [1434620640000, 58.0, 68.0]
],
zIndex: 0
}
]
});
http://jsfiddle.net/r00tGER/ueqht2eL/

issue on Adding Multi Text To Chart in Highcharts

can you please take a look at this example and let me know why I am not able to add multi text to a the chart in one function?
I used this function
function(chart) {
chart.renderer.text('Papa 1', 90, 60)
chart.renderer.text('Papa 2', 140, 90)
.attr({
rotation: -0
})
.css({
color: '#B8B6B6',
fontSize: '12px'
})
.add();
});
but it is adding just the last text to the chart. Can you please let me know why this is happening and how I can have both (or more than two text) to the chart?
You forgot to add the first one. Change the first text to : chart.renderer.text('Papa 1', 90, 60).add();
function(chart) {
chart.renderer.text('Papa 1', 90, 60).add();
chart.renderer.text('Papa 2', 140, 90)
.attr({
rotation: -0
})
.css({
color: '#B8B6B6',
fontSize: '12px'
})
.add();
});

Can highcharts crosshairs show on top of area chart fill?

Can the cross-hairs for Highcharts show on top of the area chart instead of being hidden beneath it?
Here's an example of the problem jsfiddle.net/hHjZb/1286/
Update:
Highcharts has now implemented the OP's feature request. You can now specify the zIndex in the tooltip property. Like:
tooltip: {
crosshairs: [ {
width: 1,
color: 'lime',
zIndex: 22
}, {
width: 1,
color: 'lime',
zIndex: 22
} ]
},
At the time of this question, Highcharts did not give us a way to do that. Not even CSS styles can change the plot order (visibility).
Consider making a feature request. (Update: the FR was made and implemented.)
Meanwhile, you can tweak the Highcharts source (in that example, it is highcharts.com/js/testing.js).
Find this line in the source file:
attribs = {
'stroke-width': crosshairsOptions[i].width || 1,
stroke: crosshairsOptions[i].color || '#C0C0C0',
zIndex: 2
};
and change the zIndex to 20.
Then find this line in the source file:
var group = renderer.g('tooltip')
.attr({ zIndex: 8 })
.add(),
and change the zIndex to 22.
There is a zIndex attribute for crosshairs:
tooltip: {
crosshairs: [{
width: 3,
color: 'green',
zIndex: 50
}, {
width: 3,
color: 'green',
zIndex: 50
}]
},
http://jsfiddle.net/hHjZb/3711/

Resources