score:2
Well as far as I know there is no generic option for that since highcharts ignores null values from showing.
On the other hand, we can replace the null
points with "fake" ones, that have an average value between the 2 closest points (this will cause the chart flow remain the same), and with a custom property isNull
which can be used as a flag later.
After doing that, we can use a formatter
function for the tooltip, and manipulate the tooltip the way we want, for example displaying only the series name when a point isNull
.
$(function () {
$('#container').highcharts({
title: {
text: 'The line is connected from April to Juni, despite the null value in May'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
connectNulls: true
}
},
tooltip: {
formatter: function(){
if(this.point.isNull == undefined)
return this.series.name+"<br>"+"<b>value:</b>"+this.y;
return this.series.name;
}
},
series: [{
data: [null, 71.5, 106.4, 129.2, null, 176.0, 135.6, null, 216.4, 194.1, 95.6, 54.4]
}]
}, function(chart){
var series = chart.series[0];
var data = series.data;
$.each(data,function(i){
var point = data[i];
var prevPoint = data[i-1] != undefined ? data[i-1].y : 0;
var nextPoint = data[i+1] != undefined ? data[i+1].y : 0;
if(point.y == null){
series.addPoint({x:point.x,y:(prevPoint+nextPoint)/2, isNull:true});
}
});
});
});
http://jsfiddle.net/zb5ksxtc/1/
I hope this is what you meant.
UPDATE We can also do something not less hacky... (I guess a little hacking could work fine in this unusuall case)
What I did here was creating a "fake" scatter series, with points located where null values from the real series (used same average logic). The series has hidden markers, and has a unique name.
After that, I used a shared
tooltip and a formatter
to display the right tooltip.
I used the name
attribute to determine what series is focused:
$(function () {
$('#container').highcharts({
title: {
text: 'The line is connected from April to Juni, despite the null value in May'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
connectNulls: true,
},
},
tooltip: {
shared:true,
formatter: function(){
var points = this.points;
var seriesName = points[0].series.name;
if(seriesName == 'fake')
return "Null tooltip";
return seriesName+"<br>value: <b>"+this.y+"</b>";
}
},
series: [{
type:'areaspline',
data: [null, 71.5, 106.4, 129.2, null, 176.0, 135.6, null, 216.4, 194.1, 95.6, 54.4]
},
{
type:'spline',
lineWidth:0,
name:'fake',
showInLegend:false,
marker:{
symbol:'circle',
radius:0,
}
}
]
}, function(chart){
var series = chart.series[0];
var fake_series = chart.series[1];
$.each(series.data, function(i){
var point = this;
var nextPoint = series.data[i+1] != undefined ? series.data[i+1].y : 0;
var prevPoint = series.data[i-1] != undefined ? series.data[i-1].y : 0;
if(series.data[i].y == null)
fake_series.addPoint([series.data[i].x, (nextPoint+prevPoint)/2]);
});
});
});
and the fiddle ofcourse: http://jsfiddle.net/zb5ksxtc/8/
Source: stackoverflow.com
Related Query
- How to use highcharts to display data of only five point when the page is initialized?
- Highcharts - How to display legend symbol inside the tooltip
- Highcharts - only show tooltip when hovering directly on point
- Highcharts - How to remove connecting line between fixed tooltip and point
- How to enable or disable a Highcharts tooltip when a button is clicked?
- How to get next point in Highcharts tooltip
- How to get the highlighted point from shared tooltip formatter, Highcharts
- Highcharts - how to set custom content in point tooltip (popup) on 3D scatter chart or how to customize point tooltip information?
- how to display 2 same highcharts without duplicate the code
- How to edit tooltip in Highcharts C# code
- how to use highcharts tooltip formatter in python code
- How to place tooltip above point in highcharts x-range?
- How to show values in Highcharts tooltip other than x and y when data points are too high?
- How to show other point property in bubble highcharts using tooltip
- How to display only last point on highcharts and that point should travel with chart line?
- Highcharts - how to access category of multiple axis of the point from tooltip
- Make highcharts display the tooltip of the previous point
- Highcharts: how display tooltip, when point = null?
- How to hide Series Name in HighCharts Tooltip when using pointFormatter
- How to display multiple values of the same attribute when hovering on tooltip with highcharts/highmaps
- Highcharts does not display years on Xaxis when data with NULL values
- How to set point in highcharts when x axis and y axis has data as text values?
- How to display tooltip data below x-axis category labels using Highcharts
- How can I fix the error #17 "The requested series type does not exist" error when trying to display a highcharts graph in Vue.js?
- How to display Date in Highcharts tooltip or below the categories
- How to display hovered point value in Highcharts Crosshair
- How to display precise value on tooltip on moving a cursor in highcharts
- Highcharts : Display static Y axis labels from array when series data is null , else auto generated label
- How to display extra data in highcharts bubble chart tooltip with datetime x-axis
- How to display custom or non-series data array on Highcharts tooltip on hover?
More Query from same tag
- Highcharts - How to get a value of a stack in a series?
- Why isn't my highcharts chart getting reset/destroyed properly?
- How to properly structure/pass in data for Highcharts.js series chart?
- highcharts have data Labels only on some points
- Animation for dynamically loaded new data with Highcharts
- HighCharts: show alla y axis on tooltip
- HIGHCHARTS: drilldown.js changes pie chart label color
- Highcharts time X axis
- Highchart-treemaps equal tiles
- Highcharts: only display stack labels if there are multiple stacks?
- Can't disconnect line chart with [null,null] and irregular intervals in Highcharts
- Highcharts.map depreciated warning
- Why does Highcharts <div> element take up the entire page?
- Including source for Alchemy js breaks Highcharts js
- How to display precise value on tooltip on moving a cursor in highcharts
- Set datetime format in x-axis of Highchart
- Styling issues with Highcharts JS
- Vuejs Component Communication
- Highcharts transform JSON into data without losing informations
- Highcharts JS: How do I decrease the spacing between Y values?
- Highcharts export charts as image on serverside with php
- How to enable scrolling in advanced accessible charts in highcharts
- How to draw connectors for venn diagram chart in Highcharts?
- Highcharts: Getting x-axis to display legend
- Passing in Id for each data item in bar chart using highcharts
- Highcharts - column stacked Y axis
- How to fix xAxis(datetime) scale in Highcharts?
- Highcharts - handle click on overlapping areaspline point
- Simple bar chart in jQuery HighCharts and MVC 2 application?
- Wkhtmltopdf fails to printing SVG path (highchart)