I have created a chart with StockChart and I am trying to enlarge the cropThreshold of the serie but without success.
When I am using the HighCharts implementation then it's working as expected.
example of StockChart / HighChart:
- JSFiddle
(To see the difference between the two implementation just change line 4 with line 5)
code:
$(function() {
Highcharts.stockChart('container', {
/* Highcharts.chart({ */
chart: {
renderTo: 'container'
},
title: {
text: 'Project wise Budget Estimation'
},
navigation: {
buttonOptions: {
enabled: false
}
},
navigator: {
enabled: false
},
rangeSelector: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
tickInterval: 15 * 60 * 1000,
type: 'datetime',
min: 1530385200000,
max: 1530394200000
},
yAxis: {
min: 0,
opposite: false,
tickColor: '#95989A',
tickWidth: 1,
tickLength: 10,
visible: true,
tickInterval: 60,
title: {
text: 'Amount Distribution'
}
},
legend: {
shadow: false
},
tooltip: {
},
plotOptions: {
column: {
stacking: 'normal',
cropThreshold: 150
}
},
series: [
{
name: 'targetName',
showInLegend: true,
data: [
[1530385200000,500],[1530386100000,500],[1530387000000,500],[1530387900000,500],[1530388800000,500],[1530389700000,500],[1530390600000,400],[1530391500000,450],[1530392400000,550],[1530393300000,500],[1530394200000,650],[1530395100000,500],[1530396000000,500],[1530396900000,550],[1530397800000,500],[1530398700000,500],[1530399600000,700],[1530400500000,650],[1530401400000,800],[1530402300000,500],[1530403200000,500],[1530404100000,300],[1530405000000,250],[1530405900000,200],[1530406800000,350],[1530407700000,150],[1530408600000,770],[1530409500000,800],[1530410400000,500],[1530411300000,500],[1530412200000,500],[1530413100000,500],[1530414000000,500],[1530414900000,500],[1530415800000,500],[1530416700000,500],[1530417600000,500],[1530418500000,500],[1530419400000,500],[1530420300000,500],[1530421200000,500],[1530422100000,500],[1530423000000,500],[1530423900000,500],[1530424800000,500]
],
zIndex: 2
},
{
name: 'deviationName',
showInLegend: true,
data: [
[1530385200000,450,550],[1530386100000,450,550],[1530387000000,450,550],[1530387900000,450,550],[1530388800000,450,550],[1530389700000,450,550],[1530390600000,360,440],[1530391500000,405,495],[1530392400000,495,605],[1530393300000,450,550],[1530394200000,585,715],[1530395100000,450,550],[1530396000000,450,550],[1530396900000,495,605],[1530397800000,450,550],[1530398700000,450,550],[1530399600000,630,770],[1530400500000,585,715],[1530401400000,720,880],[1530402300000,450,550],[1530403200000,450,550],[1530404100000,270,330],[1530405000000,225,275],[1530405900000,180,220],[1530406800000,315,385],[1530407700000,135,165],[1530408600000,693,847],[1530409500000,720,880],[1530410400000,450,550],[1530411300000,450,550],[1530412200000,450,550],[1530413100000,450,550],[1530414000000,450,550],[1530414900000,450,550],[1530415800000,450,550],[1530416700000,450,550],[1530417600000,450,550],[1530418500000,450,550],[1530419400000,450,550],[1530420300000,450,550],[1530421200000,450,550],[1530422100000,450,550],[1530423000000,450,550],[1530423900000,450,550]
],
type: 'arearange',
linkedTo: ':previous',
zIndex: 0
},
{
name: 'periodsName',
showInLegend: false,
type: 'column',
cropThreshold: 150,
zIndex: 1,
pointInterval: 24 * 3600 * 1000,
data: [
{"x":1530385200000,"y":400,"colorIndex":55},{"x":1530386100000,"y":400,"colorIndex":55},{"x":1530387000000,"y":400,"colorIndex":55},{"x":1530387900000,"y":480,"colorIndex":56},{"x":1530388800000,"y":495,"colorIndex":56},{"x":1530389700000,"y":510,"colorIndex":56},{"x":1530390600000,"y":700,"colorIndex":57},{"x":1530391500000,"y":650,"colorIndex":57},{"x":1530392400000,"y":300,"colorIndex":55},{"x":1530393300000,"y":660,"colorIndex":57},{"x":1530394200000,"y":400,"colorIndex":55},{"x":1530395100000,"y":500,"colorIndex":56},{"x":1530396000000,"y":500,"colorIndex":56},{"x":1530396900000,"y":200,"colorIndex":55},{"x":1530397800000,"y":490,"colorIndex":56},{"x":1530398700000,"y":500,"colorIndex":56},{"x":1530399600000,"y":400,"colorIndex":55},{"x":1530400500000,"y":300,"colorIndex":55},{"x":1530401400000,"y":200,"colorIndex":55},{"x":1530402300000,"y":500,"colorIndex":56},{"x":1530403200000,"y":480,"colorIndex":56},{"x":1530404100000,"y":670,"colorIndex":57},{"x":1530405000000,"y":755,"colorIndex":57},{"x":1530405900000,"y":680,"colorIndex":57},{"x":1530406800000,"y":710,"colorIndex":57},{"x":1530407700000,"y":670,"colorIndex":57},{"x":1530408600000,"y":400,"colorIndex":55},{"x":1530409500000,"y":400,"colorIndex":55},{"x":1530410400000,"y":500,"colorIndex":56},{"x":1530411300000,"y":400,"colorIndex":55},{"x":1530412200000,"y":510,"colorIndex":56},{"x":1530413100000,"y":400,"colorIndex":55},{"x":1530414000000,"y":490,"colorIndex":56},{"x":1530414900000,"y":400,"colorIndex":55},{"x":1530415800000,"y":400,"colorIndex":55},{"x":1530416700000,"y":590,"colorIndex":57},{"x":1530417600000,"y":590,"colorIndex":57},{"x":1530418500000,"y":600,"colorIndex":57},{"x":1530419400000,"y":620,"colorIndex":57},{"x":1530420300000,"y":400,"colorIndex":55},{"x":1530421200000,"y":600,"colorIndex":57},{"x":1530422100000,"y":600,"colorIndex":57},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55},{"x":1530423000000,"y":600,"colorIndex":57},{"x":1530423900000,"y":400,"colorIndex":55}
]
},
{
name: 'withinTarget',
type: 'column',
showInLegend: true,
data: []
},
{
name: 'belowTarget',
type: 'column',
showInLegend: true,
data: []
},
{
name: 'overTarget',
type: 'column',
showInLegend: true,
data: []
}],
scrollbar: {
enabled:true,
/* liveRedraw: false, */
barBackgroundColor: 'gray',
barBorderRadius: 7,
barBorderWidth: 0,
buttonBackgroundColor: 'gray',
buttonBorderWidth: 0,
buttonArrowColor: 'yellow',
buttonBorderRadius: 7,
rifleColor: 'yellow',
trackBackgroundColor: 'white',
trackBorderWidth: 1,
trackBorderColor: 'silver',
trackBorderRadius: 7
}
});
});
This behavior is caused by dataGrouping, you can disable it. It is also worth noting that you have unsorted data.
plotOptions: {
series: {
stacking: 'normal',
cropThreshold: 150,
dataGrouping: {
enabled: false
}
}
}
Live example: http://jsfiddle.net/BlackLabel/2ma3yhv1/
API Reference: https://api.highcharts.com/highstock/plotOptions.series.dataGrouping.enabled
I have create graph 3 level drilldown and want to show legend of 3rd level follow with color.
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
labels: {
rotation: -45,
align: "right",
y: 30,
},
type: "category",
tickWidth: 0
},
yAxis: {
title: {
text: 'Total fruit consumption'
}
},
legend: {
enabled: true,
itemStyle: {
fontSize:'10px'
},
align: 'right',
verticalAlign: 'middle',
layout: 'vertical',
reversed:true
},
plotOptions: {
series: {
cropThreshold: 1000,
animation: {
duration: 300
},
cursor: 'pointer',
point: {
events: {
click: function () {
if(this.id)
{
alert(this.id);
}
}
}
}
},
column: {
cropThreshold: 1000,
minPointLength: 3,
animation: false,
stacking: 'normal'
}
},
series: [{
index: 0,
name: 'Tippers',
turboThreshold: 0,
cropThreshold: Infinity,
data: [{
name:'01-Feb-2018',
colorByPoint:true,
y:3,
drilldown:'Tippers-1-2-2018'
}]
}],
drilldown: {
activeAxisLabelStyle: {
textDecoration: 'none',
color: 'black',
fontWeight: 'normal'
},
series: [{
name: '01-Feb-2018',
id: 'Tippers-1-2-2018',
turboThreshold: 0,
cropThreshold: Infinity,
showInLegend: false,
data: [ {
name: 'psb04221',
y: 1,
drilldown:'psb04221/Tippers-1-2-2018'
},{
name: 'rvd910939',
y: 2,
drilldown:'rvd910939/Tippers-1-2-2018'
},]
},{
name: '01-Feb-2018',
id: 'Trucks-1-2-2018',
turboThreshold: 0,
cropThreshold: Infinity,
showInLegend: false,
data: [ {
name: 'rvd910939',
y: 2,
drilldown:'rvd910939/Trucks-1-2-2018'
},{
name: 'sks913031',
y: 1,
drilldown:'sks913031/Trucks-1-2-2018'
},]
},{
name: 'psb04221 / Tippers 1-February-2018',
id: 'psb04221/Tippers-1-2-2018',
turboThreshold: 0,
cropThreshold: Infinity,
showInLegend: false,
data: [ {
name: '01-February-2018-44',
id: '44',
y: 1,
type_legend: 'green',
color:'green'
},]
},{
name: 'rvd910939 / Tippers 1-February-2018',
id: 'rvd910939/Tippers-1-2-2018',
turboThreshold: 0,
cropThreshold: Infinity,
showInLegend: false,
data: [ {
name: '01-February-2018-21',
id: '21',
y: 1,
type_legend: 'green',
color:'green'
},{
name: '01-February-2018-25',
id: '25',
y: 1,
type_legend: 'yellow',
color:'yellow'
},{
name: '01-February-2018-27',
id: '27',
y: 1,
type_legend: 'green',
color:'green'
},]
},{
name: 'rvd910939 / Trucks 1-February-2018',
id: 'rvd910939/Trucks-1-2-2018',
turboThreshold: 0,
cropThreshold: Infinity,
showInLegend: false,
data: [ {
name: '01-February-2018-13',
id: '13',
y: 1,
type_legend: 'red',
color:'red'
},{
name: '01-February-2018-26',
id: '26',
y: 1,
type_legend: 'green',
color:'green'
},]
},{
name: 'sks913031 / Trucks 1-February-2018',
id: 'sks913031/Trucks-1-2-2018',
turboThreshold: 0,
cropThreshold: Infinity,
showInLegend: false,
data: [ {
name: '01-February-2018-22',
id: '22',
y: 1,
type_legend: 'yellow',
color:'yellow'
},{
name: '01-February-2018-23',
id: '23',
y: 1,
type_legend: 'green',
color:'green'
},]
}]
}
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
1st drilldown legend show date is correct
2nd drilldown I want to show legend users
3rd drilldown I want to show legend for color filter
Please help me to add legend for show legend filter by color Red , Green and Blue of 3rd drilldown like this image : 3rd Drilldown
I have resolved problem by answer of ppotaczek.
In your example, the third level of drilldown is one series, that is why the legend show only one item. If you want to have multiple legend items on drilldown, you have to have multiple series. You can use drilldown event and addSeriesAsDrilldown method, like in the example below to achieve needed result.
Live demo: http://jsfiddle.net/BlackLabel/amg8234t/
API Reference:
https://api.highcharts.com/class-reference/Highcharts.Chart#addSeriesAsDrilldown
https://api.highcharts.com/highcharts/chart.events.drilldown
Best regards!
Thank you so much.
I'm using Highcharts.js library and when Bar Chart height is small, yAxis labels get skipped. By increasing the size of the bar chart the labels appear again. How do you avoid the labels disappearing.
See this jsfiddle for example - http://jsfiddle.net/VbecE/3/
<script src="http://code.highcharts.com/highcharts.js"></script>
<h3>Why does this skip yaxis labels America and Europe?</h3>
<div id="container" style="min-width: 310px; height: 150px; margin: 0 auto"></div>
<h3>10px bigger and all 5 yaxis labels visible</h3>
<div id="container2" style="min-width: 310px; height: 170px; margin: 0 auto"></div>
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
xAxis: {
categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Population (millions)',
align: 'high'
},
labels: {
overflow: 'justify',
crop:false
}
},
tooltip: {
valueSuffix: ' millions'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true,
crop:false
}
},
series: {
dataLabels:{
crop:false}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{
name: 'Year 1800',
data: [107, 31, 635, 203, 2]
}, {
name: 'Year 1900',
data: [133, 156, 947, 408, 6]
}, {
name: 'Year 2008',
data: [973, 914, 4054, 732, 34]
}]
});
});
$(function () {
$('#container2').highcharts({
chart: {
type: 'bar'
},
xAxis: {
categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Population (millions)',
align: 'high'
},
labels: {
overflow: 'justify',
crop:false
}
},
tooltip: {
valueSuffix: ' millions'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true,
crop:false
}
},
series: {
dataLabels:{
crop:false}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{
name: 'Year 1800',
data: [107, 31, 635, 203, 2]
}, {
name: 'Year 1900',
data: [133, 156, 947, 408, 6]
}, {
name: 'Year 2008',
data: [973, 914, 4054, 732, 34]
}]
});
});
You can set step parameter as 1,
labels: {
step:1,
}
http://jsfiddle.net/VbecE/7/