score:2
Accepted answer
Here modified_data
is the data object containing additional data need for displaying exta information in tooltip
var newseries;
$.each(jsond, function(i, item) {
var modified_data = [];
$.each(item.data, function(j) {
modified_data.push({
y: item.data[j],
android: item.android[j]
})
})
newseries = {};
newseries.name = item.name;
newseries.data = modified_data;
//newseries.android = item.android;
options.series.push(newseries);
});
Tooltip formatter
formatter: function() {
var s = '<b>' + Highcharts.dateFormat('%H:%M',
new Date(this.x)) + '</b>';
$.each(this.points, function() {
//console.log(this)
s += '<br/>' + this.series.name + ': ' +
this.y + 'm' + '<br/>' + 'Android' + ': ' +
this.point.android + 'm';
});
return s;
},
Fiddle Snippet
$(function() {
var hour = 3600 * 1000;
var options = {
chart: {
renderTo: 'container',
type: 'line',
options3d: {
enabled: true,
alpha: 0,
beta: 0,
depth: 0,
viewDistance: 25
}
},
title: {
text: ''
},
subtitle: {
text: ''
},
legend: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
labels: {
align: 'left',
style: {
color: '#423D3C',
fontWeight: 'normal',
fontFamily: 'Open Sans'
}
},
showLastLabel: false,
tickmarkPlacement: 'on',
tickPosition: 'inside',
tickWidth: 0,
tickPixelInterval: 60,
lineWidth: 2,
lineColor: '#423D3C',
maxPadding: 0,
minPadding: 0,
gridLineWidth: 0,
offset: 0,
startOnTick: true,
type: 'datetime',
dateTimeLabelFormats: {
day: '%H:%M'
},
endOnTick: true
},
yAxis: {
tickPositioner: function() {
var maxDeviation = Math.ceil(Math.max(Math.abs(this.dataMax), Math.abs(this.dataMin)));
var halfMaxDeviation = Math.ceil(maxDeviation / 2);
return [0, halfMaxDeviation, maxDeviation];
},
title: {
text: "user"
}
},
tooltip: {
backgroundColor: '#1B1A1A',
borderColor: '#1B1A1A',
crosshairs: true,
shadow: false,
style: {
color: 'white',
fontSize: '12px',
padding: '8px'
},
enabled: true,
crosshairs: false,
shared: false,
snap: 30,
formatter: function() {
var s = '<b>' + Highcharts.dateFormat('%H:%M',
new Date(this.x)) + '</b>';
$.each(this.points, function() {
//console.log(this)
s += '<br/>' + this.series.name + ': ' +
this.y + 'm' + '<br/>' + 'Android' + ': ' +
this.point.android + 'm';
});
return s;
},
shared: true
},
plotOptions: {
line: {
//dashStyle: 'ShortDot',
lineWidth: 2
},
series: {
pointStart: 0 * hour,
pointInterval: hour,
},
dataGrouping: {
enabled: false
},
marker: {
enabled: false,
states: {
hover: {
enabled: true
}
},
symbol: 'circle'
},
},
series: [],
};
var jsond = [{
"name": "Today",
"data": [17, 5, 27, 0, 28, 0, 27, 0, 25, 0, 27, 28, 26, 0, 0, 0, 60, 0,
46, 0, 0, 0, 0, 0
],
"android": [0, 0, 13, 0, 14, 0, 8, 0, 12, 0, 20, 0, 22, 0, 17, 19, 0, 0,
0, 0, 0, 0, 20, 21
]
}, {
"name": "Yesterday",
"data": [0, 0, 0, 0, 22, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36,
48, 0, 38, 30
],
"android": [17, 5, 27, 0, 28, 0, 27, 0, 25, 0, 27, 28, 26, 0, 0, 0, 60, 0,
46, 0, 0, 0, 0, 0
]
}, {
"name": "Week_ago",
"data": [0, 0, 13, 0, 14, 0, 8, 0, 12, 0, 20, 0, 22, 0, 17, 19, 0, 0, 0,
0, 0, 0, 20, 21
],
"android": [0, 0, 0, 0, 22, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36,
48, 0, 38, 30
]
}]
//$.getJSON('data.json', function(list) {
var newseries;
$.each(jsond, function(i, item) {
var modified_data = [];
$.each(item.data, function(j) {
modified_data.push({
y: item.data[j],
android: item.android[j]
})
})
newseries = {};
newseries.name = item.name;
newseries.data = modified_data;
//newseries.android = item.android;
options.series.push(newseries);
});
var chart = new Highcharts.Chart(options);
//console.log( options.series);
});
//});
/*
*/
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="width: 50%;min-width: 310px; height: 400px; margin: 0 auto"></div>
score:1
It is the problem with your data.json
file. Check the highcharts documentation. Change your value in the formats mentioned in documentation. For eg:
[
{
"name":"Today",
"data":[[17,0],[5,0], [27,13], [0,0], [28,14], [0,0], [27,8], [0,0], [25,12], [0,0], [27,20], [28,0], [26,22], [0,0], [0,17], [0,19], [60,0], [0,0], [46,0], [0,0], [0,0], [0,0], [0,20], [0,21]]
}
]
and change the tooltip formatter function according to this.
Source: stackoverflow.com
Related Query
- how to pass values to tooltip which not in x and y axis in highcharts
- How to make the Y Axis values not start from 0 in highcharts? How to display forcefully display the last category data on X axis in HighCharts ?
- How to show values in Highcharts tooltip other than x and y when data points are too high?
- How to represent a point which is outside range of x and y axis in highcharts
- Highcharts how to use column title as X axis and not as Legend
- Color columns based on x axis and not on values (y axis) in highcharts
- highcharts pass multiple values to tooltip
- Highcharts - How to programmatically toggle legend items and determine which items are selected
- Highcharts - How to hide series name and Y value in tooltip
- How to update new plotline values instead of removing and adding new ones in highcharts
- Highcharts - How to remove connecting line between fixed tooltip and point
- Highcharts - best way to handle and display zero (or negative) values in a line chart series with logarithmic Y axis
- How to add space between chart and axis in highcharts
- Highcharts shared tooltip for line series and scatter plot not working
- How to show only specific x-axis values on datetime axis in Highcharts
- Legend and Axis titles not showing in Highcharts Graph
- Legend and Axis titles not showing in Highcharts Graph
- HighCharts scatter plot with Datetime on X Axis not plotting values correctly
- Highcharts - how to create multiple y axis and group the data series
- How can I pass values from Highcharts event callbacks (click, mouseOver, mouseOut) back to React component member function?
- How do i make connectors (lines connecting datalabels) of piechart in Highcharts look straight lines and not curved?
- How to edit tooltip in Highcharts C# code
- How to feed series data that has x axis and y axis values in line highcharts?
- how to use highcharts tooltip formatter in python code
- how to show column and area charts with different y axis with same category and same x axis in highcharts
- Highcharts multiple x axis and yaxis. The width of the 1st x-axis is not in sync with browser resize
- Data and tooltip not working for graph using highcharts
- How to disable the date and time mentioned in the navigator part and not on the x axis in highstock?
- highcharts how to make x and y axis starting on the same zero using categories on yAxis
- Highcharts - how to access category of multiple axis of the point from tooltip
More Query from same tag
- Getting Highcharts tooltip to return an angular directive using templeteUrl?
- highcharts endOnTick option showing unspecified value on axis
- Highcharts accessing all records from database
- PHP - getting real time data from the database
- How to save Highcharts image on server auomatically
- The continuous update highcharts with more data plotting the continuity is not visible so we need that continuity in the centre of the graph
- How to show bar of graph in different colour when it reaches threshold level in high charts in JS?
- Place Data in Highchart using json and post url
- Is it possible to supply multiple yAxis from with data in one series
- Highcharts - Cross browser charts have different Y axis ranges, how can I ensure consistency?
- Highstock flag hover state: update font color
- Highcharts data module JSON api call setTimeout 30 sek
- Change colors on data points
- Highchart EMA, Price & MACD plot
- How to load a highchart script within a WebPartZone
- Color columns based on x axis and not on values (y axis) in highcharts
- Persist Marker state on point click -Treemap - Highchart
- Highcharts: Click to Highlight instead of Hide (= Always show non-selected)
- Highchart - Boxplot - Extra category shown with no data
- Highcharts Scatter plot - Add series from database as a different color
- Highcharts: disable allowPointSelect for only one pie slice
- HighCharts Angular 8 | yAxis problem with FireFox and IE
- Formatter Using HighCharts
- how to use json for Wind rose polar highchart insted of table data
- Highcharts context menu causes chart to disappear on return from print screen only on Chrome
- Highcharts Rendering Issues in all broswers
- Highcharts - change color while hovering over a slice in pie chart
- Highchart container does hold inner div
- Coloring a label depending on color of slice and using distance
- SplitSeries does not work in Packed Bubble Highchart in r