Highcharts column chart not rendering in Edge - highcharts

I created line and column charts, everything is working perfectly in local machine. However, when I moved to production, column chart was not displaying the bars. In Chrome it is working perfectly, but in Edge and IE it is not showing.
I searched a lot on Google, but nothing worked. Most of the sites suggest adding below tag.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
and
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

I tried to test the official sample of HighCharts on my side with Edge and IE browser.
Based on my testing results, charts are working fine with IE and Edge browser.
sample code:
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Monthly Average Rainfall'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Rainfall (mm)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Tokyo',
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
name: 'New York',
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]
}, {
name: 'London',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2]
}, {
name: 'Berlin',
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
}]
});
.highcharts-figure, .highcharts-data-table table {
min-width: 310px;
max-width: 800px;
margin: 1em auto;
}
#container {
height: 400px;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #EBEBEB;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
A basic column chart compares rainfall values between four cities.
Tokyo has the overall highest amount of rainfall, followed by New York.
The chart is making use of the axis crosshair feature, to highlight
months as they are hovered over.
</p>
</figure>
Result with IE and Edge browser.
It can possible that the issue is in your customized code or there are some settings on that machine causing this issue.
I suggest you check for any errors or warnings in the console of the browser. It can give an idea about the issue.
If the issue persists then I suggest you post a sample code to test the issue. Also let us know, which version of IE and Edge you are using for this test.

Add one more }); as the last line of code....
...
name: 'Berlin',
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
}]
});
});

Related

Highcharts custom event point of event is not right

i need to add some custom contextmenu on some column charts but here i get some strange results using the highcharts extension custom-events (https://www.highcharts.com/products/plugin-registry/single/15/Custom-Events). i have the following example: https://jsfiddle.net/4zhvdapb/
Highcharts.chart('container', {
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'
},
events: {
contextmenu: function (e) {
console.log("create context menu for curent series: ")
console.log(e)
console.log(e.point.category)
$('#constext-menu-div').text(e.point.category);
$('#constext-menu-div').css({top: e.pageY, left: e.pageX});
$('#constext-menu-div').show();
}
}
}
},
series: [{
name: 'John',
data: [5.32, 3.22, 4.05, 7.15, 2.22]
}, {
name: 'Jane',
data: [2.55, 2.50, 3.53, 2.05, 1.15]
}]
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://blacklabel.github.io/custom_events/js/customEvents.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div style="border: solid 1px; background-color: lightgray; position: absolute; width: 100px; height: 200px; display: none; z-index: 9999;" id="constext-menu-div"></div>
(for some reason the in built code in stack overflow does not work - please use the jsfiddle link)
if you right click for example on the john serie on the buttom right side of the category grapes you will get the point/category of bananas instead of grapes. Same thing for apples where you get oranges.
does anyone have an idea what the problem is?
seems to be a bug: https://github.com/blacklabel/custom_events/issues/119

Highcharts zIndex of dataLabel vs renderer.rect vs tooltip

I'm struggling to get my chart elements in the right Z order, in particular where I have dataLabels with useHTML enabled, and where I also add a rectangle via chart.renderer.rect(). This is illustrated in the following jsfiddle:
https://jsfiddle.net/fk7b3cnz/
I want the rectangle to be above the main chart features (lines, labels), and for the tooltip to be above the rectangle (i.e. above everything). I managed to get the tooltip to sit on top (except for the margin around it... how do I fix that?), but the data labels are sitting above the rectangle... the zIndex I set for the rectangle doesn't seem to have any effect.
JAVASCRIPT:
Highcharts.chart('container', {
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
tooltip: {
useHTML: true,
formatter: function () {
return '<div class="tooltip">value: ' + this.y + '</div>';
}
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
useHTML: true // need this to achieve the text formatting I want via appropriate html (not shown here)
}
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
}, function (chart) { // on complete
chart.renderer.rect(100, 100, 100, 100, 5)
.attr({
'stroke-width': 2,
stroke: 'red',
fill: 'yellow',
zIndex: 9998 // want this to be above chart features but below tooltip
})
.add();
});
CSS:
.highcharts-tooltip span {
background-color: white;
border: 1px solid green;
opacity: 1;
z-index: 9999;
}
.tooltip {
padding: 5px;
}
HTML:
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
Instead of adding zIndex manually you can use Highcharts.SVGElement.toFront method. The rectangle will be plotted above lines and other svg elements. However, data labels that are created using HTML will be always above other SVG elements (Since Highcharts v6.1.1 tooltip can be plotted above HTML content) as you can read in the Highcharts documentation:
"It will always be laid out on top of all other SVG content.
Specifically the tooltip may be rendered below the useHTML label.
Since Highcharts v6.1.1 this can be avoided by setting tooltip.outside
to true."
chart.renderer.rect(100, 100, 100, 100, 5)
.attr({
'stroke-width': 2,
stroke: 'red',
fill: 'yellow'
})
.add()
.toFront();
Demo:
jsfiddle

I need Highchart watermark image when i download highchart

