Related
As soon as I scroll using x axis and hover over any bar the tooltip location comes at the end of the chart rather than above the bar.
const chart = Highcharts.ganttChart('container', {
chart: {
spacingLeft: 1,
style: {
fontFamily: ' Roboto, sans-serif;'
},
// event:{
// load: function(e){
// console.log(e)
// }
// },
scrollablePlotArea: {
scrollPositionY: 0,
opacity: 0
}
},
title: {
text: 'Gantt Chart with Navigation'
},
// chart: {
// scrollablePlotArea: {
// minWidth: 700,
// scrollPositionX: 1
// },
// events: {
// click: function(event) {
// alert (
// 'x: '+ Highcharts.dateFormat('%Y-%m-%d', event.xAxis[0].value) +', ' +
// 'y: '+ event.yAxis[0].value
// );
// }
// }
// },
yAxis: {
uniqueNames: true,
grid: {
enabled: true,
borderColor: 'rgba(0,0,0,0.3)',
borderWidth: 1
},
min: 0,
max: 6,
scrollbar:{
enabled : true
},
},
xAxis: {
currentDateIndicator: true,
grid: {
enabled: true,
borderColor: 'rgba(0,0,0,0.3)',
borderWidth: 1
}
},
// tooltip: {
// xDateFormat: '%a %b %d, %H:%M'
// },
plotOptions:{
series: {
pointWidth: 13,
dataLabels: {
enabled: true,
format: '{point.label}',
style: {
cursor: 'default',
pointerEvents: 'none'
}
},
}
},
navigator: {
enabled: true,
liveRedraw: 0,
series: {
type: 'gantt',
pointPlacement: 0.5,
pointPadding: 0.25
},
yAxis: {
min: 0,
max: 3,
reversed: true,
categories: []
}
},
scrollbar: {
enabled: true
},
rangeSelector: {
enabled: true,
selected: 5
},
series: [{
dataLabels: {
enabled: true,
style: {
textOutline: 0
}
},
// name : 'vai',
data: <?php echo $string; ?>
}],
tooltip: {
outside: true,
useHTML: true,
style :{
borderRadius: "10px 10px 10px"
},
pointFormatter: customPointFormatter
}
});
I have been able to convert my range selector buttons in to a dropdown rather than displaying as a list. And seperately, adding the export to PDF/Image dropdown.
What i am now trying to achieve is integrate the range selector dropdown buttons in to the same dropdown as the Export, or vice versa.
Export:
exporting: {
enabled: true,
allowHtml: true,
accessibility: {
enabled: true,
},
buttons: {
contextButtons: {
enabled: true
}
}
}
Range selector:
exporting: {
buttons: {
contextButton: {
enabled: false
},
toggle: {
text: 'Select range',
align: 'left',
height: 20,
y: -3,
theme: {
'stroke-width': 0.5,
stroke: '#000000',
r: 2
},
menuItems: [{
text: '1M',
onclick: function() {
this.rangeSelector.clickButton(0, true);
}
}, {
text: '3M',
onclick: function() {
this.rangeSelector.clickButton(1, true);
}
}, {
text: '6M',
onclick: function() {
this.rangeSelector.clickButton(2, true);
}
}, {
text: 'YTD',
onclick: function() {
this.rangeSelector.clickButton(3, true);
}
}, {
text: '1Y',
onclick: function() {
this.rangeSelector.clickButton(4, true);
}
}, {
text: 'All',
onclick: function() {
this.rangeSelector.clickButton(5, true);
}
}]
}
}
},
Example:
http://jsfiddle.net/8rrotg5a/
Add default items to menuItems array:
exporting: {
buttons: {
contextButton: {
enabled: false
},
toggle: {
...,
menuItems: [..., {
text: 'All',
onclick: function() {
this.rangeSelector.clickButton(5, true);
}
},
'separator',
'viewFullscreen',
'printChart',
'separator',
'downloadPNG',
'downloadJPEG',
'downloadPDF',
'downloadSVG'
]
}
}
}
Live demo: http://jsfiddle.net/BlackLabel/j7s8xgtr/
API Reference: https://api.highcharts.com/highcharts/exporting.buttons.contextButton.menuItems
I am having an issue displaying my chart. I am creating a script that displays three charts with a print button to print all the chart to one PDF.
The JSON call is returning:
[{"name":"Month"},{"name":"percent","data":[9.52]}]
I am not getting any errors in the browser console, can any one see where I am going wrong.
$(function () { //1
var chart1, chart2, chart3;
var categories=[];
//var chart;
var data2 =[];
$(document).ready(function() { //2
$.getJSON("../charts/1-2-4-detractors_month_chart.php?From=<?php echo $_GET['From'];?>&To=<?php echo $_GET['To'];?>", function(json) { //3
$.each(json,function(i,el) { //4
if (el.name=="Month")
categories = el.data;
else data2.push(el);
});
chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container1',
type: 'column',
marginTop: 25,
marginRight: 25,
marginBottom: 25,
plotBackgroundColor: '#FCFFC5',
style: {
fontFamily: 'serif',
fontSize: '8px',
}
},
title: {
text: '',
},
subtitle: {
text: '',
},
xAxis: {
categories: categories,
labels: {
enabled: false
}
},
yAxis: {
endOnTick: false,
max:101,
showFirstLabel: false,
lineColor:'#999',
lineWidth:1,
tickColor:'#666',
tickWidth:1,
tickLength:2,
tickInterval: 10,
gridLineColor:'#ddd',
title: {
text: '',
style: {
fontFamily: 'Tahoma',
color: '#000000',
fontWeight: 'bold',
fontSize: '8px'
}
},
plotLines: [{
color: '#808080'
}]
},
legend: {
enabled: false,
},
colors: ['#FF0000','#FF2F2F'],
plotOptions: {
column: {
colorByPoint: true
},
series: {
cursor: 'pointer',
pointWidth: 20,
point: {
events: {
//click: function() {
//location.href = "feedback-items_detractors_iframe.php?FromDate1=<?php echo $StartDate;?>&ToDate1=<?php echo $EndDate;?> target='iframe2'";
//}
}
},
legendIndex:0,
dataLabels: {
enabled: true,
color: '#000000',
align: 'center',
cursor: 'pointer',
borderRadius: 5,
backgroundColor: 'rgba(252, 255, 255, 255)',
borderWidth: 1,
borderColor: '#AAA',
y: -6,
format: '{y:.2f} %', // one decimal
y: -20, // 10 pixels down from the top
style: {
textShadow: false,
fontSize: '8px',
fontFamily: 'Verdana, sans-serif'
}
}
}
},
tooltip: {
style: {
fontSize: '7pt',
fontFamily: 'Verdana, sans-serif'
},
valueDecimals: 1,
formatter: function() {
return '<b>Guest responses:<br/> '+ this.y +'%</b>';
}
},
navigation: {
buttonOptions: {
verticalAlign: 'top',
y: -10,
x: -20
}
},
credits: {
enabled: false
},
series: data2,
lang: {
noData: "No data"
},
noData: {
style: {
fontWeight: 'normal',
fontSize: '12px',
color: '#303030'
}
},
});
});
});
//});
//--------------------------------------------------------------------
$("#print").click(function () {
printCharts([chart1, chart2, chart3]);
});
//--------------------------------------------------------------------
function printCharts(charts) {
var origDisplay = [],
origParent = [],
body = document.body,
childNodes = body.childNodes;
// hide all body content
Highcharts.each(childNodes, function (node, i) {
if (node.nodeType === 1) {
origDisplay[i] = node.style.display;
node.style.display = "none";
}
});
// put the charts back in
$.each(charts, function (i, chart) {
origParent[i] = chart.container.parentNode;
body.appendChild(chart.container);
});
// print
window.print();
// allow the browser to prepare before reverting
setTimeout(function () {
// put the chart back in
$.each(charts, function (i, chart) {
origParent[i].appendChild(chart.container);
});
// restore all body content
Highcharts.each(childNodes, function (node, i) {
if (node.nodeType === 1) {
node.style.display = origDisplay[i];
}
});
}, 500);
}
});
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.
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