Highcharts - problem when dividing series - highcharts

I'm using highcharts and have to divide a series, so the mouse over event focus on the correct data. But, when I divide the data, the space between horizontal series changes.
Highcharts one serie - before divide the data
Highcharts multiple series - after divide the data
I also have the two playgrounds on JSFiddle:
https://jsfiddle.net/6g09hjyk/
Highcharts.chart('container', {
chart: {
backgroundColor: 'transparent'
},
credits: false,
navigation: {
buttonOptions: {
theme: {
fill: 'white',
padding: 5,
stroke: 'none'
}
}
},
title: {
text: null
},
subtitle: {
},
xAxis: [{
visible: true,
offset: 0.1,
},
{
visible: false
}],
plotOptions: {
series: {
pointWidth: -5
}
},
yAxis: [{
visible: true,
reversed: true,
gridLineWidth: 0,
title: {
text: 'MD (m)',
style: {
fontSize: '10px'
}
},
min: 2000,
max: 6500
},
{
opposite: true,
gridLineWidth: 0,
title: {
text: null,
}
}
],
legend: {
enabled: false
},
series: [
{
showInLegend: false,
pointPlacement: 0,
animation: {
duration: 2000
},
pointWidth: 4,
type: 'columnrange',
inverted: false,
name: 'Revestimento',
color: 'grey',
dataLabels: {
enabled: true,
useHTML: true,
crop: false,
x: 0
},
data: [
[2001, 2057, 3455],
[2002, 2059, 5499],
[2003, 2055, 5838],
[2004, 2058, 6028],
[2007, 2058, 6028],
[2008, 2055, 5838],
[2009, 2059, 5499],
[2010, 2057, 3455]
]
}
]
});
https://jsfiddle.net/6g09hjyk/1/
Highcharts.chart('container', {
chart: {
backgroundColor: 'transparent'
},
credits: false,
navigation: {
buttonOptions: {
theme: {
fill: 'white',
padding: 5,
stroke: 'none'
}
}
},
title: {
text: null
},
subtitle: {
},
xAxis: [{
visible: true,
offset: 0.1,
},
{
visible: false
}],
plotOptions: {
series: {
pointWidth: -5
}
},
yAxis: [{
visible: true,
reversed: true,
gridLineWidth: 0,
title: {
text: 'MD (m)',
style: {
fontSize: '10px'
}
},
min: 2000,
max: 6500
},
{
opposite: true,
gridLineWidth: 0,
title: {
text: null,
}
}
],
legend: {
enabled: false
},
series: [
{
showInLegend: false,
pointPlacement: 0,
animation: {
duration: 2000
},
pointWidth: 4,
type: 'columnrange',
inverted: false,
name: 'Revestimento',
color: 'grey',
dataLabels: {
enabled: true,
useHTML: true,
crop: false,
x: 0
},
data: [
[2001, 2057, 3455],
[2010, 2057, 3455]
]
},
{
showInLegend: false,
pointPlacement: 0,
animation: {
duration: 2000
},
pointWidth: 4,
type: 'columnrange',
inverted: false,
name: 'Revestimento',
color: 'grey',
dataLabels: {
enabled: true,
useHTML: true,
crop: false,
x: 0
},
data: [
[2002, 2059, 5499],
[2009, 2059, 5499]]
},
{
showInLegend: false,
pointPlacement: 0,
animation: {
duration: 2000
},
pointWidth: 4,
type: 'columnrange',
inverted: false,
name: 'Revestimento',
color: 'grey',
dataLabels: {
enabled: true,
useHTML: true,
crop: false,
x: 0
},
data: [
[2003, 2055, 5838],
[2008, 2055, 5838],
]
},
{
showInLegend: false,
pointPlacement: 0,
animation: {
duration: 2000
},
pointWidth: 4,
type: 'columnrange',
inverted: false,
name: 'Revestimento',
color: 'grey',
dataLabels: {
enabled: true,
useHTML: true,
crop: false,
x: 0
},
data: [
[2004, 2058, 6028],
[2007, 2058, 6028],
]
}
]
});
Can anyone help me?

You need to disable the grouping feature:
plotOptions: {
series: {
...,
grouping: false
}
}
Live demo: https://jsfiddle.net/BlackLabel/rta5xs81/
API Reference: https://api.highcharts.com/highcharts/plotOptions.columnrange.grouping

Related

Highcharts. Indentation and formatting issues

