highcharts download context menu size - highcharts

I am using highcharts & highstock latest versions and been struggling ever since day 1 to get the download context menu width size right... there seems to be no way to control the context's menu width and I am not sure what I am doing wrong... please take a look on the below image.
Any help would be appreciated.
<div id='CurrentDemand' style='width:1124px; height:400px;'></div>
function Chart_CurrentDemand_Bar(DIVID, TITLE, CATEGORIES, yAxisLabel, Tooltip, SERIES1LABEL, SERIES1VALUES ) {
var Param_CATEGORIESS = JSON.stringify(CATEGORIES);
var Param_SERIES1VALUES = JSON.stringify(SERIES1VALUES);
var data_CATEGORIESS = JSON.parse(Param_CATEGORIESS);
var data_SERIES1VALUES = JSON.parse(Param_SERIES1VALUES);
$("#" + DIVID).highcharts({
chart: {
type: 'column'
},
title: {
text: TITLE
},
xAxis: {
categories: data_CATEGORIESS,
tickInterval: .5,
tickmarkPlacement: 'on',
gridLineWidth: .5
},
yAxis: {
min: 0,
title: {
text: yAxisLabel
}
},
tooltip: {
headerFormat: '<span style="font-size:20px">{point.key}</span><table width=150px>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:1f} </b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true,
animation:true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: SERIES1LABEL,
data: data_SERIES1VALUES
}],
navigation: {
buttonOptions: {
verticalAlign: 'bottom',
y: -20,
height: 30,
theme: {
'stroke-width': 1,
stroke: 'silver',
r: 0,
states: {
hover: {
fill: '#bada55'
},
select: {
stroke: '#039',
fill: '#bada55'
}
}
}
}
}
});
}

Related

Highcharts - How to deploy data labels & tooltips for 2nd data series

I've created a Highcharts that is a bit unusual. It's placing two series in the same plotarea, but instead of them "lining up" and sharing the entire plot area, series0 is using the left side of the area and series1 is using the right side. Everything is working great except for two (related) things: I cannot get tooltips or datalabels to display for the series1 data on the right-hand side of the page. Completely guessing here, but I'm guessing the series are not being shared because they are not lining up together.
I've spent the past day trying various things and have completely ran out of ideas. Hoping a fresh set of eyes might spot something that will work. Attached is a fiddle for your viewing pleasure...
https://jsfiddle.net/wk0uh72o/
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<div id="adaRate"></div>
$(function() {
var options = {
chart: {
renderTo: 'adaRate',
type: 'bar',
width: 600,
height: 400
},
title: {
text: 'Average Daily Attendance Rate',
align: 'center',
style: {
fontWeight: 'bold',
color: 'rgba(0,0,0,.9)'
}
},
legend: {
enabled: true
},
tooltip: {
shared: true,
crosshairs: true,
formatter: function() {
var s = '<b>' + this.x + '</b>';
$.each(this.points, function() {
s += '<br/>' + this.series.name + ': ' +
this.y + '%';
});
return s;
},
},
xAxis: {
labels: {
style: {
fontWeight: 'bold'
}
}
},
yAxis: [{
min: 0,
max: 100,
opposite: true,
width: 270,
title: {
text: 'Average Daily Attendance %'
}
}, {
min: -10,
max: 10,
offset: 0,
opposite: true,
plotLines: [{
color: 'red',
value: 0,
width: 2
}],
left: 400,
width: 170,
title: {
text: 'Variance from Prior Year'
}
}],
series: [{
name: 'ADA',
dataLabels: {
enabled: true,
align: 'right',
color: '#FFFFFF',
x: -10
},
yAxis: 0,
}, {
type: 'scatter',
name: 'PY Variance',
dataLabels: {
enabled: true,
align: 'center',
color: '#000000',
x: -10
},
yAxis: 1,
}],
credits: {
enabled: false
}
};
var categories = ["School 1", "School 2", "School 3", "School 4", "School 5", "School 6", "School 7"];
var adaRate = [96.4, 95.9, 93.3, 92.3, 89.8, 85.4, 83.9];
var adaVar = [{
"color": "yellow",
"y": -.8
}, {
"color": "red",
"y": -3.5
}, {
"color": "lightgreen",
"y": 1.5
}, {
"color": "lightgreen",
"y": 2.3
}, {
"color": "red",
"y": -4.3
}, {
"color": "green",
"y": 5.3
}, {
"color": "darkgreen",
"y": 7.8
}
];
options.xAxis.categories = categories;
options.series[0].data = adaRate;
options.series[1].data = adaVar;
var chart = new Highcharts.Chart(options);
});
I don't have time to write a longer answer. But, shared tooltips don't work for unordered data (pie, scatter, flag). See http://api.highcharts.com/highcharts#tooltip.shared
You can simulate a scatter series using a line series with lineWidth of 0. You also have to modify the mouseOver event to not increase the lineWidth on hover.
Just need to remove tooltip on the top level. But set it in each series separately.
series: [{
name: 'ADA',
dataLabels: {
enabled: true,
align: 'right',
color: '#FFFFFF',
x: -10
},
yAxis: 0,
tooltip: {
pointFormat: 'First {point.y}'
}
}, {
type: 'scatter',
name: 'PY Variance',
dataLabels: {
enabled: true,
align: 'center',
color: '#000000',
x: -10
},
yAxis: 1,
tooltip: {
pointFormat: 'Second {point.y}'
}
}],
refer to fiddle I updated from yours.

