I have a problem in displaying stack label value (histogram chart) , in fact Stacked column label doesn't not displaying, when columns sum had close values on yAxis, i uploaded the (screen shot and code):
Thank you for help
screenshot histogram
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
}
},
series: [{
name: 'John',
data: [54701, 56762, 42544, 94446, 20473],
stack: 'x'
}, {
name: 'Jane',
data: [54701, 52762, 36879, 68872, 82761],
stack: 'y'
}]
});
It's because by default stackLabels.allowOverlap = false. Set this property to true and you will see all labels:
stackLabels: {
enabled: true,
allowOverlap: true,
rotation: 0,
style: {
fontWeight: 'bold',
fontSize: '9px',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
Demo:
https://jsfiddle.net/BlackLabel/xbp5c61s/
API reference:
https://api.highcharts.com/highcharts/yAxis.stackLabels.allowOverlap
Related
Can anyone help me with highcharts stacked column my problem is that i have big difference with data and the graph show me only the big data.
i try minPointLength but don't help in my case. please check here the example: http://jsfiddle.net/17jd6frn/
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
}
}
},
series: [{
name: 'John',
data: [2000, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [7000, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});
});
One option is to use a logarithmic scale (http://api.highcharts.com/highcharts/yAxis.type). It will show your small numbers and your large numbers. Note, that you can't show 0 or negative numbers on a log scale.
yAxis: [{
type: "logarithmic",
min: 1,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
}],
http://jsfiddle.net/17jd6frn/1/
You have two options with you.
1.) Either use "minPointLength". This is the minimum value for for the y-axis plotting.You can use this setting and set this to a value which will always be shown in case the value gets too small for plotting. You can use this setting like
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
},
minPointLength: 5
}
},
series: [{
name: 'John',
data: [7000, 5, 1, 1, 2]
}, {
name: 'Jane',
data: [2000, 10, 1, 1, 2]
}, {
name: 'Joe',
data: [5, 1, 1, 1, 2]
}]
});
});
2.) You can change the "stacking" option to 'percent' and remove the 'minPointLength' . This will cause the stacked columns to appear w.r.t to their value percentages.
Please play with the above two options and see if it works for you !!!
I want to give a color for bars depending on their values.
For example if you a bar value 5000 then the color should be Dark RED similar for 3000 less darker than 5000 bar values so on...
I want to add total space like 100TB above all bars(some text on my bar value)
`
Availability Bar Chart
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Disk Utility'
},
subtitle: {
text: 'Source: Application Name'
},
xAxis: {
categories: ['Checkout', 'Hermes', 'Hybris', 'Marketplace', 'Mobile'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Used (TB)',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
tooltip: {
valueSuffix: ' millions'
},
plotOptions: {
column: {
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true
},
credits: {
enabled: false
},
series: [{
data: [107, 311, 635, 203, 244]
}]
});
});
Fiddle
Here is updated fiddle
You can use "Zones" in plotoptions to define a range and relevant color , as per code below :
zones: [{
value: 200,
color: '#bdbdbd'
},{
value:300,
color: '#ff0000'
},
{
value:500,
color: 'blue'
},{
value:800,
color: 'black'
}]
I am trying to generate combination chart with stacked column and spline.Example of categories that I have are :
'Q4 12', 'Q3 12', 'Q2 12', 'Q1 12', 'Q4 11','Forecast'
So it will have 6 bars, but I want 'Q4 11' and 'Forecast' 'touching',I mean close to each other.This is because 'Forecast' is related to 'Q4 11' category.I already read demo on Stacked and Group column but still don't have idea to make only certain bar close to each other.
Here is my code, you also can view it in JSFiddle also.Thanks for reading this.
$(function () {
$('#container').highcharts({
tooltip: { enabled: false },
chart: {
},
title: {
text: 'Desktop'
},
xAxis: {
categories: ['Q4 12', 'Q3 12', 'Q2 12', 'Q1 12', 'Q4 11','Forecast']
},
yAxis:[ {
min: 0,
title: {
text: 'TAM'
},
stackLabels: {
enabled: false,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
{ // Secondary yAxis
title: {
text: 'Share',
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
format: '{value} %',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true,
min:0,max:100
}
],
legend: {
align: 'right',
x: -70,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black, 0 0 3px black'
}
}
}
},
series: [{
name: 'HDD',
type:'column',
data: [0, 30, 40, 70, 20,30],
stack:'old'
},
{
name: 'SSHD',
type:'column',
data: [20, 20, 30, 20, 10,0],
stack:'old'
},
{
name: 'SSD',
type:'column',
data: [30, 40, 40, 20, 50,10],
stack:'old'
},
{
name: 'Share',
type: 'spline',
data: [10, 20, 40, 90,70],
}
]
});
});
You can use different series, linked to the main one. In that case you will be able to set different options for that one specific bar, see: http://jsfiddle.net/tQeF7/28/
Now you can play around with pointPadding and groupPadding like in aboce example. Or you can use pointPlacement, like this: http://jsfiddle.net/tQeF7/29/
Note, with the second solution, it moves only point, not the full category. In Highcharts terms categories always are taking full space and divide in evenly between each.
I would like to add points to my highcharts without expecting to fulfill all the categories.
is it possible? any work around?
I've done the same when X data is based on time, but could it be done with other kind of data?
For example one serie could be just Apples and Oranges, but not the other categories. See code:
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -70,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
return '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y +'<br/>'+
'Total: '+ this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'John',
data: [[Apples,5], [Oranges, 6]]
}, {
name: 'Jane',
data: [[Grapes,2]]
}, {
name: 'Joe',
data: [[Grapes,2], [Bananas, 4]]
}]
});
});
You can use the indexes into your categories: http://jsfiddle.net/BwyAj/
var categories = ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
...
series: [{
name: 'John',
data: [[categories.indexOf('Apples'),5], [categories.indexOf('Oranges'), 6]]
}, {
name: 'Jane',
data: [[categories.indexOf('Grapes'),2]]
}, {
name: 'Joe',
data: [[categories.indexOf('Grapes'),2], [categories.indexOf('Bananas'), 4]]
}]
I am trying to get the horizontal scroll bar to work in my highcharts graph. Though the horizontal scroll bar appears, there is no space to scroll. The graph is actually becoming smaller to be able to accommodate all the data.
Here is the jsfiddle code
var colors = Highcharts.getOptions().colors;
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
xAxis: {
categories: ["CCD Oberon Mall","CCD Gold S",
"Barista Coffee Shop Indra Nagar",
"Dominos Pizza Delhi MG Road"],
title: {
enabled: true,
margin: 15
},
labels: {
rotation: -90,
align: 'right',
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
}
},
scrollbar: {
enabled: true
},
yAxis: [{
title: {
text: 'Age Count'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
}, { // Secondary yAxis
title: {
text: 'Gender Count'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
},
opposite: true
}],
legend: {
align: 'center',
//x: -100,
verticalAlign: 'top',
//y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>'; //+
//'Total: '+ this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal',
point: {
events: {
click: function () {
console.log('this.x,y=' + this.x + "," + this.y + " category=" + this.category);
}
}
},
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
type: 'column',
name: 'Female',
data: [44,4,10,10],
stack: 'Female'
}, {
type: 'column',
name: 'Male',
data: [30,0,0,10],
stack: 'Male'
}, {
type: 'column',
name: 'Under 18',
data: [0,0,0,0],
yAxis: 1,
stack: 'Under18'
}, {
type: 'column',
name: '18 To 24',
data: [0,0,0,0],
yAxis: 1,
stack: '18To24'
}, {
type: 'column',
name: '25 To 34',
data: [54,4,10,20],
yAxis: 1,
stack: '25To34'
}, {
type: 'column',
name: 'Above 34',
data: [20,0,0,3],
yAxis: 1,
stack: 'Above34'
}]
});
You need to set min/max values, i.e
min:0,
max: 2 // 2 categories on xAxis will be displayed
http://jsfiddle.net/2K8uW/2/