Highstock (Highcharts) Tooltip without delimiter scale y values - javascript
I'm trying show multiples values in tooltip.
In old version of Highstock (2.0.3) it's working fine!
But in last release, not work =(
Working fine version with highstock-2.0.3:
<!-- ##### !!! HERE - WORKING FINE !!! ##### -->
<script src="http://code.highcharts.com/stock/2.0.3/highstock.js"></script> <!-- OLD Version -->
<!--script src="https://code.highcharts.com/highcharts.js"></script--> <!-- NEW Version -->
<div id="container" style="height: 400px"></div>
$(function () {
$('#container').highcharts({
chart: {
type: 'line',
plotBorderWidth: 0,
backgroundColor: null,
events: {
load: function() {
valueX('#xxx');
}
}
},
xAxis: {
categories: [1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014],
title: {
text: ''
},
labels: {
y: 30,
style: {
fontSize: '13px'
}
}
},
yAxis: {
opposite: false,
gridLineWidth: 0.5,
labels: {
enabled: true,
},
title: {
text: ''
},
min: 0,
max: 85,
startOnTick: false
},
tooltip: {
shared: true,
},
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
},
series: [
{
animation: false,
name: 'A',
min: 0,
max: 1000,
data: [113.000,153.000,156.000,155.000,123.000,109.000,95.000,67.000,111.000,106.000,95.000,88.000,88.000,107.000,90.000,79.000,59.000,65.000,66.000],
type: 'line',
showInLegend: false,
color: 'none', // color 'transparent' não funciona no IE 8
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
tooltip: {
shared: true,
useHTML: true,
pointFormat: '{point.y} AAA <br />',
valueDecimals: 2
}
},
{
animation: false,
name: 'B',
data: [196429.000,192757.000,185378.000,186675.000,179462.000,167270.000,165125.000,157333.000,159636.000,160324.000,153598.000,147554.000,151092.000,149217.000,152051.000,152902.000,153945.000,155758.000,159915.000],
type: 'line',
showInLegend: false,
color: 'none', // color 'transparent' não funciona no IE 8
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
tooltip: {
shared: true,
useHTML: true,
pointFormat: '{point.y} BBB<br/>',
valueDecimals: 2
}
},
{
animation: false,
name: 'C',
data: [57.530,79.370,84.150,90.10,68.540,65.160,57.530,42.580,69.530,66.120,61.850,59.640,58.240,71.710,59.190,51.670,38.330,41.730,41.270],
shared: true,
type: 'line',
lineWidth: 5,
tooltip: {
useHTML: true,
showInLegend: false,
pointFormat: '{point.y} CCC<br/>',
valueDecimals: 2
},
},
{
data: "[null]",
visible: false,
showInLegend: false
}
]
http://jsfiddle.net/mad7a8b1/1/
========================================
Not Working with last version highstock-5.0.1:
<!-- ##### !!! HERE - NOT WORKING !!! ##### -->
<script src="https://code.highcharts.com/highcharts.js"></script> <!-- NEW Version -->
<!--script src="http://code.highcharts.com/stock/2.0.3/highstock.js"></script--> <!-- OLD Version -->
<div id="container" style="height: 400px"></div>
$(function () {
$('#container').highcharts({
chart: {
type: 'line',
plotBorderWidth: 0,
backgroundColor: null,
events: {
load: function() {
valueX('#xxx');
}
}
},
xAxis: {
categories: [1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014],
title: {
text: ''
},
labels: {
y: 30,
style: {
fontSize: '13px'
}
}
},
yAxis: {
opposite: false,
labels: {
enabled: true,
style: {
}
},
title: {
text: ''
},
min: 0,
max: 85,
startOnTick: false
},
tooltip: {
shared: true,
},
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0,
},
series: [
{
animation: false,
name: 'A',
min: 0,
max: 1000,
data: [113.000,153.000,156.000,155.000,123.000,109.000,95.000,67.000,111.000,106.000,95.000,88.000,88.000,107.000,90.000,79.000,59.000,65.000,66.000],
type: 'line',
showInLegend: false,
color: 'none', // color 'transparent' não funciona no IE 8
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
tooltip: {
shared: true,
useHTML: true,
pointFormat: '{point.y} AAA <br />',
valueDecimals: 2
}
},
{
animation: false,
name: 'B',
data: [196429.000,192757.000,185378.000,186675.000,179462.000,167270.000,165125.000,157333.000,159636.000,160324.000,153598.000,147554.000,151092.000,149217.000,152051.000,152902.000,153945.000,155758.000,159915.000],
type: 'line',
showInLegend: false,
color: 'none', // color 'transparent' não funciona no IE 8
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
tooltip: {
shared: true,
useHTML: true,
pointFormat: '{point.y} BBB<br/>',
valueDecimals: 2
}
},
{
animation: false,
name: 'C',
data: [57.530,79.370,84.150,90.10,68.540,65.160,57.530,42.580,69.530,66.120,61.850,59.640,58.240,71.710,59.190,51.670,38.330,41.730,41.270],
shared: true,
type: 'line',
lineWidth: 5,
tooltip: {
useHTML: true,
showInLegend: false,
pointFormat: '{point.y} CCC<br/>',
valueDecimals: 2
},
},
{
data: "[null]",
visible: false,
showInLegend: false
}
]
});
});
http://jsfiddle.net/vtju3n4a/2/
Please: check head includes to view the JSs. ;-)
Thanks!
Related
Hightchart issue, when more then one plot is used on page
I am working on page, where i need to have multiple plots, one being a solid gauge and the other being a line graph. I am using the Ionic Framework 5 with angular and High Charts. I am finding that when one plot is displayed, it works fine, but with more then one I am getting some type of conflict where the line chart does not get updated and the gauge gets data which is meant for the line graph. This my code. Do i need to do anything in perticular? particulate_plot() { let particulte_chart = this.particulte_chart.stockChart('particulate_plot', { chart: { type: 'line', animation: true, backgroundColor: "#464340", }, credits: { enabled: false }, legend: { enabled: true, layout: 'horizontal', verticalAlign: 'bottom', floating: false, }, rangeSelector: { selected: 1, inputEnabled: false, enabled: false }, title: { text: "Particulate Mass Concentration", style: { "color": "#f4f5f8", "fontSize": "12px" } }, xAxis: { type: 'datetime', dateTimeLabelFormats: { day: '%e of %b', }, title: { text: 'Date', style: { "color": "#f4f5f8", "fontSize": "12px" } }, labels: { style: { "color": "#f4f5f8", "fontSize": "12px" } } }, yAxis: { min: 0, opposite: false, title: { text: "Mass \xb5g/m\xb3", style: { "color": "#f4f5f8", "fontSize": "12px" } }, labels: { formatter: function() { return (this.value.toFixed(2) ? '' : '') + this.value.toFixed(2); }, style: { "color": "#f4f5f8", "fontSize": "12px" } }, plotLines: [{ label: { text: "EU Limit 40 \xb5g/m\xb3", style: { "color": "#f4f5f8", "fontSize": "12px" }, align: 'center', y: -10, }, color: 'red', // Color value value: 3, // Value of where the line will appear width: 5 // Width of the line }], }, navigator: { enabled: false }, scrollbar: { enabled: false }, series: [{ boostThreshold: 0, color: '#FFF59D', name: "PM1.0", type: 'spline', data: this.datasets[0].data, showInNavigator: true, visible: false, lineWidth: 1, }, { boostThreshold: 0, color: '#FFAB40', name: "PM2.5", type: 'spline', data: this.datasets_b[0].data, showInNavigator: true, visible: true, lineWidth: 1, }, { boostThreshold: 0, color: '#90CAF9', name: "PM4", type: 'spline', data: this.datasets_c[0].data, showInNavigator: true, visible: false, lineWidth: 1, }, { boostThreshold: 0, color: '#4DD0E1', name: "PM10", type: 'spline', data: this.datasets_d[0].data, showInNavigator: true, visible: false, lineWidth: 1, } ], "tooltip": { "pointFormat": "<b>{point.y:.2f}</b>", "shared": true }, }); } } air_main_gauge() { let maingauge_chart = this.maingauge_chart.stockChart('MainGuageA', { chart: { type: 'solidgauge', backgroundColor: 'white', }, credits: { enabled: false }, pane: { center: ['50%', '50%'], size: '100%', innerSize: '10%', startAngle: -150, endAngle: 150, background: { backgroundColor: HighCharts.defaultOptions.legend.backgroundColor || '#EEE', innerRadius: '85%', outerRadius: '100%', shape: 'arc' } }, lineWidth: 1, tooltip: { enabled: false }, navigator: { enabled: false }, rangeSelector: { selected: 1, inputEnabled: false, enabled: false }, scrollbar: { enabled: false }, // the value axis yAxis: { min: 0, max: 100, // title: { // text: 'Speed' // }, stops: [ [0.1, '#55BF3B'], // green [0.5, '#DDDF0D'], // yellow [0.8, '#ed1f1f'] // red ], minorTickInterval: null, tickPixelInterval: 400, tickWidth: 0, gridLineWidth: 10, gridLineColor: 'transparent', labels: { enabled: false }, title: { enabled: false } }, series: [{ // name: 'Speed', data: [20], dataLabels: { format: '<div style="text-align:center">' + '<span style="font-size:25px">{y}</span><br/>' + '<span style="font-size:12px;opacity:0.4">km/h</span>' + '</div>', position: 'right', }, tooltip: { // valueSuffix: ' km/h' enabled: false } }], plotOptions: { solidgauge: { innerRadius: '85%', dataLabels: { y: -45, borderWidth: 0, useHTML: true } }, }, }); } </ion-row><ion-row class="ion-align-self-start"><!-- <script src="https://code.highcharts.com/highcharts.js"></script>--><script src="https://code.highcharts.com/stock/highstock.js"></script><script src="https://code.highcharts.com/highcharts-more.js"></script><script src="https://code.highcharts.com/modules/solid-gauge.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><div id="particulate_plot" style="width:100%; height:100%;"></div><div id="MainGuageA" style="width: 100%;" class="posi"></div><!-- <ion-item class="leafpostion" lines="none"></ion-item>--><!-- <ion-icon name="leaf" class="leaf"></ion-icon>--></ion-row>
How to show an empty chart in beginning and populate values on button click
I have code from this post. I want to populate the chart on click of a button instead of initializing it and provide only 3 values e.g.22286,12286,9286 ( these values would be dynamic) and plot the chart with the same appearance (i.e. 3 colors chart) as of the snippet Highcharts.chart('container', { colors: ['#762232', '#EFCA32', '#007788'], title: { text: '', }, chart: { type: 'area', backgroundColor: null, // spacingRight: 5, spacingTop: 5, spacingBottom: 5, style: { fontFamily: 'Arial, sans-serif', }, plotBorderWidth: 1, plotBorderColor: '#ccc', }, xAxis: { gridZIndex: 4, gridLineWidth: 1, tickInterval: 1, tickWidth: 0, alignTicks: true, gridLineColor: '#762232', minPadding: 0, maxPadding: 0, title: { text: 'Years Invested', }, labels: { enabled: true, }, }, yAxis: { gridLineWidth: 0, opposite: true, title: { text: 'Hypothetical Value', }, showFirstLabel: false, showLastLabel: false, tickPositioner: function() { var prevTickPos = this.tickPositions, tickPositions = [prevTickPos[0], prevTickPos[prevTickPos.length - 1]], series = this.chart.series; series.forEach(function(s) { tickPositions.push(s.processedYData[s.processedYData.length - 1]); }); tickPositions.sort(function(a, b) { return a - b; }); return tickPositions; }, labels: { enabled: true, align: "right", reserveSpace: true, }, }, tooltip: { enabled: !1, }, plotOptions: { area: { pointStart: 0, stacking: false, lineColor: '#762232', lineWidth: 1, fillOpacity: 1, dataLabels: { crop: !1, color: '#762232', align: 'right', y: 5, }, marker: { enabled: !1, symbol: 'circle', radius: 1, states: { hover: { enabled: !1, }, }, }, }, }, series: [{ data: [4457, 13371, 22286] }, { data: [2457, 9371, 12286] }, { data: [1457, 5371, 9286] }] }); <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> </figure> <button>Populate Chart</button>
All you need to do is to create series with empty data array and use chart.update method to add data. Example: var chart = Highcharts.chart('container', { ..., series: [{ data: [] }, { data: [] }, { data: [] }] }); document.getElementById('chartInit').addEventListener('click', function(){ chart.update({ series: [{ data: [4457, 13371, 22286] }, { data: [2457, 9371, 12286] }, { data: [1457, 5371, 9286] }] }); }); Live demo: https://jsfiddle.net/BlackLabel/8pL6hr3w/ API Reference: https://api.highcharts.com/class-reference/Highcharts.Chart#update
how to display 2 same highcharts without duplicate the code
I have 2 div of same content, I want to display the same pie charts inside the 2 div, however just the first one is showing, I know the idea of duplicate the js code and make the id like #container1, #container2, but is there a way to avoid code duplication. Thank you. Here is the js: $(document).ready(function () { // Build the chart $('#container').highcharts({ chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: '' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: false }, showInLegend: true } }, series: [{ name: 'Brands', colorByPoint: true, data: [{ name: 'Unused', y: 40, color: '#eeeeee', sliced: true, selected: true }, { name: 'Used', y: 60, color: '#ff7900', selected: true }] }] }); $('#container').highcharts({ chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: '' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: false }, showInLegend: true } }, series: [{ name: 'Brands', colorByPoint: true, data: [{ name: 'Unused', y: 40, color: '#eeeeee', sliced: true, selected: true }, { name: 'Used', y: 60, color: '#ff7900', selected: true }] }] }); }); And HTML : <div id='container' style="margin-top:300px">pie1</div> <div id='container' style="margin-top:500px">pie2</div>
You can define the Highchart configuration object once and use it multiple times, like this: $(document).ready(function () { // Using classes to select multiple containers var $containers = $(".container"); // You just set the configuration object once var chartConfig = { chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: '' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: false }, showInLegend: true } }, series: [{ name: 'Brands', colorByPoint: true, data: [{ name: 'Unused', y: 40, color: '#eeeeee', sliced: true, selected: true }, { name: 'Used', y: 60, color: '#ff7900', selected: true }] }] }; // And then for every container init Hightchart with the same object $containers.each(function() { $(this).highcharts(chartConfig); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.highcharts.com/highcharts.src.js"></script> <div id="container1" class="container">pie1</div> <div id="container2" class="container">pie2</div>
Slow loading data highstock
I have trouble with performance of my highstock. All works, but time of plotting of my data is too slow, about 30 seconds. JSON is about 30000 points. Maybe problem in how I draw this data ? I already turn off animation, shadow, marks etc. And here is my JS code: $(function() { Highcharts.setOptions({ global: { useUTC: false, timezoneOffset: - 3 * 60 } }); function requestData() { $.ajax({ url: 'values.php', success: function(series) { chart.addSeries({name: 'Temp1', data: series[0], yAxis:0}, false); chart.addSeries({name: 'Temp2', data: series[1], yAxis:0}, false); chart.redraw(); }, cache: false }); } chart = new Highcharts.StockChart({ chart: { animation: false, zoomType: 'xy', renderTo: 'container', events: { load: requestData } }, title: { text: 'Temperatures from DS18B20', x: -20 }, plotOptions: { spline: { turboThreshold: 50000 } }, rangeSelector: { allButtonsEnabled: true, buttons: [{ type: 'minute', count: 10, text: '10min' }, { type: 'minute', count: 30, text: '30min' }, { type: 'all', text: 'all' }], buttonTheme: { width:60 }, selected: 2 }, xAxis: { type: 'datetime', categories: true, ordinal: false, // tickInterval: 100*3600, minTickInterval:100000, labels: { align: 'center', formatter:function(){ return Highcharts.dateFormat('%H:%M:%S',this.value); } } }, yAxis: { labels: { format: '{value}°C', style: { color: Highcharts.getOptions().colors[0] } }, title: { text: 'Temperature', style: { color: Highcharts.getOptions().colors[0] } }, opposite: false }, legend: { enabled: true, align: 'right', backgroundColor: '#DBFFDB', borderColor: 'black', borderWidth: 2, layout: 'vertical', verticalAlign: 'top', y: 200, shadow: true }, tooltip: { shared: true }, series: [] }); });
How can I remove the white border from HighCharts pie chart?
I am using High-charts to show pie charts, can any one tell me how can I remove this white border around the radius. My code is given below also the screen shot image of chart. I have no lot of experience with high-charts if anyone know this please help me. The documentation is also very tough to read and understand $(function () { $('#cashflow_graph').highcharts({ chart: { type: 'pie', backgroundColor:'red', }, title: { text: false }, yAxis: { title: { text: false } }, plotOptions: { pie: { dataLabels: { enabled: false }, shadow: false, center: ['50%', '50%'] }, series: { states: { hover: { enabled: false, halo: { size: 0 } } } }, }, credits: { enabled: false }, tooltip: { enabled: false, valueSuffix: '%' }, series: [{ name: 'Cash Flow', data: [ { name: 'Incoming', y: 40, color: '#87b22e' }, { name: 'Outgoing', y: 30, color: 'black' }, { name: '', y: 30, color: 'white' } ], size: '80%', innerSize: '80%', dataLabels: { enabled: false, formatter: function () { return false; } } }] }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts-more.src.js"></script> <div id="cashflow_graph" style="height: 300px; width:100%;"></div>
You need to set the plotOptions.pie.borderWidth property to 0: $(function() { $('#cashflow_graph').highcharts({ chart: { type: 'pie', backgroundColor: 'red', }, title: { text: false }, yAxis: { title: { text: false } }, plotOptions: { pie: { dataLabels: { enabled: false }, shadow: false, center: ['50%', '50%'], borderWidth: 0 // < set this option }, series: { states: { hover: { enabled: false, halo: { size: 0 } } } }, }, credits: { enabled: false }, tooltip: { enabled: false, valueSuffix: '%' }, series: [{ name: 'Cash Flow', data: [{ name: 'Incoming', y: 40, color: '#87b22e' }, { name: 'Outgoing', y: 30, color: 'black' }, { name: '', y: 30, color: 'white' } ], size: '80%', innerSize: '80%', dataLabels: { enabled: false, formatter: function() { return false; } } }] }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/4.1.5/highcharts-more.src.js"></script> <div id="cashflow_graph" style="height: 300px; width:100%;"></div>