Highcharts, button to redraw stackedcolumn

I am bringing in to my chart json objects, indexed two different ways.
I have a button to flip my index, and it works in the sense that my catagories will flip back and forth, but my new data does not...
var $chart_data = data[1];
$button = $('#button');
var chart_ops_support_times = new Highcharts.Chart({
chart: {
renderTo: 'chart_ops_support_times',
type: 'column'
},
title: {
useHTML: true,
text: '',
align: 'left'
},
subtitle: {
text: ' '
},
xAxis: {
categories: [
'priority 1',
'priority 2',
'priority 3'
]
},
yAxis: {
min: 0,
max: 60,
title: {
text: 'Total Actual Hours by Type',
style: {
fontSize: '8px',
fontWeight: 'normal'
}
},
stackLabels: {
enabled: false,
style: {
fontWeight: 'bold'
}
}
},
legend: {
align: 'center',
x: 0,
verticalAlign: 'top',
y: 0,
floating: true,
borderColor: '#CCC',
borderWidth: 1,
shadow: false,
symbolHeight: 10,
symbolWidth: 10
},
credits: {
enabled: 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: false,
style: {
textShadow: '0 0 3px black'
}
}
}
},
exporting: {
enabled: false
},
series: $chart_data
});
$button.click(function() {
if (!flipxAxis) {
console.log('flip to priority x axis');
chart_ops_support_times.xAxis[0].categories = priority_bkts ;
chart_ops_support_times.series[0].update({
dataLabels: {
enabled: true
},
series: data[0]
});
chart_ops_support_times.redraw();
} else {
console.log('flip to time span x axis');
chart_ops_support_times.xAxis[0].categories = time_span_bkts;
chart_ops_support_times.series[0].update({
dataLabels: {
enabled: false
},
series: data[1]
});
chart_ops_support_times.redraw();
}
flipxAxis = !flipxAxis;
});
}
I have put in the swap of datalabels just to test if the update is firing, and it is...

Why Highcharts Animation choppy on mobile device?

