score:1
You can dynamically do this with the load event of highcharts and annotations. Like this:
chart: {
type: 'column',
events: {
load: function() {
for (let i = 0; i < this.series[0].data.length; i++) {
if (this.series[0].data[i].y == null && this.series[1].data[i].y == null) {
this.addAnnotation({
labelOptions: {
backgroundColor: 'rgba(255,255,255,0.5)',
borderWidth: 0,
},
labels: [{
point: {
x: i,
y: 0,
xAxis: 0,
yAxis: 0
},
text: 'Your title here',
shape: 'rect',
style: {
fontSize: '20px'
}
}]
})
}
}
this.redraw()
}
}
},
This will print a text for every position in the chart that does not have any values.
It is assumed that you have two series, both with null
values where data is missing. After a point with no data is found an annotation is added in its place.
There are lots of options to play with, to style and position the annotation exactly as you wish.
This will only work if <script src="https://code.highcharts.com/modules/annotations.js"></script>
has been included.
var investment = 10000;
Highcharts.chart('updown_chart', {
chart: {
type: 'column',
events: {
load: function() {
for (let i = 0; i < this.series[0].data.length; i++) {
if (this.series[0].data[i].y == null && this.series[1].data[i].y == null) {
this.addAnnotation({
labelOptions: {
backgroundColor: 'rgba(255,255,255,0.5)',
borderWidth: 0,
verticalAlign: 'top',
y: 0
},
labels: [{
point: {
x: i,
y: 0,
xAxis: 0,
yAxis: 0
},
text: 'Your title here',
shape: 'rect',
style: {
fontSize: '20px'
}
}]
})
}
}
this.redraw()
}
}
},
xAxis: {
categories: ['pa', 'p2', 'p3', 'p4'],
reversed: false,
labels: {
step: 1
}
},
yAxis: [{
title: {
text: null
},
labels: {
formatter: function() {
return this.value + '%';
}
},
stackLabels: {
enabled: true,
align: 'center',
formatter: function() {
var newval = this.total;
var pval = Math.abs(this.total);
var amount = parseInt((investment * pval) / 100);
if (this.isNegative) {
newval = '-' + pval + '%' + ' ($' + amount + ')';
} else {
newval = '+' + pval + '%' + ' ($' + amount + ')';
}
return newval;
}
}
}],
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function() {
return '<b>' + this.point.category + '</b><br/>' +
this.series.name + ': ' + Highcharts.numberFormat(this.point.y, 2) + '%';
}
},
credits: {
enabled: false
},
series: [{
showInLegend: false,
name: 'aa',
color: '#428bca',
data: [10, 20, 10, null]
}, {
showInLegend: false,
name: 'bb',
color: '#15315A',
data: [-10, -20, -30, null]
}],
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/annotations.js"></script>
<div id="updown_chart">
</div>
Working jsfiddle example: http://jsfiddle.net/ewolden/p4e0m1w6/4/
Source: stackoverflow.com
Related Query
- Highcharts show blank colum with text
- Getting numbers on Y-axis to show up as percentages with code from a Highcharts code generator tool?
- Highcharts blank chart with x and y axis
- Highcharts - Global configuration with common code and unique data & Headings
- Show more data on Gauge chart with Highcharts
- Using wkhtmltopdf with highcharts shows blank chart
- Highcharts Gauge Chart with text labels
- Highcharts show the same yAxis start and end value with multiple data series
- Highcharts : show time with 30 second interval
- HighCharts PieChart with just one segment doesn't show a label
- highcharts dataLabels support RTL with enable hover it for show tooltip
- highcharts donut chart center text overlaps with tooltip
- passing formatting JavaScript code to HighCharts with JSON
- Highcharts gantt chart : Task progress indicator need to show a single task for various status like completed,inprogress etc with different colors
- Highcharts - draw line chart with summed values but show breakup on hover
- how to show column and area charts with different y axis with same category and same x axis in highcharts
- Show plotlines in highcharts with hidden axis?
- Highcharts stacked column don't show the stacked with min value
- Highcharts for multiple plot lines each with a different color and show tooltip?
- Highcharts plotbands text should not overlap with columns
- Change the legend in highcharts heatmap to show instead of a color bar, a set of fixed icons with hide and show on click
- Why Highcharts box only show with some position
- Highcharts series visibility with csv data source
- Text overflow issue with highcharts
- Custom bar chart text with Highcharts
- Highcharts Bubble with text
- How to have multiple highcharts with different series data in vuejs without repeating code
- Highcharts show two line series with same values
- show two different series with different start intervals with the same xAxis highcharts
- Highcharts show x-axis with dates
More Query from same tag
- Highcharts: Dynamically update dataLabels in synchronization with setData
- Highcharts visualizes chart data incorrectly after zooming or using the navigator
- Highcharts - Bubble chart - Proportional bubbles
- Re-sizing problems in HighChart
- Highmaps missing cities for California State
- Highcharts - Export CSV include additional data
- Show logo and menu before Highcharts
- Highcharts -- Getting categories from mysql
- Highcharts adding additional series and axis breaks existing yAxis min/max
- Incorrect JSON data format
- Area Stacked linewidth
- How to set Y axis with equal interval in Highcharts?
- Angular 8 & Highcharts - how to show tooltip crosshairs
- highchart color as classname inside data series doesn't apply to legend
- Highcharts multiple series from JSON with different style depending on serie name
- Highcharts Highmaps the data does not match with polygons correctly
- Highcharts tooltip looks weird
- Angular JSON from API to an Array of value
- Showing HighCharts in A JQuery Mobile application
- Highcharts Heat map not displaying data yet correctly labelling
- Is such graph possible to plot Using Highchart?
- How to import Highmaps map collection in Angular 6
- Highchart click response time
- Highchart - Chart type, gap in the x and y axis (0,0)
- Set different width for each column in highcharts
- change highchart data using radio buttons
- rangeSelector: change date beyond zoomed time range
- Highcharts - StackLabels displayed over tooltip when useHTML=true
- How to hide stackLabel in highcharts when it is bigger than the column
- I want to show all lines but just legend of one of them in highchart