score:5
Accepted answer
To just add a suffix, you'd be ok using the headerFormat like:
headerFormat: '<span style="font-size: 10px"> {point.key}s </span><br/>'
But since you want to do division in there, you'll need to take complete control with a formatter function:
tooltip: {
formatter: function(d){
var rV = (this.x / 1000).toFixed(2) + "s <br/>";
rV += '<span style="color:' + this.point.color + '">\u25CF</span> ' + this.series.name + ': <b> ' + this.y + '</b><br/>';
return rV;
}
},
Here's a working example:
$(function () {
$('#container').highcharts({
tooltip: {
formatter: function(d){
var rV = (this.x / 1000).toFixed(2) + "s <br/>";
rV += '<span style="color:' + this.point.color + '">\u25CF</span> ' + this.series.name + ': <b> ' + this.y + '</b><br/>';
return rV;
}
},
series: [{
name: 'Short',
data: [[1.23 * 1000, Math.random() * 10], [2.343 * 1000, Math.random() * 10],[3.343 * 1000, Math.random() * 10],[4.343 * 1000, Math.random() * 10],[5.343 * 1000, Math.random() * 10]]
}]
});
});
<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>
<div id="container" style="height: 300px"></div>
EDITS
Here's an updated version of your fiddle.
With multiple series you want a shared tooltip and loop the points object:
tooltip: {
formatter: function(d){
var rV = (this.x / 1000).toFixed(2) + "s <br/>";
this.points.forEach(function(d){
rV += '<span style="color:' + d.color + '">\u25CF</span> ' + d.series.name + ': <b> ' + d.y + '</b><br/>';
});
return rV;
},
shared: true
},
Full working code:
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Profile'
},
subtitle: {
text: '(pressure & velocity vs. dispense time)'
},
xAxis: [{
//categories: [0,48,98,150,200],
//labels:{rotation:-45, step:0}
title: {
enabled: true,
text: 'Seconds from start' //Seconds from start of Dispense
},
name: 'test',
labels: {
formatter: function () {
return Highcharts.numberFormat(this.value / 1000, 3);
}
},
crosshair: true
}],
yAxis: [{ // Primary yAxis
labels: {
formatter: function () {
return this.value + ' PSI';
},
style: {
color: '#4572A7'
}
},
title: {
text: 'Pressure',
style: {
color: '#4572A7'
}
},
opposite: false
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Vel', //Pallet
style: {
color: '#89A54E'
}
},
labels: {
formatter: function () {
return this.value + ' mm/s';
},
style: {
color: '#89A54E'
}
},
opposite: true
}],
tooltip: {
shared: true,
formatter: function(d){
var rV = (this.x / 1000).toFixed(2) + "s <br/>";
this.points.forEach(function(d,i){
rV += '<span style="color:' + d.color + '">\u25CF</span> ' + d.series.name + ': <b> ' + d.y;
if (i === 0){
rV += ' PSI';
} else {
rV += ' mm/s';
}
rV += '</b><br/>';
});
return rV;
},
valueDecimals: 4,
},
plotOptions: {
spline: {
marker: {
radius: 1,
}
}
},
legend: {
layout: 'vertical',
align: 'left',
x: 100,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: '#FFFFFF'
},
series: [{
name: 'PSI',
color: '#4572A7',
yAxis: 0,
data: [
[0, -8.527222],
[48, -8.19928],
[98, -8.19928],
[150, -8.19928],
[200, -8.19928]
],
tooltip: {
valueSuffix: ' PSI'
},
marker: {
radius: 2
}
}, {
name: 'Vel',
color: '#89A54E',
yAxis: 1,
data: [
[0, 5.376344E-02],
[48, -5.376344E-02],
[98, -1.075269E-01],
[150, 0],
[200, -2.688172E-01]
],
tooltip: {
valueSuffix: ' mm/s'
},
marker: {
radius: 2
}
}, {
name: 'Vel',
color: '#29A54E',
yAxis: 1,
data: [
[0, -0],
[48, 4.032258E-01],
[98, -0],
[150, 4.032258E-01],
[200, -4.032258E-01]
],
tooltip: {
valueSuffix: ' mm/s'
},
marker: {
radius: 2
}
}]
});
});
<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>
<div id="container" style="height: 300px"></div>
Source: stackoverflow.com
Related Query
- How to modify Highcharts x-axis tooltip text
- how to pass values to tooltip which not in x and y axis in highcharts
- How to edit tooltip in Highcharts C# code
- how to use highcharts tooltip formatter in python code
- How to edit the tooltip text in a highcharts boxplot
- Highcharts - how to access category of multiple axis of the point from tooltip
- How to add text labels to a numerical x axis in Highcharts
- How to set point in highcharts when x axis and y axis has data as text values?
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- How to hardcode arbitrary Tick text labels on y axis in highcharts
- How to modify highcharts legend item click event?
- how to set the interval of points on Y - Axis highcharts
- How replicate the value of Y Axis on both sides of the axis in Highcharts
- How to change the text color in Highcharts
- Highcharts - How to display legend symbol inside the tooltip
- Javascript Highcharts v3.0.5 - How to hide Y Axis Title when using multiple Y Axis
- Highcharts how to change x axis options
- Highcharts - How to start x axis from an arbitrary value
- Highcharts how to remove headers from tooltip
- Highcharts - How to hide series name and Y value in tooltip
- Highcharts - How to remove connecting line between fixed tooltip and point
- Tooltip text alignment in Highcharts for 'direction: rtl'
- how to add annotation text to a Highcharts chart?
- How to add space between chart and axis in highcharts
- Highcharts - How to remove tooltip arrows
- How to change axis label size when exporting in Highcharts / Highstock
- How to enable or disable a Highcharts tooltip when a button is clicked?
- How to show only specific x-axis values on datetime axis in Highcharts
- How to remove text which was added via chart.renderer in Highcharts
- highcharts tooltip text align
More Query from same tag
- How to tell if series is in upper chart or lower chart in tooltip (using highstock)?
- Plotting multiple series from JSON php import to Highcharts
- How to ignore hidden series when clicking on a legend using highcharts?
- Highchart Java export image
- HighCharts: use an anonymous function in maincontentText
- plot bands in x-axis is not working on time
- Highcharts data set array
- Remove spacing on a HighChart graph?
- Highcharts sankey. Highlight all paths of a given category
- Can hidden values be passed between a highcharts drilldown?
- When I hover the curve on any point,the tooltip will display the first point
- React highchart: Shared tooltip in same and different chart
- ng2-highcharts chart update after load
- Highcharts - remove times between dates on a datetime xaxis type
- Get x-axis values of selected graphs
- Highcharts plotband label zIndex
- HighCharts - Dynamically Change Axis Title Color
- Disabling inactive state in Highcharts styled mode
- how can I add a borderline to a plotBand when mouse move in and remove that borderline when mouse move out?
- high charts line graph x-axis issue
- Issue removing and readding series to chart
- creating a bar chart using Highcharts with React - getting an error that rendering div isn't found
- Erb array not updated after ajax post
- How to Disable Highchart Unit Display None
- Highcharts not working in ie 11
- Highcharts highstock update date filter with javascript
- highstock 1.3 / highcharts 3.0 beta navigator lagging
- How to get series highlight on hover in highcharter?
- How to create charts like below using highcharts in angular
- How can I add internal padding to the plot area of my highchart/highstock chart?