Is this possible with Highchart - highcharts

I have a chart with two combine chart types, line and column. I would like, as in the image below, to have my column chart at the bottom and my line chart a bit higher up and the line chart label to start hihger up as well.
I want something like:
yAxis: labels{y: -100}
My problem with this is that this only moves the labels, not the chart data.
My try so far can be found here: http://jsfiddle.net/32r7rctt/2/

It is possible to set 'height' and 'top' properties of the yAxis. Example: https://jsfiddle.net/mtvy24rj/1/
yAxis: [{
height: '70%',
top: '0%'
}, {
title: {
text: null
},
height: '30%',
top: '70%',
labels: {
enabled: false
},
}],

Related

Position events below analog area in Highcharts combined line/timeline chart

I have created a combined line/timeline chart in this jsfiddle:
// arbitrary code snippet required by stackoverflow editor:
xAxis: [{
type: 'datetime'
}, {
type: 'linear'
}],
I would prefer the events to be positioned below the analog value grid rather than as currently, in the middle of it.
Is there any way to achieve this? Thanks in advance!
I can suggest two solutions:
add a second yAxis and set heights for both y-axes:
yAxis: [{
height: '50%'
}, {
height: '50%',
top: '50%'
}],
Demo: http://jsfiddle.net/BlackLabel/e0zhmyr7/
API: https://api.highcharts.com/highcharts/yAxis.height
change the y values for x-range series in the current implementation
Demo: http://jsfiddle.net/BlackLabel/ow1357tq/

Highchart pie chart colors are not changing

I'm trying to create a pie chart with custom colors. My legend colors update just fine but the pie itself is not changing its colors. I've tried many different ways like setOptions:
Highcharts.setOptions({
colors: ['#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4']
});
Or change color for each pie separately in series:
series: [{
type: 'pie',
keys: ['name', 'y', 'color'],
data: [
{ name: "KPI", y: 60, color: '#f3c200' },
{ name: "-KPI", y: 0, color: '#e87e04' },
{ name: "Remains", y: 40, color: '#e2000f' }
],
size: '60%',
innerSize: '40%',
showInLegend: true,
dataLabels: {
enabled: false
}
}]
And other methods too, but the output is always the same, legend color changed, pie colors did not. When I test my code in a fiddle it works just fine, so it's a local issue, but I do not see where, because every piece of code is the same. So I'm not sure is it a bug, missing package, or imported styles. Please advise if you faced this issue.
Here's my code in a fiddle:
"http://jsfiddle.net/vnfkw9ds/"
In this post, Rohitesh in the comments had the same issue, but it was never resolved:
https://stackoverflow.com/a/10074739/11745912
Ok, looks like if you add highcharts.css to you styles you cannot do any color modifications for some reason. Could not find an answer for two days, but after posting it here, the answer found me.

Highcharts heatmap chart labels render extremely slow

I'm using Highcharts to generate a heatmap grid with around 10k grid cells. The heatmap renders in under a second without dataLabels. However if I enable dataLabels, which are necessary for my project, the same heatmap takes 10 seconds to render. I tried setting useHTML to true, and that renders in 30+ seconds. I'm not doing any work within the dataLabel rendering. Is there any way to speed this up?
The example with 10k cells in the heatmap with enabled data labels is here.
Highcharts.chart('container', {
chart: {
type: 'heatmap'
},
xAxis: {
min: 0,
max: 99
},
series: [{
data: data,
dataLabels: {
enabled: true
}
}]
});
No-opt rendering time: 33.5 s
From the profiler I can say thet there are two good candidates for optimization.
Rendering with overlapping labels: 10.4 s
dataLabels: {
enabled: true,
allowOverlap: true
}
No textOutline: 8.56 s
dataLabels: {
enabled: true,
allowOverlap: true,
shadow: false,
style: {
textOutline: null,
color: 'black'
}
},
The other candidate is about setting zIndex for the data labels, I cannot see how to optimize it without changing internal Highcharts method responsible for drawing data labels. You can wrap drawDataLabels method and remove the part for setting label's zIndex.
Without zIndex: 1.62 s
attr = {
//align: align,
fill: options.backgroundColor,
stroke: options.borderColor,
'stroke-width': options.borderWidth,
r: options.borderRadius || 0,
rotation: rotation,
padding: options.padding
// zIndex: 1 /* commenting this part gives a few good seconds */
};
full example: http://jsfiddle.net/dddqrb9f/1/
I commented only one line in the function but you can remove additional features if you don't need them - e.g. if you don't need labels, you can render text only.
if (!dataLabel) {
dataLabel = point.dataLabel = renderer['text']
Text instead of labels: 0.864 s
example: http://jsfiddle.net/dddqrb9f/2/

HighCharts Column Overlapping

How do I get HighCharts not to overlap columns in this chart? I have tried all sorts of options. What I would like is for highcharts to set the widths evenly depending on the number data elements in the series, the more the narrower.'
I have specified width: 300 to force the columns to overlap just to show what is happening in narrow chart and only add a few data elements.
$(function() {
Highcharts.chart('container', {
chart: {
type: 'column',
width: 300,
zoomType: 'x'
},
legend: {
enabled: false
},
series: [{
data: [
[102.0, 66815.0],
[96.0, 77760.0],
[90.0, 68710.0],
[84.0, 69452.5],
[78.0, 48807.5],
[72.0, 35472.5],
[66.0, 24595.0],
[60.0, 17790.0],
[54.0, 18010.0],
[48.0, 5635.0]
]
}]
});
});
http://jsfiddle.net/a0kjogh1/3/
Data should be sorted before you put it into the chart. You receive the error in the console.
data.sort((a, b) => {
return a[0] > b[0];
});
example: http://jsfiddle.net/a0kjogh1/4/

Highcharts - Data label cut off

I took a sample jsfiddle and modified it here just to show a sample of what I experienced:
http://jsfiddle.net/pMwuv/
Here is what my actual datalabel code looks like:
dataLabels: {
enabled: true,
align: 'left',
verticalAlign: 'top',
style: {
color: 'black'
},
formatter: function () {
if (this.x == 19) {
return this.y + '<br>units left';
};
}
}
What I am having on my area chart is that the last data label is cut off. Is there a way to increase the width of the container or add some type of padding so that the full label shows?
Just changing the x and y position of the label will not work for my area chart. I have my chart customized so that only the last point of the chart has a data label and i want it aligned to the right of the last point and not within the chart.
But if we can get the above sample fiddle to work then the same solution should work for me.
You can add marginRight to chart like this:
chart: {
renderTo: container,
width: 550,
marginRight: 35
}
jsFiddle.
This is not a direct solution, but I suggest you to put the label at the yAxis:
yAxis: {
title: {
text: 'Units left'
}
},
And remove the other attributes, leaving just enabled: true:
plotOptions: {
series: {
dataLabels: {
enabled: true
}
}
},
See the fiddle
You can set spacingRight and add correct value.

Resources