Adding images to tooltips in Highmaps - highcharts

How can I a display an image (small icon) in a tooltip within Highmaps?
I know this question has been asked before - here - but damned if I can get it to work. I even wonder if it is possible, because as far as I can see in their API docs, the Highmaps support for HTML is limited, as eg here and does not include the img tag.
I have create a jsfiddle here with some sample icons. I'd be grateful if someone could demo how to add these to the tooltips (one per tooltip, of course)
$('#container').highcharts('Map', {
title: {
"text": "Simple Map"
},
series: [
{
"name": "Colours",
"type": "map",
"tooltip": {
"headerFormat": "",
"pointFormat": "{point.name}"
},
"data": [
{
"name": "Blue<br>violets",
"path": "M0,-994L204,-994L203,-480,0,-477z"
},
{
"name": "Yellow<br>is the colour of...",
"path": "M204,-994L455,-994L457,-477,203,-480z"
},
{
"name": "Red<br>sky at night",
"path": "M455,-994,697,-991,700,-481,457,-477z"
},
{
"name": "Green<br>grass",
"path": "M697,-991,998,-992,1000,-480,700,-481z"
}
]
}
]
});

You need to enable the useHTML parameter and link a displayed picture with a point, for example:
series: [{
...,
"data": [{
...,
tooltipImg: 'left'
},
{
...,
tooltipImg: 'right'
},
...
]
}],
tooltip: {
useHTML: true,
formatter: function() {
return this.point.name +
'<br><img src="http://icons.iconarchive.com/icons/saki/nuoveXT/128/Small-arrow-' +
this.point.tooltipImg + '-icon.png" width="32" height="32">'
}
}
Live demo: https://jsfiddle.net/BlackLabel/9bujq56y/
API Reference: https://api.highcharts.com/highmaps/tooltip.useHTML

Related

Highcharts line chart - incorrect point ordering - boost module

Issue
We are currently implementing a highcharts graph for large datasets that will require the boost module for performance reasons. However, on enabling the boost module we have encountered an intermittent issue that is proving challenging to consistently reproduce and isolate.
Because I am not able to replicate this I cannot create a jsfiddle as of yet. Does anyone have any idea how to isolate and fix this?
The graph should look like this:
Expected graph
But occasionally does this:
Actual graph
This has also happened on another occasion whilst manually testing with different data:
With different data
It has been observed on
Chrome 70.0.3538.67
IE 11.345.17134.0
Highcharts JS & Boost module v6.1.4
Input data
Sample of the type of data:
{
"label": "2018-04-19T15:17:02",
"value": "1"
}, {
"label": "2018-04-19T15:17:05",
"value": "9620035.36877074"
}, {
"label": "2018-04-19T15:17:59",
"value": "9583104.14689662"
}, {
"label": "2018-04-19T15:18:46",
"value": "9604094.84064805"
}, {
"label": "2018-04-19T15:20:17",
"value": "9571679.9536289"
}, {
"label": "2018-04-20T08:18:24",
"value": "7902991.39771514"
}
Or:
{
"label": "2018-04-19T15:17:59",
"value": "1.4132e-007"
}, {
"label": "2018-04-19T15:18:46",
"value": "1.41434e-007"
}, {
"label": "2018-04-19T15:20:17",
"value": "1.41355e-007"
}, {
"label": "2018-04-20T08:18:24",
"value": "1.40532e-007"
}, {
"label": "2018-04-20T08:20:35",
"value": "1.40928e-007"
}, {
"label": "2018-04-20T08:23:51",
"value": "1.4078e-007"
}, {
"label": "2018-04-20T08:24:39",
"value": "1.40901e-007"
}
Graph config
{
"chart": {
"type": "line",
"zoomType": "x",
"panning": true,
"panKey": "shift"
},
"boost": {
"usePreallocated": false
},
...
y-axis label customisation
title
exporting
etc
...
"series": [{
"showInLegend": false,
"name": "",
"data": []
}],
}
Update mechanism
When the HTTP response comes back the following is called on the graph instance:
graphToUpdate.series[0].setData(parsedData, true, true, false);

Highcharts - column chart has space between bar and xAxis

How can I prevent this space:
I try a lot but no success.
Here is my options:
$('#container').highcharts({
"chart": {
"type": "column"
},
"xAxis": {
"categories": ["1/1/2018", "2/1/2018", "3/1/2018"]
},
"legend": {
"enabled": false
},
"yAxis": {
"categories": []
},
"series": [{
"data": [1, 3, 1]
}]
});
JSFiddle link
Thanks in advance.
Remove the empty category definition on the yAxis to make highchart automatically generate values for the yAxis:
$('#container').highcharts({
"chart": {
"type": "column"
},
"xAxis": {
"categories": ["1/1/2018", "2/1/2018", "3/1/2018"]
},
"legend": {
"enabled": false
},
"yAxis": {
},
"series": [{
"data": [1, 3, 1]
}]
});
JSFiddle working example: http://jsfiddle.net/ewolden/sq1hf68r/