I'm making a HTML5 hybrid app for android with Highcharts for my dashboard page.
There are 3 charts in this page, and only less than 10 points in each chart.
The init animation looks smoothly on PC browser(include chrome & firefox), but very choppy on my mobile device(Nexus 7 and MSM8916 CPU phone).
Even i set duration to 2000, it's still choppy.
With jQuery 2.1.3 and Hightcharts 4.1.5.
Could someone tell me the reason and how to improve the performance of Highcharts animation on mobile device?
html code below, i use jquery mobile 1.4.5 for UI framework.
<div data-role="page" data-title="总览" id="overall-page">
<div role="main" class="ui-content no-margin">
<div class="border-chart" id="hdgjChart"></div>
<div class="border-chart" id="sbzxlChart"></div>
<div class="border-chart" id="lsgjChart"></div>
</div>
</div>
js code below:
$(document).on("pageshow", "#overall-page", function() {
// Draw first Charts.
$('#hdgjChart').highcharts({
credits: {
enabled: false
},
chart: {
type: 'column',
//pinchType: 'xy',
//zoomType: 'xy',
//panning: true
},
title: {
text: '活动告警',
align: 'left',
margin: 0,
style: { "color": "#004488", "fontSize": "16px" }
},
legend: {
enabled: false
},
xAxis: {
labels: {
enabled: false
},
tickLength: 0
},
yAxis: {
labels: {
enabled: false
},
stackLabels: {
style: {
color: "#004488"
},
enabled: true
},
title: {
text: null
},
tickAmount: 8
},
plotOptions: {
column: {
stacking: 'normal',
animation: {
duration: 2000
}
}
},
tooltip: {
headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>'
},
series: [{
name: '数目',
data: [
{
y: 381,
color: "#f00505",
name: "一级告警"
},
{
y: 25,
color: "#f46700",
name: "二级告警"
},
{
y: 652,
color: "#ffcf05",
name: "三级告警"
},
{
y: 72,
color: "#22a5f2",
name: "四级告警"
}]
}]
});
// Draw second chart
$('#sbzxlChart').highcharts({
credits: {
enabled: false
},
chart: {
type: 'pie',
spacingBottom: 0
},
title: {
text: '<span style="color:#004488;font-size:16px">设备在线率</span><span style="color:#004488;font-size:12px">--总设备数:78</span>',
align: 'left',
margin: 0
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
legend: {
align: 'right',
verticalAlign: 'top',
floating: true,
itemDistance: 10,
borderRadius:3,
borderWidth: 1
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
format: '{point.y}个,{point.percentage:.1f} %',
style: {
color: "#004488"
}
},
innerSize: '50%',
point: {
events: {
legendItemClick: function(e) {
e.preventDefaut();
}
}
},
animation: {
duration: 2000
}
}
},
series: [{
name: '数目',
data: [
{
y: 31,
color: "#00ff00",
name: '在线'
},
{
y: 47,
color: "#959595",
name: '中断'
}
],
showInLegend: true
}]
});
// Draw third chart
$('#lsgjChart').highcharts({
credits: {
enabled: false
},
chart: {
type: 'areaspline',
spacingBottom: 0,
//pinchType: 'x',
//zoomType: 'x',
//panning: true
},
title: {
text: '<span style="color:#004488;font-size:16px">历史告警数量</span><span style="color:#004488;font-size:12px">--最近7天</span>',
align: 'left',
margin: 7
},
tooltip: {
headerFormat: "",
pointFormat: '{point.y}'
},
legend: {
align: 'right',
verticalAlign: 'top',
floating: true,
borderRadius:3,
borderWidth: 1
},
xAxis: {
gridLineWidth: 1,
tickAmount: 7,
tickInterval: 1
},
yAxis: {
stackLabels: {
enabled: true,
useHTML: true,
y: -12,
formatter: function() {
return '<span style="background-color:#0d61be;color:white;font-weight:normal">' + this.total + '</span>';
}
},
title: {
text: null
},
tickAmount: 7
},
plotOptions: {
areaspline: {
stacking: 'normal',
pointStart: 1,
color: '#0d61be',
events: {
legendItemClick: function(e) {
e.preventDefault();
}
},
animation: {
duration: 2000
}
}
},
series: [{
name: '总告警数',
data: [150, 450, 300, 550, 300, 300, 100]
}]
});
});
When I made a simple highcharts test html page, and run it on mobile chrome browser, it runs smoothly.
But when simple packaged it to hybrid android app, using OS WebView & Crosswalk, It runs choppy still.(intel XDK)
I tested a canvas based js chart lib, Chart.js, It's choppy also when hybrid app.
So, I think it's the problem of VebView or Phonegap.
I'm finding the reason now, and will update the issue when I solved it.
Thanks all.