I am using HighCharts Javascript library for a web application. I need Highchart watermark image when i download Highchart.
I am using normal hicgchart code.
Code here
Highcharts.chart('container', {
chart: {
type: 'bar'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
Any suggestions?
please use this code
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
events: {
load: function() {
this.renderer.image('https://i.stack.imgur.com/E1r9X.png', 200, 20, 163, 187)
.attr({
zIndex:1000 })
.add();
}
}
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}],
exporting: {
enableImages: true
}
});
image{display:none;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script><div id="container" style="height: 300px"></div>
You can watermark a picture only when it is downloaded by including that in the exporting options, like this:
exporting: {
chartOptions: {
chart: {
plotBackgroundImage: 'https://i.stack.imgur.com/E1r9X.png'
}
}
}
Highcharts.chart('container', {
chart: {
type: 'bar'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}],
exporting: {
chartOptions: {
chart: {
plotBackgroundImage: 'https://i.stack.imgur.com/E1r9X.png'
}
}
}
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
Working JSFiddle example: https://jsfiddle.net/ewolden/acL4z2su/2/
A watermark on screen where you can interact with the chart (based on a previous answer) can come from:
//
// add a watermark (where template is the highchart object I'm building)
//
template.chart.events = {
load: function() {
this.renderer.image('https://i.stack.imgur.com/E1r9X.png')
.attr({
zIndex:1000, x:'10%', y:'10%', width:'80%',height:'80%', style:'pointer-events:none' })
.add();
}
};

i want to show/hide y axis grid lines of highchart by onclick on button

i want to show/hide y axis grid lines of high chart by onclick of a button.I am not getting grid Line Width property to set in the java script function.Can i know how to access all the properties like grid line width,title,line color,line width,axis label
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
var chart;
function DisableGridLine() {
chart.yAxis.gridLineWidth = 0;
}
$(function () {
$(document).ready(function () {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
gridLineWidth: 10,
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
this.x + ': ' + this.y + '°C';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'New York',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
name: 'Berlin',
data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
});
});
</script>
</head>
<body>
<script src="js/highcharts.js" type="text/javascript"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">
</div>
<input type="button" value="Disable" onclick="disablegridlines();"
</body>
</html>
Use:
chart.yAxis[0].update({
gridLineWidth: 0 // or 1
});

min, max threshold in highcharts

#Hightcharts stock
How can i have two threshold's ? for min,max in this graph http://jsfiddle.net/CYJAk/16/
As an example in here there's only one threshold set
http://jsfiddle.net/gh/get/jquery/1.6/highslide-software/highcharts.com/tree/master/samples/stock/demo/area/
or
instead of threshold option in highcharts, is there way i can show red spots/points when
they fall out of min:max range?
A better way to approach this problem is to add two plot lines on the chart indicating
the minimum and maximum values allowed.
Let's say you would like to apply this to the yAxis and set a minimum of 100 and a maximum of 500, you can like so:
var min = 100;
var max = 500;
yAxis: {
min: min - 100,
max: max + 100,
plotLines: [{
id: 'limit-min',
color: '#FF0000',
dashStyle: 'ShortDash',
width: 2,
value: min,
zIndex: 0
}, {
id: 'limit-max',
color: '#FF0000',
dashStyle: 'ShortDash',
width: 2,
value: max,
zIndex: 0
}]
}
The reason for adding and subtracting 100 to the max and min values is because we'd like the plot lines to be visible on the chart.
Hope that helps.
why not render a second band behind (or over) this series which contains the normal range. Then you could see easily which points fall outside that range.
Based on the answer, I created a quick code sample. I think if you have the red line for min, you can clear see which points are falling below your allowable minimum.
The full code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>How to add min and max thresholds in Highcharts</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Sales By Month',
},
subtitle: {
text: 'Metrics',
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Revenue'
},
plotLines: [{
color: '#FF0000',
dashStyle: 'ShortDash',
width: 2,
value: 22,
zIndex: 0,
label : {
text : 'Goal'
}
}, {
color: '#008000',
dashStyle: 'ShortDash',
width: 2,
value: 10,
zIndex: 0,
label : {
text : 'Loss'
}
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': $'+ this.y;
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'Revenue',
data: [21000, 24000, 27500, 33000, 29000, 26000, 19000, 21000, 25000, 29000, 23000, 18000]
}]
});
});
});
</script>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
Working demo on Edit Fiddle here. It may help you.
Based on the answer, I created a quick code sample. I think if you have the red line for min, you can clear see which points are falling below your allowable minimum.
The full code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>How to add min and max thresholds in Highcharts</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Sales By Month',
},
subtitle: {
text: 'Metrics',
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Revenue'
},
plotLines: [{
id: 'limit-min',
color: '#FF0000',
dashStyle: 'ShortDash',
width: 2,
value: 22000,
zIndex: 0,
label : {
text : 'Last Year\'s Minimum Revenue'
}
}, {
id: 'limit-max',
color: '#008000',
dashStyle: 'ShortDash',
width: 2,
value: 32000,
zIndex: 0,
label : {
text : 'Last Year\'s Maximum Revenue'
}
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': $'+ this.y;
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'Revenue',
data: [21000, 24000, 27500, 33000, 29000, 26000, 19000, 21000, 25000, 29000, 23000, 18000]
}]
});
});
});
</script>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
Working demo here.

Resources