Highcharts context menu hidden behind series

The context menu is hidden behind the series when the bar chart series spans across the entire chart. How can I get the menu to not be hidden behind the series?
http://jsfiddle.net/kadams/uy05zby3/2/
$('#container').highcharts({
"chart": {
"type": "bar",
"zoomType": "x"
},
"title": {
"text": ""
},
"xAxis": {
"title": {
"text": ""
},
"categories": [
"A",
"B",
"C"
]
},
"plotOptions": {
"series": {
"stacking": "percent",
"pointPadding": 0.2,
"borderWidth": 0,
"animation": false
}
},
"series": [
{
"name": "Bacon",
"data": [
36.4,
18.9,
17.5
]
},
{
"name": "Pork Chops",
"data": [
105,
93.7,
108.8
]
},
{
"name": "Ham",
"data": [
32.7,
30.7,
34.2
]
}
]
});
I see two solutions for your case:
display button in front of the series: http://jsfiddle.net/uy05zby3/7/
events: {
load: function() {
if(!this.options.chart.forExport) {
this.exportSVGElements[0].toFront();
}
}
}
make space for the button: http://jsfiddle.net/uy05zby3/5/
"chart": {
"type": "bar",
"zoomType": "x",
"marginTop": 30 // make more space on top edge
},
This is happening because of the height value set in the div,
try the following
#container {
min-width: 300px;
max-width: 800px;
min-height: 350px;
margin: 1em auto;
}
fiddle link :)
It provides margin so that no overlay of menu happpens
hope this us helpful

Highcharts - Highstocks. Show all x-axis labels

I have highstocks set up to display two series of data.
When I zoom all the way the x-axis label for one of the series is always missing.
jsfiddle link
$(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var chart = new Highcharts.StockChart({
chart: {
"renderTo": "container"
},
plotOptions: {
"column": {
"stacking": "normal"
}
},
series: [{
"type": "column",
"name": "column 1",
"color": "#1d8ecd",
"data": [
[1296511200000, 974],
[1301605200000, 1618],
[1306875600000, 990],
[1312146000000, 1720],
[1317416400000, 516],
[1322690400000, 1472],
[1328047200000, 349],
[1333227600000, 1781],
[1338498000000, 649],
[1343768400000, 1124],
[1349038800000, 829],
[1354312800000, 1615],
[1359669600000, 1181]
]
}, {
"type": "column",
"name": "column 2",
"color": "#636466",
"data": [
[1293832800000, 1913],
[1298930400000, 1269],
[1304197200000, 567],
[1309467600000, 668],
[1314824400000, 722],
[1320098400000, 442],
[1325368800000, 1558],
[1330552800000, 1831],
[1335819600000, 373],
[1341090000000, 275],
[1346446800000, 1540],
[1351720800000, 998]
]
}],
});
});
Any ideas why is this happening and if I can force it to display all x-axis labels, at least when there is space for it?

Highchart Stacked Column w/ Datetime X-axis Columns Too Thin

I am trying to display to my users the number of videos recorded per day with each one of their cameras. To do so I would like to use a stacked back (each stack showing the # of videos recorded with a given camera). Here are the options I am passing in:
var options = {
"title": {
"text": null
},
"legend": {
"layout": "vertical",
"style": { },
"enabled": false
},
"xAxis": {
"type": "datetime",
"minTickInterval": 86400000
},
"yAxis": {
"stackLabels": { "enabled": true },
"title": { "text": null }
},
"tooltip": { "enabled": true },
"credits": { "enabled": false },
"plotOptions": {
"column": { "stacking": "normal" }
},
"chart": {
"defaultSeriesType": "column",
"height": 200,
"borderRadius": 0,
"renderTo": "monthy_chart"
},
"subtitle": { },
"colors": [ "#c7084b","#089fbf","#00d047","#d300d1","#f48400","#f6f400" ],
"series": [
{
"name": "Camera",
"data": [ [ 1362614400000,6 ],[ 1362528000000,2 ] ]
},
{
"name": "NewCamera2",
"data": [ [ 1362614400000,1 ] ]
}
]
};
The graph displays the data correctly but is rendering the columns extremely narrowly even when there are only 2 days of data (image below). Is there a way for me to deine the scale of the x-axis so the widths of the columns will display a bit better?
http://i.stack.imgur.com/NSSYg.png
You can set pointWidth and startOnTick / endOfTick
http://jsfiddle.net/bLrah/
"xAxis": {
startOnTick:true,
endOnTick:true,
"type": "datetime",
"minTickInterval": 86400000
http://api.highcharts.com/highcharts#xAxis.startOnTick
http://api.highcharts.com/highcharts#xAxis.endOnTick
http://api.highcharts.com/highcharts#plotOptions.column.pointWidth

Resources