How to include custom data in a point data of arearange chart - highcharts

I am creating an arearange chart in Highcharts. Data to this chart is passed as an array of array like [[1,2,3],..]. Can i pass custom data in this point like [[1,2,3, "abc:12"],[5,6,7,"abc:14"]..].
If i want to pass custom data for each point, please let me know how to pass.

You can use keys property to map the values and for example use the custom value in a tooltip:
Highcharts.chart('container', {
series: [{
keys: ['x', 'low', 'high', 'customValue'],
type: 'arearange',
data: [
[1, 2, 3, "abc:12"],
[5, 6, 7, "abc:14"]
]
}],
tooltip: {
pointFormat: '{point.customValue}'
}
});
Live demo: http://jsfiddle.net/BlackLabel/ncmy1jt7/
API Reference: https://api.highcharts.com/highcharts/series.arearange.keys
Or define the series data as an array of objects:
series: [{
keys: ['x', 'low', 'high', 'customValue'],
type: 'arearange',
data: [{
x: 1,
low: 2,
high: 3,
customValue: "abc:12"
}, {
x: 5,
low: 6,
high: 7,
customValue: "abc:14"
}]
}]
Live demo: http://jsfiddle.net/BlackLabel/s035q8um/

Related

Set different pointPadding with highcharts

I would like to emphasise the difference between 2 different series in the same graphic : one coming from the user data and one from static data as following :
I wanted to define the pointPadding value, but this is available for all the series. How can I set this value only for a specific serie ?
The simplest solution seems to be adding a second x-axis and separate series. For example:
series: [{
...,
groupPadding: 0.325,
id: 'id1'
}, {
...,
groupPadding: 0.325,
id: 'id2'
}, {
...,
xAxis: 1,
linkedTo: 'id1'
}, {
...,
xAxis: 1,
linkedTo: 'id2'
}],
xAxis: [{
width: '20%',
type: 'category',
tickWidth: 1
}, {
offset: 0,
width: '80%',
left: '20%',
type: 'category',
tickWidth: 1
}]
Live demo: http://jsfiddle.net/BlackLabel/rwg6tL2v/
API Reference: https://api.highcharts.com/highcharts/xAxis

Highcharts Highmaps the data does not match with polygons correctly

I built a map with Highmaps: see fiddle
The data comes from this google sheet
see code:
data: {
googleAPIKey: 'AIzaSyB-ZvAYEcpvptgn77Mfld0iHwSRAVepo7I',
googleSpreadsheetKey: '105jszNGYP9P8g5mnmPY2wZgofnayy8TPZM2RBKYTf-c',
seriesMapping: [{
'land': 0,
'inzidenz': 1,
'value': 1,
'hc-key': 2,
'lat': 3,
'lon': 4
},{
'land': 0,
'inzidenz': 1,
'value': 1,
'hc-key': 2,
'lat': 3,
'lon': 4,
'z': 1
}],
complete: function(options) {
options.series[0].name = 'Inzidenz';
options.series[1].name = 'Labels';
}},
But the data is not displayed on the correct polygons, e.g. the value of Hessen in Bayern etc.
This problem is a Highmaps regression bug: https://github.com/highcharts/highcharts/issues/16782
As a workaround, you can add an empty point on init:
series: [{
type: 'map',
data: [{}],
...
}, ...]
Live demo: https://jsfiddle.net/BlackLabel/edpbjvm1/
Is there a reason you are using mapbubble instead of map as your series.type?
If you change it to map, it works.
https://jsfiddle.net/vf8o7cnd/1/

How to hide single point bar in serie

I need to hide the last point in a serie but have to keep the label. Seems is only possible to set a pointWidth but not a pointHeight. How can i force to display the label and hide the column bar for the last point?
series: [
{
type: 'column',
data: [1, 2, 1, 2, 3, { pointWidth: 0, y: 5 }]
}
]
Here's a demo of the current/expected behavior
Thanks
You could set the color of the last column to transparent:
series: [{
data: [3,5,7,4,{y:5,color: 'transparent'}]
}]
Example:
http://jsfiddle.net/jlbriggs/7o2hafuy/
With dataLabels Api Doc that's possible
series: [{
type: 'column',
dataLabels:{
enabled:true
},
data: [1, 2, 1, 2, 3, {
pointWidth: 0,
y: 5
}]
}]
Fiddle

Multiple histograms in highcharts causes an issue with bin spacing on the second histogram?

