Select which chart data category to show versus omit - highcharts
In the following webpage, https://betterbuildingssolutioncenter.energy.gov/energy-data/District%20of%20Columbia , the highchart next to "Portfolio Energy Performance", clicking on the legend icon "Public" omits the public data and only shows the private data. How can I reverse this, so that clicking on the "Public" legend icon omits the private data instead? I have attached the code used for this webpage.
// color declarations
var colorGreen = '#0b6a39',
colorBlue = '#0c4489',
colorBlueLight = '#558ed5',
colorGray = '#595959',
font = 'avenir';
// graph data variables
// Portfolio Energy Performance
var /* title */ energyPerformanceTitle = 'Average Annual % Improvement by Reporting Period',
/* columns */ energyPerformanceCategories = ['2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019'],
/* Y max */ energyPerformanceYMax = 9,
/* X title */ energyPerformanceXaxis = [''],
/* Y title */ energyPerformanceYaxis = ['Average Annual % Improvement'],
/* column colors */ energyPerformanceColumns = [colorBlue, colorBlue, colorBlue, colorBlue, colorBlue, colorBlue, colorBlue, colorBlue],
/* column data */ energyPerformanceData = [8.53, 3.31, 2.37, 2.91, 2.86, 2.63, 2.4, 0.34],
/* goal data */ energyPerformanceGoalData = 2;
// Energy Performance by Facility
var /* title */ energyFacilityTitle = 'Number of Properties by Cumulative % Improvement',
/* columns */ energyFacilityCategories = ['<=0%', '0-2%', '2-6%', '6-10%', '10-15%', '>15%'],
/* X title */ energyFacilityXaxis = ['Cumulative % Improvement Category'],
/* Y title */ energyFacilityYaxis = ['Number of Properties'],
/* Y interval */ energyFacilityYinterval = 10,
/* column colors */ energyFacilityColumns = [colorBlue, colorGreen, colorGreen, colorGreen, colorGreen, colorGreen, colorGreen],
/* column data */ energyFacilityData = [82, 14, 28, 16, 35, 101];
// Identifying Opportunities for Improvement
var /* title */ improvementOpportunityTitle = '% Improvement vs. Baseline EUI',
/* columns */ improvementOpportunityCategories = ['0', '200', '400', '600', '800'],
/* X min */ improvementOpportunityXMin = 0,
/* X max */ improvementOpportunityXMax = 800,
/* Y min */ improvementOpportunityYMin = -60,
/* Y max */ improvementOpportunityYMax = 100,
/* Y interval */ improvementOpportunityYinterval = 20,
/* X interval */ improvementOpportunityXinterval = 200,
/* X title */ improvementOpportunityXaxis = ['Baseline Source EUI (kBtu/sq.ft.)'],
/* Y title */ improvementOpportunityYaxis = ['% Improvement'],
/* scatter data */ improvementOpportunityData = [[704,76], [55,-273], [216,10], [205,6], [505,12], [167,4], [147,-7], [254,-14], [307,19], [275,36], [179,-4], [146,-16], [324,17], [225,19], [146,5], [199,18], [162,4], [183,26], [208,20], [187,-13], [187,19], [145,49], [172,24], [206,25], [208,-35], [222,16], [221,19], [145,18], [151,10], [159,-13], [221,20], [150,26], [215,38], [152,11], [158,-17], [174,9], [249,28], [166,12], [231,3], [165,15], [132,16], [217,3], [163,1], [225,3], [151,20], [149,-9], [164,5], [149,-3], [193,30], [177,10], [246,-20], [155,4], [184,17], [200,7], [132,10], [162,12], [149,19], [252,23], [142,-16], [165,10], [230,-2], [180,16], [193,29], [185,5], [61,49], [226,66], [128,46], [141,76], [190,2], [194,24], [217,10], [127,3], [216,15], [89,-23], [137,-9], [162,33], [171,7], [136,19], [190,-6], [155,18], [93,-35], [147,-20], [199,7], [141,14], [177,7], [276,-16], [103,-2], [172,20], [90,-24], [153,17], [184,10], [149,34], [240,-5], [163,-15], [122,-10], [160,-22], [236,16], [139,5], [183,22], [165,12], [141,22], [114,-39], [175,16], [164,26], [141,16], [186,28], [160,-14], [148,14], [231,15], [204,-9], [170,6], [112,-4], [170,27], [191,17], [216,-1], [215,12], [166,19], [131,-13], [109,15], [181,4], [300,28], [210,13], [236,15], [183,19], [144,14], [198,3], [219,-14], [291,12], [169,19], [194,-8], [208,-16], [304,3], [208,0], [195,-5], [175,17], [143,-1], [161,15], [194,-10], [121,-3], [117,21], [189,0], [136,10], [189,-7], [150,-32], [308,-1], [136,-1], [253,-2], [121,25], [427,2], [222,20], [150,-2], [254,33], [284,38], [307,3], [249,26], [178,6], [134,-22], [282,-4], [151,-10], [143,-3], [116,-6], [158,7], [161,16], [260,55], [131,15], [246,3], [113,-3], [209,22], [322,21], [245,39], [197,14], [142,5], [253,23], [197,-9], [184,15], [169,12], [187,12], [132,-21], [195,16], [143,6], [145,-10], [200,35], [142,5], [178,28], [271,21], [140,-29], [125,6], [148,-15], [185,18], [163,36], [173,13], [117,-2], [291,23], [168,-8], [196,26], [202,13], [169,22], [142,-37], [142,-32], [211,22], [165,5], [181,30], [140,0], [126,-15], [410,14], [167,-17], [205,13], [171,-6], [197,24], [167,15], [115,0], [160,31], [164,13], [176,11], [169,23], [153,25], [542,16], [138,-12], [143,-25], [228,-1], [95,10], [147,-14], [200,8], [195,1], [178,12], [192,20], [152,11], [224,1], [150,-2], [247,12], [208,36], [134,-18], [231,-4], [248,-1], [217,-2], [164,22], [288,0], [201,15], [149,26], [206,33], [179,23], [151,22], [168,14], [165,5], [176,12], [145,-15], [103,-40], [163,5], [141,-9], [128,9], [177,30], [238,17], [182,10], [198,23], [147,-8], [205,29], [528,-8], [205,16], [164,15], [163,39], [193,1], [173,-1], [168,30], [233,6], [117,2], [205,13], [110,7], [161,15], [159,4], [197,2], [131,0], [231,-37], [248,0], [140,0], [155,-9], [153,-2],],
/* trendline data */ improvementOpportunityTrendLine = [[55, -5], [704, 54]];
// On document ready, call visualize on the datatable.
jQuery(document).ready(function () {
Highcharts.visualize = function (table, options) {
// the categories
options.xAxis.categories = energyPerformanceCategories;
options.colors = energyPerformanceColumns,
options.series = [{
type: 'column',
name: ['Public'],
data: energyPerformanceData,
color: colorBlue,
colorByPoint: false,
dataLabels: {
enabled: false
}
}, {
type: 'column',
name: ['Private'],
data: [3.3, 4.95, 3.68, 3.31, 2.76, 2.99, 2.3, 1.71],
color: colorBlueLight,
colorByPoint: false,
dataLabels: {
enabled: false
},
}];
var chart = new Highcharts.Chart(options);
}
var table = document.getElementById('datatable'),
options = {
chart: {
renderTo: 'energy-performance',
type: 'column'
},
title: {
text: energyPerformanceTitle,
style: {
color: colorGray,
fontFamily: font
}
},
subtitle: {},
plotOptions: {
series: {
shadow: false
},
column: {
borderWidth: 0
}
},
xAxis: {
title: {
text: energyPerformanceXaxis,
style: {
color: colorGray,
fontFamily: font
}
},
tickLength: 0,
lineColor: colorGray,
lineWidth: 1
},
yAxis: {
title: {
text: 'Average Annual % Improvement',
style: {
color: colorGray,
fontFamily: font
}
},
tickInterval: 1,
tickLength: 5,
tickWidth: 1,
tickColor: colorGray,
max: energyPerformanceYMax,
lineColor: colorGray,
lineWidth: 1,
gridLineWidth: 0,
plotLines: [{
color: colorGray,
width: 2,
value: energyPerformanceGoalData,
zIndex: 5,
label: {
text: 'GOAL',
align: 'right',
x: 11,
y: -5,
style: {
color: colorGray,
fontFamily: font,
fontWeight: 'bold'
}
}
}],
labels: {
style: {
color: colorGray,
fontFamily: font
}
}
},
legend: {
enabled: true
},
legend: {
itemHiddenStyle: {
color: colorBlue,
colorByPoint: false
}
},
credits: {
enabled: false
},
tooltip: {
formatter: function () {
var raw = ((this.y / energyPerformanceData[0])) * 100,
percentage = Math.round(100 - (raw * 100) / 100);
if (this.y === energyPerformanceData[0] && this.key === '2012') {
return '<strong>' + this.series.name + '</strong><br/>' + '<strong>' + this.x + '</strong>: ' + Highcharts.numberFormat(this.y, 1) + '%';
} else {
return '<strong>' + this.series.name + '</strong><br/>' + '<strong>' + this.x + '</strong>: ' + Highcharts.numberFormat(this.y, 1) + '%';
}
},
}
};
Highcharts.visualize(table, options);
});
// On document ready, call visualize on the datatable.
jQuery(document).ready(function () {
Highcharts.visualize = function (table, options) {
// the categories
options.xAxis.categories = energyFacilityCategories;
options.colors = energyFacilityColumns,
options.series = [{
type: 'column',
name: energyFacilityYaxis,
data: energyFacilityData,
color: colorGreen,
colorByPoint: true,
dataLabels: {
enabled: false
}
}];
var chart = new Highcharts.Chart(options);
}
var table = document.getElementById('datatable'),
options = {
chart: {
renderTo: 'facility-performance',
type: 'column'
},
title: {
text: energyFacilityTitle,
style: {
color: colorGray,
fontFamily: font
}
},
subtitle: {},
plotOptions: {
series: {
shadow: false
},
column: {
borderWidth: 0
}
},
xAxis: {
title: {
text: energyFacilityXaxis,
style: {
color: colorGray,
fontFamily: font
}
},
tickLength: 0,
lineColor: colorGray,
lineWidth: 1,
labels: {
rotation: -45,
y: 30,
style: {
color: colorGray,
fontFamily: font
}
}
},
yAxis: {
title: {
text: energyFacilityYaxis,
style: {
color: colorGray,
fontFamily: font
}
},
tickInterval: energyFacilityYinterval,
tickLength: 5,
tickWidth: 1,
tickColor: colorGray,
lineColor: colorGray,
lineWidth: 1,
gridLineWidth: 0,
minorTickColor: colorGray,
labels: {
style: {
color: colorGray,
fontFamily: font
}
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
tooltip: {
formatter: function () {
return '<strong>' + this.series.name + '</strong><br/>' + '<strong>' + this.x + '</strong>: ' + this.y;
}
}
};
Highcharts.visualize(table, options);
});
// On document ready, call visualize on the datatable.
jQuery(document).ready(function () {
Highcharts.visualize = function (table, options) {
// the categories
options.xAxis.categories = improvementOpportunityCategories;
options.series = [{
name: improvementOpportunityYaxis,
data: improvementOpportunityData,
color: colorBlue
}, {
type: 'line',
name: 'Trendline',
data: improvementOpportunityTrendLine,
color: colorGray,
width: 1,
marker: {
enabled: false
}
}];
var chart = new Highcharts.Chart(options);
}
var table = document.getElementById('datatable'),
options = {
chart: {
renderTo: 'improvement-opportunities',
type: 'scatter',
zoomType: 'xy'
},
title: {
text: improvementOpportunityTitle,
style: {
color: colorGray,
fontFamily: font
}
},
subtitle: {},
plotOptions: {
series: {
shadow: false
},
scatter: {
marker: {
radius: 3,
symbol: 'diamond',
states: {
hover: {
enabled: true
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
}
}
},
xAxis: {
title: {
text: improvementOpportunityXaxis,
style: {
color: colorGray,
fontFamily: font
}
},
lineWidth: 0,
min: improvementOpportunityXMin,
max: improvementOpportunityXMax,
tickInterval: improvementOpportunityXinterval,
minTickInterval: 25,
tickLength: 0
},
yAxis: {
title: {
text: improvementOpportunityYaxis,
style: {
color: colorGray,
fontFamily: font
}
},
min: improvementOpportunityYMin,
max: improvementOpportunityYMax,
tickInterval: improvementOpportunityYinterval,
tickLength: 5,
tickWidth: 1,
tickColor: colorGray,
lineColor: colorGray,
lineWidth: 1,
gridLineWidth: 0,
plotLines: [{
color: colorGray,
width: 1,
value: 0
}, {
color: colorGray,
width: 1,
value: 0,
zIndex: 5
}]
},
legend: {
enabled: false
},
credits: {
enabled: false
},
tooltip: {
formatter: function () {
return '<strong>' + this.series.name + ':</strong> ' + this.y;
}
}
};
Highcharts.visualize(table, options);
});
Use legendItemClick event and hide/show other series than the clicked one:
plotOptions: {
series: {
events: {
legendItemClick: function() {
this.chart.series.forEach(function(s) {
if (s !== this) {
s.setVisible();
}
}, this);
return false;
}
}
}
}
Live demo: http://jsfiddle.net/BlackLabel/j0eyc625/
API Reference: https://api.highcharts.com/class-reference/Highcharts.Series#setVisible
Related
how to highcharts code new for local to set the values for stacked column
how to highcharts code new for local to set the values for stacked columnhow to highcharts code new for local to set the values for stacked column how to highcharts code new for local to set the values for stacked column how to highcharts code new for local to set the values for stacked column how to highcharts code new for local to set the values for stacked column public options: any = { title: { text: 'Sales of petroleum products March, Norway', align: 'left' }, xAxis: { categories: ['Jet fuel', 'Duty-free diesel', 'Petrol', 'Diesel', 'Gas oil'] }, yAxis: { title: { text: 'Million liter' } }, labels: { items: [{ html: 'Total liter', style: { left: '50px', top: '18px', color: ( // theme Highcharts.defaultOptions.title.style && Highcharts.defaultOptions.title.style.color ) || 'black' } }] }, plotOptions: { column: { stacking: 'percent' // normal or percent }, series: { cursor: 'pointer', point: { events: { click: function () { alert('Category: ' + this.category + ', value: ' + this.y); } } } } }, series: [{ type: 'column', name: '2020', data: [59, 83, 65, 228, 184] }, { type: 'column', name: '2021', data: [24, 79, 72, 240, 167] }, { type: 'column', name: '2022', data: [58, 88, 75, 250, 176] }, { type: 'spline', name: 'Average', data: [47, 83.33, 70.66, 239.33, 175.66], marker: { lineWidth: 2, lineColor: Highcharts.getOptions().colors[3], fillColor: 'white' } }] }; public options1: any = { chart: { zoomType: 'xy' }, colors: ['#7cb5ec', '#91e8e1', '#90ed7d'], title: { text: 'Something ' }, subtitle: { text: 'subsomething' }, xAxis: [{ categories: ['1/1','2/1','3/1','4/1', '5/1', '6/1','7/1','8/1','9/1','10/1','11/1', '12/1', '13/1', '14/1', '15/1'] }], yAxis: [{ // Primary yAxis labels: { format: '{value} %', style: { color: Highcharts.getOptions().colors[1] } }, min: 0, max:100, title: { text: 'Percent', style: { color: Highcharts.getOptions().colors[1] } } }, { // Secondary yAxis title: { text: 'sample', style: { color: Highcharts.getOptions().colors[0] } }, min: 0, max: 100, labels: { format: '{value} %', style: { color: Highcharts.getOptions().colors[0], display:'none' } }, opposite: true }], tooltip: { shared: false }, legend: { layout: 'vertical', align: 'center', x: -0, verticalAlign: 'top', y: 400, floating: true, // backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF' }, plotOptions: { column: { stacking: 'percent' } }, series: [ { name: 'suff1', type: 'column', yAxis: 1, data: [10, 25, 10,30,80, 20, 25, 10,30,80, 20, 25, 10,30,80], tooltip: { valueSuffix: ' %' } }, { name: 'suff2', type: 'column', yAxis: 1, tooltip: { valueSuffix: ' %' }, data: [20, 50, 30,30,10, 30, 50, 30,30,10, 30, 50, 30,30,10] }, { name: 'suff3', yAxis: 1, type: 'column', tooltip: { valueSuffix: ' %' }, data: [30,5, 60, 40, 10, 50,25, 60, 40, 10, 50,25, 60, 40, 10] }, { name: 'NS', type: 'spline', data: [45,55,74,85,81, 45,55,74,85,81, 45,55,74,85,81], tooltip: { valueSuffix: '%' } }] }; Highcharts.chart('container-nps', this.options); import * as Highcharts from 'highcharts'; <div id="container-nps"></div>
Xaxis should get aligned at (0,0) in highcharts
I want to align xaxis line and axis labels at position (0,0) when data contains negative values. ex. consider this fiddle example where negative values bar goes down and xaxis is set at (0,0) http://jsfiddle.net/13d54mp8/2/ var YTD = 'YTD'; var yr1 = 'Year 1'; var yr3 = '*3 Year'; var yr5 = '*5 Year'; var sinceIN = '* Since Inception (5/31/2012)'; $(function() { var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'column', events: { load: function() { var xx = (-1) * (this.yAxis[0].translate(0, false, false)); this.xAxis[0].axisGroup.translate(0, xx); this.xAxis[0].labelGroup.translate(0, xx); } } }, title: { text: 'Report Title', style: { fontSize: '18px', color: '#1D5293', fontWeight: 'bold' }, }, subtitle: { text: '(As of 6/30/2012)', style: { fontSize: '18px', color: '#1D5293' }, y: 40 }, xAxis: { categories: [YTD, yr1, yr3, yr5, sinceIN], lineColor: '#C1BADB', tickWidth: 2, }, yAxis: { title: { text: '' }, lineColor: '#C1BADB', lineWidth: 1, labels: { formatter: function() { return this.value + '%'; } }, gridLineWidth: 0, tickWidth: 2 }, tooltip: { enabled: true, formatter: function() { return this.series.name + ': ' + this.y + '%'; }, }, credits: { enabled: false }, series: [{ name: 'XXX Company Ltd. (Net)', data: [3.02, -0.61, 2.03, 1.51, 5.35], dataLabels: { enabled: true, color: '#333', formatter: function() { return this.y + '%' } }, color: '#1D5293' }, { name: 'XXX Relative Return Index (Gross)**', data: [2.45, 0.85, 4.11, 0.73, 3.56], dataLabels: { enabled: true, color: '#333', formatter: function() { return this.y + '%' } }, color: '#9E9E9E' } ], legend: { layout: 'vertical', align: 'top', verticalAlign: 'top', x: 50, y: 65, borderWidth: 0, margin: 30 }, }); }); }); Now I want to make work the same use case for inverted column chart where xaxis is on top and yaxis is at right side. check fiddle - http://jsfiddle.net/fa2e80qu/3/ var YTD = 'YTD' var yr1 = 'Year 1' var yr3 = '*3 Year' var yr5 = '*5 Year' var yr7 = '*7 Year' var yr9 = '*9 Year' var sinceIN = '* Since ' $(function() { var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'column', events: { load: function() { var xx = (0.34)* (this.yAxis[0].translate(0, false, false)); this.xAxis[0].axisGroup.translate(0, xx); this.xAxis[0].labelGroup.translate(0, xx); } } }, title: { text: 'Report Title', style: { fontSize: '18px', color: '#1D5293', fontWeight: 'bold' }, }, subtitle: { text: '(As of 6/30/2012)', style: { fontSize: '18px', color: '#1D5293' }, y: 40 }, xAxis: { categories: [YTD, yr1, yr3, yr5, yr7,yr9, sinceIN], lineColor: '#C1BADB', tickWidth: 2, opposite:true }, yAxis: { opposite:true, reversed:true, title: { text: '' }, lineColor: '#C1BADB', lineWidth: 1, labels: { formatter: function() { return this.value + '%'; } }, gridLineWidth: 0, tickWidth: 2 }, tooltip: { enabled: true, formatter: function() { return this.series.name + ': ' + this.y + '%'; }, }, credits: { enabled: false }, series: [ { name: 'XXX Company Ltd. (Net)', data: [3.02, -0.61, 2.03, 1.51, 5.35, -0.50,2.5], dataLabels: { enabled: true, color: '#333', formatter: function() { return this.y + '%' } }, color: '#1D5293'}, { name: 'XXX Relative Return Index (Gross)**', data: [2.45, 0.85, 4.11, 0.73, 3.56,-0.5,1.6], dataLabels: { enabled: true, color: '#333', formatter: function() { return this.y + '%' } }, color: '#9E9E9E'} ], legend: { enabled:false, layout: 'vertical', align: 'top', verticalAlign: 'top', x: 50, y: 65, borderWidth: 0, margin: 30 }, }); }); }); Expected behavior is to have xaxis line and labels aligns properly at position (0,0)
You can use the toPixels method: chart: { ..., events: { load: function() { var xx = this.yAxis[0].toPixels(0) - this.plotTop; this.xAxis[0].axisGroup.translate(0, xx); this.xAxis[0].labelGroup.translate(0, xx); } } } Live demo: http://jsfiddle.net/BlackLabel/07rej16z/ API Reference: https://api.highcharts.com/class-reference/Highcharts.Axis#toPixels
highcharts Unable to create plotbands
Im trying to create plotbands but does not work correctly. Here is my fiddle and code. https://jsfiddle.net/z0h85fku/ Javascript $(function() { categories = ["09/07/2016 00:00", "09/07/2016 00:01", "09/07/2016 00:02", "09/07/2016 00:03", "09/07/2016 00:04"] rate_1 = [0.8, 0.54, 0.6, 0.3, 0.4] rate_2 = [0.33, 0.16, 0.33, 0.3, 0.38] rate_3 = [0.03, 0.04, 0.05, 0.03, 0.01] var addCallout = function(chart) { $('.callout').remove(); var xAxis = chart.xAxis[0], yAxis = chart.yAxis[0], series = chart.series[0], point = series.data[0]; console.log('xAxis == ', xAxis) console.log('yAxis == ', yAxis.toPixels) console.log('series == ', series) console.log('point == ', point) console.log(point.plotY) console.log(point.plotX) var a = chart.renderer.label('<div class="callout top">This is the callout text!</div>', point.plotX + chart.plotLeft - 20, point.plotY + chart.plotTop - 70, 'callout', null, null, true).add(); }; $('#container').highcharts({ chart: { // type: 'bar', events: { load: function() { addCallout(this); }, redraw: function() { addCallout(this); }, } }, title: { text: 'Spikes Graph', x: -20 //center }, subtitle: { text: '', x: -20 }, events: { load: function() { // addCallout(this); }, redraw: function() { addCallout(this); }, }, series: [{ turboThreshold: 2000 // to accept point object configuration }], xAxis: { categories: categories, <!-- tickInterval: 60,--> plotBands: [{ color: 'orange', // Color value // from: Date.UTC(09/07/2016 02:00), // Start of the plot band // Date.UTC(year,month,day,hours,minutes,seconds,millisec) from: Date.UTC(2016,9,7,0,0), to: Date.UTC(2016,9,7,4,0) // to: '09/07/2016 05:00' // End of the plot band }], type:'datetime' }, yAxis: { title: { text: 'Error Rate' }, min: 0, max: 5, plotLines: [{ value: 0, width: 1, color: '#808080' }], labels: { format: '{value} %' } }, tooltip: { valueSuffix: '°C' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: [ // {turboThreshold: 2000 }, { name: 'Rate-1', data: rate_1, turboThreshold: 2000, lineWidth: 1, dataLabels: { enabled: true, useHTML: true, style: { fontWeight: 'bold' }, }, }, { name: 'Rate-2', data: rate_2, turboThreshold: 2000, lineWidth: 1 }, { name: 'Rate-3', data: rate_3, turboThreshold: 2000, lineWidth: 1 } ] }); });
Highstocks Line Chart: Using fixed tooltips on top of point markers
I am using Area chart with navigator, what I am trying to do is highlight high and Low point markers (only two points ) in the current visible chart, and on top of these markers I want to display fixed tooltips displaying the point information. And as user navigates through navigator these point markers should be recalculated and tooltips should follow them. [This is what I am trying to accomplish][1] So far I have been able to calculate high and low points and highlight corrosponding markers in chart, and I have also been able to display two tooltips, but they are not ACURATELY positioned along with point markers. ![So far this has been accomplished][2] Here is my Code: function customTooltip(point) { console.log(chart); var text = chart.renderer.text( 'Max', point.plotX + chart.plotLeft + 10, point.plotY + chart.plotTop - 10 ).attr({ zIndex: 5 }).add(); var box = text.getBBox(); chart.renderer.rect(box.x - 5, box.y - 5, box.width + 10, box.height + 10, 5) .attr({ fill: '#FFFFEF', stroke: 'gray', 'stroke-width': 1, zIndex: 4 }) .add(); } var labelArr = [], // keeps Tooltips for High and Low chart = $('#container').highcharts('StockChart', { chart: { type: 'line', width: 900 }, scrollbar: { enabled: false }, navigator: { top: -1, height: 25, handles: { backgroundColor: 'transparent', borderColor: 'transparent' } }, rangeSelector: { inputPosition: { align: 'left', x: 10, y: 30 }, buttons: [{ type: 'year', count: 1, text: '' }], buttonTheme: { // styles for the buttons fill: 'none', stroke: 'none', 'stroke-width': 0, states: { hover: { fill: 'none' }, select: { fill: 'none' } } }, inputDateFormat: '%m-%d-%Y', inputStyle: { fontSize: '14px', borderColor: '#FFF' }, selected: 0 }, yAxis: { labels: { align: 'right', x: -5, formatter: function () { return "$" + this.value; } } }, xAxis: { type: 'datetime', tickWidth: 0, labels: { y: 20 }, dateTimeLabelFormats: { month: '%B' }, events: { setExtremes: function () { var pointMax, pointMin, labelLength = labelArr.length; // Flush out Old Tooltips for High and Low if (labelLength > 0) { for (var i = 0; i < labelLength; i++) { var popVal = labelArr.pop(); this.chart.container.firstChild.removeChild(popVal); } } $.each(this.series[0].points, function (i, point) { if (!pointMax && !pointMin) pointMax = pointMin = point; // If marker is enabled for any point, disable it if (typeof point.marker != 'undefined') point.marker.enabled = false; // Calculate Highest point if (pointMax.y < point.y) pointMax = point; // Calculate Lowest point if (pointMin.y > point.y) pointMin = point; }); pointMax.update({ marker: { enabled: true } }, false, false); //customTooltip( pointMax ); pointMin.update({ marker: { enabled: true } }, false, false); //customTooltip( pointMin ); } } }, tooltip: { crosshairs: false /*useHTML: true, borderRadius: 0, backgroundColor: '#000', shadow: false, borderWidth: 0, enabled: true, formatter: function(){ /* Temp Disable Custom tool-Tip var arr = []; $.each(this.points, function(k, obj){ arr.push( "<span style='color:#FFF'>Low price w/o sales charge</span>" ); arr.push( "<br>" ); arr.push( "<span style='font-weight:bold;color:#FFF'>$" + obj.y + "</span>" ); arr.push( "<br>" ); }); return arr.join(' '); } */ }, plotOptions: { area: { marker: { fillColor: '#f7941e', states: { hover: { enabled: false } } } }, series: { point: { events: { update: function (event) { event.target.series.chart.tooltip.refresh([event.target]); var cloneToolTip = event.target.series.chart.tooltip.label.element.cloneNode(true); event.target.series.chart.container.firstChild.appendChild(cloneToolTip); labelArr.push(cloneToolTip); } } } } }, series: [{ name: 'Quarterly Returns w/o sales charge', data: [ [1149120000000, 62.17], [1149206400000, 61.66], [1369699200000, 441.44], [1369785600000, 444.95] ] // pointWidth: 14, }] }).highcharts(); }); Can you please guide me on how to proceed from here?
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/