How to retain the conditional color of bar in highcharts

I am filling the bar of the chart to particular color at specific conditions but at its mouse hover over the bar it is regaining its original color.
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Title',
style: { fontSize: '17px', color: 'Black', fontWeight: 'bold', fontfamily: 'Times New Roman' }
},
subtitle: {
text: ''
},
xAxis: {
categories: [
'AT',
'KW',
'ND',
'IT'
]
},
yAxis: {
min: 0,
title: {
text: 'Attributes Scores'
}
},
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} </b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0,
borderWidth: 0,
minPointLength: -200
}
},
series: [{
name: 'YTD',
color: "#4F81BD",
data: [67, 66, 87, 60]
// data: eval('(' + seriesYTD + ')')
}, {
name: 'MAY',
color: "#BFBFBF",
data: [65, 65, 57, 70]
}, {
name: 'JUNE',
color: "#92D050",
data: [61, 77, 47, 94]
}],
exporting: {
enabled: false
}
}, function (chart) {
var ct = 0;
var minArray = new Array();
$.each(chart.series[0].data, function (i, data) {
min = data.y;
minArray[ct] = data.y;
// alert(minArray[ct]);
ct = ct + 1;
});
ct = 0;
$.each(chart.series[2].data, function (i, data) {
// alert('1: '+ data.y + ' - 2: '+ minArray[ct]);
if (data.y < minArray[ct])
data.graphic.attr({
fill: 'red'
});
else
data.graphic.attr({
fill: '#92D050'
});
ct = ct + 1;
});
});
});
Please see the code on this jsfiddle
Please suggest how to resolve this problem so that after tooltip view, the changed color i.e. red retain on specific bars.
Try to use point.update which will affect point options, not only actual state/color of that point, see: http://jsfiddle.net/NWmKL/3/

remove grid line on chart