I want to make the graph start at 0 (as shown in the picture) and have the string formatted according to the regular expression replace(/\B(?=(\d{3})+(?!\d))/g, " ") but all my attempts are unsuccessful.
chartOptions: {
colors: ['#3DC3FB', '#FF5252', '#D2F449', '#179877'],
title: {
text: "",
},
credits: {
enabled: false
},
tooltip: {
formatter: function () {
if (this.x > 0) {
return this.x;
} else return false;
},
},
plotOptions: {
series: {
enableMouseTracking: false,
states: {
hover: {
enabled: false
},
normal: {
animation: false
},
select: {
enabled: false
}
}
},
},
xAxis: {
gridLineWidth: 1,
tickmarkPlacement: 'on',
lineColor: "#A4A4A4",
min: 0,
categories: [null, "10 лет"],
top: 10,
right: -100,
title: {
style: {
color: "#A4A4A4"
}
},
},
yAxis: {
gridLineWidth: 0,
tickColor: 'undefined',
tickLength: 5,
tickWidth: 1,
tickPosition: 'outside',
lineWidth: 1,
lineColor: '#A4A4A4',
min: 3,
title: {
text: "Доход от инвестиций",
margin: 10,
align: "low",
style: {
color: "#A4A4A4"
},
y: -50,
},
labels: {
enabled: false,
},
},
legend: {enabled: false},
marker: {
enabled: false,
symbol: 'circle',
radius: 12,
states: {
hover: {
fillColor: 'white',
lineColor: 'green',
lineWidth: 0
}
}
},
series: [
{
type: 'line',
name: "ВДело",
data: [0, 1100],
dataLabels: {
x: -100,
y: 5,
enabled: true,
// useHTML: true,
format: `{point.y}/мес`,
formatter: function () {
return Highcharts.numberFormat(this.y,2);
},
color: "#3DC3FB",
style:{
fontSize: 20,
lineHeight: 18,
fontWeight: 500,
fontFamily: 'Gilroy',
fontStyle: 'normal',
}
},
animation: {
defer: 1
},
marker: {
symbol: 'circle',
radius: 4,
states: {
hover: {
fillColor: '#3DC3FB',
lineColor: 'green',
lineWidth: 0
}
}
},
},
{
type: 'line',
name: "Акции",
data: [0, 550],
animation: {
defer: 1
},
marker: {
symbol: 'circle',
radius: 4,
states: {
hover: {
fillColor: '#FF5252',
lineColor: 'green',
lineWidth: 0
}
}
},
},
{
type: 'line',
name: "Облигации",
data: [0, 366],
animation: {
defer: 1
},
marker: {
symbol: 'circle',
radius: 4,
states: {
hover: {
fillColor: '#D2F449',
lineColor: 'green',
lineWidth: 0
}
}
},
},
{
type: 'line',
name: "Депозит",
data: [0, 275],
animation: {
defer: 1
},
marker: {
symbol: 'circle',
radius: 4,
states: {
hover: {
fillColor: '#179877',
lineColor: 'green',
lineWidth: 0
}
}
},
},
],
},
I am new to highcharts and have a hard time with huge documentation. help me please
Understood the cost of his sleep. For those who will be interested. So that the graph starts like in the picture.
plotOptions: {
series: {
findNearestPointBy: 'x',
label: {
connectorAllowed: false
},
pointPlacement: 'on'
}
}
and
{
type: 'line',
name: "ВДело",
data: [0, 1100],
dataLabels: {
x: -50,
y: -10,
enabled: true,
format: `{point.y}/мес`,
pointFormat: ' <b>{point.y:,.0f}/мес</b>',
shared: true,
color: "#3DC3FB",
style:{
fontSize: 20,
lineHeight: 18,
fontWeight: 500,
fontFamily: 'Gilroy',
fontStyle: 'normal',
}
},
When it comes to the place to start the chart in the category axis, you need to only change xAxis.min to 0.5
Sample code:
xAxis: {
min: 0.5,
tickmarkPlacement: 'on',
type: 'category'
},
Simplified demo:
https://jsfiddle.net/BlackLabel/jt1gqrnb/

Highcharts - How do I keep both line points in from splitting between the two bar charts

How do I keep both line points/markers in from splitting between the two bar charts but yet still have the ability to span both when values exceed initial bar value.
In the following example you will note that there are two line series that have the same values and thus I'm wanting the points/markers positioned one above the other but they are being split between the two stacked bars.
If you comment out the first bar series and plot options (see comments in code) you will see what I looking achieve but want the stacked bars rendered as well as have the second data value shown to the left.
My fiddle: https://jsfiddle.net/gbp5qvzh/58
var mychart = Highcharts.chart(
'container', {
chart: {
type: 'bar',
height: '400px'
},
title: {
text: null
},
xAxis: {
lineWidth: 0,
tickLength: 0,
opposite: false,
labels: {
enabled: false
}
},
yAxis: {
opposite: true,
gridLineWidth: 0,
title: {
enabled: false
},
labels: {
enabled: false
},
stackLabels: {
enabled: false,
formatter: function () {
return '<div class="barLabel">' + this.axis.chart.xAxis[0].categories[this.x] + '</div>';
},
useHTML: true,
verticalAlign: 'top',
align: 'left',
style: {
fontSize: '16px',
fontFamily: 'proxima-nova'
}
}
},
tooltip: {
enabled: false
},
legend: {
itemStyle: {
color: '#000000',
fontWeight: 'bold',
fontSize: '18px',
fontFamily: 'proxima-nova'
}
},
series: [
/** COMMENT 1 - START **/
{ type: 'bar',
name: 'background fller',
pointWidth: 50,
data: [6, 5, 7, 3, 6],
showInLegend: false,
animation: false,
color: '#dde8f2',
dataLabels: {
enabled: false
},
states: {
hover: {
enabled: false
}
}
},
/** COMMENT 1 - END **/
{ type: 'bar',
name: 'actual value',
pointWidth: 50,
data: [4, 5, 3, 7, 4],
showInLegend: false,
color: '#729bc3',
dataLabels: {
enabled: true,
align: 'left',
style: {
textOutline: false,
color: '#000000',
fontWeight: 'bold',
fontSize: '16px',
fontFamily: 'proxima-nova'
},
},
states: {
hover: {
enabled: false
}
}
}
],
/** COMMENT 2 - START **/
plotOptions: {
series: {
stacking: 'normal',
dataLabels: {
enabled: false
},
events: {
legendItemClick: function (e) {
e.preventDefault();
}
}
}
}
/** COMMENT 2 - END **/
});
mychart.addSeries({ type: 'line', name: 'Indicator1', lineWidth: 0,
data: [3.3, 2, 3, 6, 3], pointPlacement: 0.3, showInLegend: true,
dataLabels: { enabled: true, allowOverlap: true, verticalAlign: 'top', align: 'right', color: '#ff0000', style: { textOutline: false } },
marker: { symbol: 'circle', fillColor: '#ff0000' },
states: { hover: { enabled: false }, }
});
mychart.addSeries({ type: 'line', name: 'Indicator2', data: [3.3, 2, 3, 6, 3], pointPlacement: -0.3, showInLegend: true, dataLabels: { enabled: true, allowOverlap: true, verticalAlign: 'bottom', align: 'right', style: { textOutline: false }, x: 0, y: 0 }, lineWidth: 0, marker: { symbol: 'diamond', fillColor: '#000000' }, states: { hover: { enabled: false }, }
});
Currently you have both indicators in one stack group which makes the values in second indicator to add up with first one. If you want them to look like the second images in your question You should seperate their groups using stack: value option in their series. somthing like this: (note stack: 0 in indicator1 and stack: 1 in indicator2)
mychart.addSeries({ type: 'line', name: 'Indicator1', lineWidth: 0,
data: [3.3, 2, 3, 6, 3], stack : 0, pointPlacement: 0.3, showInLegend: true,
dataLabels: { enabled: true, allowOverlap: true, verticalAlign: 'top', align: 'right', color: '#ff0000', style: { textOutline: false } },
marker: { symbol: 'circle', fillColor: '#ff0000' },
states: { hover: { enabled: false }, }
});
mychart.addSeries({ type: 'line', name: 'Indicator2', data: [3.3, 2, 3, 6,
3],stack:1, pointPlacement: -0.3, showInLegend: true, dataLabels: { enabled: true,
allowOverlap: true, verticalAlign: 'bottom', align: 'right', style: { textOutline:
false }, x: 0, y: 0 }, lineWidth: 0, marker: { symbol: 'diamond', fillColor:
'#000000' }, states: { hover: { enabled: false }, }
JSFiddle: https://jsfiddle.net/3pfm8Laz/
API Reference: https://api.highcharts.com/highcharts/series.line.stack

Highcharts bug - label formatter function does not fire with multiple axis

I have a chart with multiple yAxis and I want to format each one differently. However, it seems with multiple yAxis, the label formatter function does not fire at all. Here's my options:
{
chart: {
backgroundColor: 'transparent',
pinchType: 'none',
height: 320,
events: {
load: (e) => {
}
}
},
plotOptions: {
line: {
states: {
hover: {
enabled: true
}
},
animation: {
duration: 750
}
},
series: {
lineWidth: 2,
}
},
series : [
{ name: 'charts',
type: 'line',
id: 0,
dataGrouping: {
groupPixelWidth: 8
},
},
{ name: 'marketcap',
type: 'line',
id: 1,
color: '#1fd3a3',
dataGrouping: {
groupPixelWidth: 8
},
},
{ name: 'volume',
type: 'area',
id: 2,
color: '#ddd',
lineWidth: 1,
dataGrouping: {
groupPixelWidth: 8
},
}
],
navigator: {
enabled: false
},
scrollbar: {
enabled: false
},
rangeSelector: {
enabled: false
},
// responsive: {
// rules: [{
// condition: {
// maxWidth: 500
// },
// }]
// },
xAxis: {
// crosshair: {
// width: 1,
// color: 'rgba(255,255,255,.5)'
// },
visible: true,
type: 'datetime'
},
yAxis: [
{
opposite: false,
gridLineWidth: 0,
minorGridLineWidth: 0,
height: '75%',
tickAmount: 5,
labels: {
formatter: () => {
// this does not fire
console.log('firing!!');
return this.value
}
}
},
{
opposite: true,
gridLineWidth: 0,
minorGridLineWidth: 0,
height: '75%',
tickAmount: 5
},
{
top: '75%',
height: '25%',
opposite: false,
gridLineWidth: 0,
minorGridLineWidth: 0,
visible: false,
},
],
tooltip: {
followPointer: true,
shared: true,
},
credits: { enabled: false }
}
Notice that I have 3 yAxis, and within each of those I have different keys and values. I need to have a custom format for each, but when I try to use the formatter function, nothing happens. Using the format string value works, but it does not allow me to format the string the way I want. Any ideas?

How to truncate value in tooltip using highcharts

I have following code:
$(function () {
$('#container').highcharts({
chart: {
type: 'spline',
zoomType: 'xy',
borderRadius: 20,
borderWidth: 2,
},
credits: {
enabled: false
},
title: {
text: 'CO2 (Latest 7-days)'
},
exporting: {
enabled: false
},
xAxis: {
type: 'datetime',
labels: {
overflow: 'justify'
},
startOnTick: true,
showFirstLabel: true,
endOnTick: true,
showLastLabel: true,
categories: dateAndTimeArray,
tickInterval: 10,
labels: {
formatter: function() {
return this.value.toString().substring(0, 6);
},
rotation: 0.1,
align: 'left',
step: 20,
enabled: true
},
style: {
fontSize: '8px'
}
},
yAxis: {
title: {
text: 'CO2'
},
labels: {
formatter: function() {
return this.value +'°'
}
}
},
legend: {
enabled: false
},
tooltip: {
// crosshairs: true,
shared: true,
},
plotOptions: {
spline: {
marker: {
radius: 4,
lineColor: '#666666',
lineWidth: 1
}
}
},
series: [{
name: "CR3000Tower",
data: chartData,
marker: {
enabled: false
}
} ]
});
});
It is producing the following output:
I want to truncate the tooltipe value after 2 decimal point. So that the tooltip value will be 414.26 instead of the long value. Any help please. Thanks.
Set valueDecimals, see docs.

Highcharts: remove 1 label from windrose chart

I have created a wind rose type chart using highcharts, and something like a label
that needs to be removed
I tried using: { lables: { enabled: false } } and also tried using
showFirstLabel and showLastLabel
But it didn't work for me :(
Here is how i created the wind rose chart:
wind_rose_chart = Highcharts.data({
table: 'roulette_windrose',
startRow: 1,
endRow: 38,
endColumn: 37,
complete: function (options) {
// Create the chart
window.chart = new Highcharts.Chart(Highcharts.merge(options, {
chart: {
renderTo: 'windrose_container',
polar: true,
type: 'column',
animation: false,
backgroundColor: '#e4e6e1',
plotBackgroundImage: "/images/gallery/windrose_roulette.png",
height: 400,
width: 350,
},
colors: ['#008403',
'#E30000','#000000','#E30000',
'#000000','#E30000','#000000',
'#E30000','#000000','#E30000',
'#000000','#000000','#E30000',
'#000000','#E30000','#000000',
'#E30000','#000000','#E30000',
'#E30000','#000000','#E30000',
'#000000','#E30000','#000000',
'#E30000','#000000','#E30000',
'#000000','#000000','#E30000',
'#000000','#E30000','#000000',
'#E30000','#000000','#E30000'],
title: {
text: 'Spots'
},
pane: {
size: '70%'
},
legend: {
enabled: false
},
xAxis: {
labels: {
enabled: false
},
showFirstLabel: false,
showLastLabel: false,
tickmarkPlacement: 'on',
lineWidth:0,
gridLineWidth: 0
},
yAxis: {
min: 0,
gridLineWidth: 0,
endOnTick: false,
showLastLabel: false,
showFirstLabel: false,
labels: {
formatter: function () {
return this.value;
}
}
},
tooltip: {
formatter: function() {
return this.y;
}
},
plotOptions: {
series: {
stacking: 'normal',
shadow: false,
groupPadding: 0,
pointPlacement: 'on',
}
},
navigation: {
buttonOptions: {
enabled: true
}
},
exporting: {
enabled: true
},
credits: {
enabled: false
}
}));
}
});
following code is working:
yAxis: {
...
labels: {
enabled: false
}
}
DEMO

Resources