I'm trying to plot two series of data and their corresponding histograms on the same chart. Unfortunately the result is gaps between the bins of one of the histograms.
Has anyone any idea how to resolve this, bearing in mind that the data is dynamic so I don't want to explicitly set any bin widths etc.
http://jsfiddle.net/uwq9k7Lg/
JS:
Highcharts.chart('container', {
xAxis: [{
}, {
}, {
}],
yAxis: [{
}, {
}],
series: [{
type: 'histogram',
xAxis: 2,
yAxis: 1,
baseSeries: 's1'
}, {
type: 'histogram',
xAxis: 2,
yAxis: 1,
baseSeries: 's2'
}, {
id: 's1',
type: 'scatter',
data: [1540.05,1532.99,1880.28,1477.81,1585.73,1517.52,1986.31,1469.12,1314.68,1769.32,1438.85,1559.51,1712.68,1539.97,1253.89,1830.8,1496.05,1490.26,1671.14,2442.06,1553.05,1493.59,1563.03,1486.62,1802.82,1373.39,1754.35,1525.61,1546.15,1505.9,1457.14,1800.56,1481.7,1349.72,2125.55,1621.02,1689.52,1685.67,1778.98,1698.82,1921.13,1520.81,1566.14,2372.76,1419.91,1796.7,1621.19,1816.31,1528.85,1342.83,2481.26,1694.68,1657.92,1457.89,1414.73,1857.76,1715.27,1530.2,1553.69,2890.06,1632.14,1419.08,1449.88,1414.45,1600.4,1473.22,1745.77,2536.96,1625.38,1788.98,1502.14,1414.55,1491.99,1389.6,1606.47,1865.12,2281.73,1466.92,1485.69,1492.09,2272.98,1656.43,1562.23,2229.11,1732.37,1466.74,1428.72,1209.87,1459.51,1618.47,1720.35,1660.64,1479.19,1425.42,1549.53,1645.3,1602.82,1608.41,1749.81,1714.55,1679.14,1791.71,1490.59,1928.39,1586.32,1494.97,1550.52,2608.26,1512.23,1804.93,1799.76,2493.59,2105.95,1765.73,1176.89,1789.19,1257.6,1701.47,1445.61,2308.24,1644.9,1590.58,2272.31,1449.72,1802.39,1385.58,1402.27,1562.01,1593.6,1585.58,1351.67,1563.42,1689.95,1332.75,2055.39,1567.86,1918.89,1669.67,1521.49,1936.59,1646.44,1735.57,1512.26,1727.84,1398.51,1437.52,1395.86,1704.65,1691.25,2436.58,1474.62,1971.48,1453.26,1274.71,1908.51]
}, {
id: 's2',
xAxis: 1,
type: 'scatter',
data: [1796.39,1819.96,1644.75,1682.29,1664.81,2122.26,1442.42,1748.17,2099.26,1866.1,1466.9,2090.13,1502.34,1760.46,2279.47,1565.06,2104.19,1707.06,1827.82,1989.51,1899.41,1836.86,1633.83,2633.47,1860.75,2582.93,1500.57,2213.11,1417.45,1671.14,2305.97,3002.58,1802.91,1978.37,1914.84,1688.79,1967.32,1622.43,1705.98,1911.45,2040.99,2404.06,1788.33,1540.64,1900.35,1822.32,1995.54,2837.06,1840.97]
}]
});
Thank you!
Just change the xAxis and set borderWith:0
...
xAxis: [{}, {}, {}, {}], // new xAxis
...
{
type: 'histogram',
xAxis: 3, // Use the new added xAxis
yAxis: 1,
baseSeries: 's2',
borderWidth: 0 // Remove the line around the bins
}
Fiddle

Highcharts addaxis measure dynamically

I want to add yAxis dynamically.
chart.addAxis({
id: serie.options.id,
title: {
text: serie.name
},
lineWidth: 2,
lineColor: serie.color,
opposite: false,
});
the code above, adds only line. I need to add measure too. How can i add specific measure for a serie?
For new axis to show measure (AKA scale and labels) you need to set this axis as an yAxis for a series or link this new axis to an existing one, that is showing labels.
$(function() {
$('#container').highcharts({
series: [{
data: [1, 2, 3, 4, 5, 6, 7]
}]
}, function(chart) {
chart.addAxis({
id: 'serie.options.id',
title: {
text: 'serie.name'
},
lineWidth: 2,
//lineColor: serie.color,
opposite: false,
//linkedTo: 0
});
chart.addSeries({
data: [42,2,4,0],
yAxis: 1
});
});
});
Example with:
linkedTo: http://jsfiddle.net/u90dLbc6/1/
assigned series: http://jsfiddle.net/u90dLbc6/0/

Resources