I have the charts of lib HighCharts and I want to remove the gridline of yAxis on charts
I write gridLineWidth: 0
but gridlines are not removing
All code:
<script type="text/javascript">
(function($){ // encapsulate jQuery
$(function() {
Highcharts.setOptions({
lang: {
rangeSelectorZoom: 'Маcштаб',
rangeSelectorFrom: 'От',
rangeSelectorTo: 'До',
thousandsSep: ' '
},
global: {
useUTC: false
}
});
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
// Create the chart
window.chart = new Highcharts.StockChart({
chart : {
borderColor: 'white',
renderTo : <?php echo "cont".$i; ?>,
backgroundColor: '#f9f9f9' // Сделаем слегка серый фон
},
rangeSelector: {
buttons: [
{
type: 'week',
count: 1,
text: 'Неделя',
},
{
type: 'month',
count: 1,
text: 'Месяц',
},
{
type: 'year',
count: 1,
text: 'Год'
},
{
type: 'all',
text: 'Всё'
}],
inputDateFormat: '%d.%m.%Y', // Меняем на привычный для нас формат даты в интервалах
inputEditDateFormat: '%d.%m.%Y',
buttonTheme: {
width: 43 // Увеличим ширину кнопки
},
selected: 1 // Какая кнопка выбрана по умолчанию
},
yAxis: [{
gridLineWidth: 0,
plotBands: [{
color: 'rgba(1, 143, 189, 1)',
from: -2,
to: 11
},
{
color: 'rgba(157, 200, 5, 1)',
from: 11,
to: 21
},
{
color: 'rgba(202, 1, 94, 1)',
from: 21,
to: 50
}],
title: {
text: 'Позиции'
},
startOnTick: false,
// min: 1,
showFirstLabel: true,
showLastLabel: true,
reversed: true,
tickPositioner: function(min, max) {
// specify an interval for ticks or use max and min to get the interval
var interval = Math.round((max-min)/5);
// push the min value at beginning of array
var dataMin=this.dataMin;
var dataMax=this.dataMax;
var positions = [dataMin];
var defaultPositions = this.getLinearTickPositions(interval, dataMin, max);
//push all other values that fall between min and max
for (var i = 0; i < defaultPositions.length; i++) {
if (defaultPositions[i] > dataMin && defaultPositions[i] < dataMax) {
positions.push(defaultPositions[i]);
}
}
// push the max value at the end of the array
positions.push(dataMax);
return positions;
},
//changed min valuereversed: true
}],
navigator: {
enabled: false,
maskFill: 'rgba(255, 255, 255, 0.45)',
//margin: 20,
series: {
type: 'areaspline',
color: 'rgba(255, 255, 255, 0.00)',
fillOpacity: 0.4,
dataGrouping: {
smoothed: false
},
lineWidth: 2,
lineColor: '#e9cc00',
marker: {
enabled: false
},
shadow: true
},
yAxis: {
reversed: true
}
},
xAxis : {
gridLineWidth: 0,
type: 'datetime',
title : {
text : ' '
},
},
title : {
//text : 'Позиции сайта'
},
legend: {
enabled: true,
align: 'center',
itemWidth: 234, // указал ширину, чтобы выводились сайты в 4 колонки
verticalAlign: 'top'
},
series : [{
lineColor: 'white',
name : 'Позиция в яндексе',
id : 'dataseries',
data : <?php echo $d ?>,
tooltip: {
backgroundColor: 'rgba(250, 250, 250, .85)', // Фон немного темнее
borderColor: 'rgba(100, 100, 100, .90)', // Цвет границы (по умолчанию меняется автоматом)
xDateFormat: '%d.%m.%Y %H:%M', // Наш формат даты
// Тут немного увеличиваем размер даты
headerFormat: '<span style="font-size: 12px">{point.key}</span><br/>',
// Формат надписей в подсказке, названия цветом графика, а значения жирным
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b><br/>',
//valueDecimals: 2
}
}]
});
});
});
})(jQuery);
</script>
The problem is not the gridLineWidth. You've set that correctly.
In addition you need to set the minorGridLineWidth that you have to set to 0
Working demo
If you doesn't want to touch the config object, you just hide the grid by css:
.chart-container .highcharts-grid {
display: none;
}
you just need to gridLineWidth set to 0
yAxis: {
min:0,
categories: ["","Low","Medium","High"],
tickWidth: 0,
crosshair: false,
lineWidth: 0,
gridLineWidth:0,//Set this to zero
title: '',
labels: {
formatter: function () {
return this.value;labels
}
},
showEmpty: false
}
None of the mentioned solutions worked for me, so this one finally worked (taken from Sparklines examples: https://www.highcharts.com/demo/sparkline):
yAxis: {
startOnTick: false,
endOnTick: false,
tickPositions: [],
}
for all other lines here is what worked for me, in some cases using line transparency as the color was the only solution I could find.
$(function() {
$('#container').highcharts({
colors: ['#00f900', '#ffff3c', '#ff2600'],
credits: {
enabled: false
},
exporting: {
enabled: false
},
legend: {
itemDistance: 60
},
lineColor: 'red',
chart: {
type: 'column',
backgroundColor: 'transparent'
},
title: {
text: ''
},
legend: {
itemStyle: {
color: 'white',
fontWeight: 'normal',
fontFamily: 'helvetica',
fontSize: '12px'
}
}
// ....rest in js fiddle
http://jsfiddle.net/fv50sLkj/23/

Resources