score:1
The issue is the use of this.x
here:
for (i = 0; i < 4; i++) {
sum += series[i].yData[this.x];
}
For "normal" x-axis types this works well since you can open the yData
by index. In your case it will end up trying to find something like series[0].yData[1262304000000]
, which won't work.
I'm not aware of any easy way to find the relationship between the timestamp this.x
and which index that has on the x-axis. My solution uses another for loop to compare the timestamp from this.x
with the xData
array, and if it matches we use the data in the sum, as shown in this updated formatter
:
formatter: function () {
// If doing negative, ignore
if(this.total <= 0)
return;
var sum = 0;
var series = this.axis.series;
for (var i = 0; i < series.length; i++){
for(var j = 0; j < series[i].xData.length; j++) {
if(series[i].options.type == 'column' && series[i].xData[j] == this.x) {
sum += series[i].yData[j];
break;
}
}
}
return sum;
}
This updated JSFiddle shows it in action.
score:1
If I understand what you're asking for correctly, the following formatter function should work:
formatter: function () {
return this.total >= 0 ?this.total : null ;
},
As to the available options in the formatter function, http://api.highcharts.com/highcharts#plotOptions.column.dataLabels.formatter should help. But, I tend to just put a breakpoint in the function and inspect what this
is. :)
Source: stackoverflow.com
Related Articles
- Highcharts - with datetime axis labels overlap
- How to get proper stack labels with 'datetime' axis?
- Highcharts label format with tickPositioner in a datetime x Axis
- last label in x axis with datetime format not coming in highchart
- HighCharts scatter plot with Datetime on X Axis not plotting values correctly
- How can I force ticks/grid lines on a Highcharts datetime X axis to arbitrarily line up with data points?
- How To Show All Data Labels For Datetime Axis In Highcharts
- Replace axis labels with custom in highcharts r
- Bar with negative stack and positive labels
- Highcharts datetime axis overlap with a long time series
- Highcharts datetime axis labels according to data point groups
- Highcharts React update animations with datetime axis
- Align labels of axis with type category under ticks
- Dates instead of values on Highchart labels in graph with multiple axis
- Plotting Irregular DateTime Data with a predefined X Axis
- Is it possible to make a table with y axis labels of Highcharts bar chart?
- Slanted highcharts axis labels overlap with legend
- highchart place x-axis labels in between ticks on a datetime axis
- How to fix formatting of axis labels in Highcharts when surrounding the contents with div?
- Width for labels on x Axis with grouped Categories in Highcharts
- Highcharts multiple axis with custom labels
- Highcharts - draw path on chart with datetime axis
- In the following code i want to show the WHOLE names on x axis nd dont want them to overlap with the legend
- Category chart with datetime y axis in highcharts
- How to prevent highcharts from shortening labels with ellipsis
- How to show all values at datetime axis in highcharts?
- How to display highchart y axis with constistant data
- Highcharts - best way to handle and display zero (or negative) values in a line chart series with logarithmic Y axis
- Highcharts - Long multi-line y axis labels causing following label to be removed
- Highstocks - Use tickmarkPlacement "between" on datetime Axis (no categories)
- Missing series name as label in highcharts heatmaps
- Highcharts - Issue with the chart reflow function
- Hover entire container contents with an Overlay
- Switch between the view data table and the highcharts graph
- Highcharts custom x-axis categories aligned center (Under the pins)
- Change color of different points in same series Highcharts
- How do I pass in parameters to the Highcharts pointFormatter callback function
- Highcharts Chrome 71 leak
- Format categories (x-axis) for highcharts
- how to exclude last column from highchart from table
- wkhtmltoimage does not show gridlines of highcharts graph
- (Very) hard to find Highcharts error
- DB Array to expected javascript format
- Highcharts : How do I keep the marker formatting and make the click event fire with a 5K+ point scatter plot?
- highcharts display all dates for all points on x-axis
- highcharts yaxis start on 1 min:1 not working
- How to change color of single column in Highcharts column graph when data is in CSV form?
- Is it possible to hide the line & symbol next to Highcharts legend items?
- R highcharter - grouped categories - missing label for group with one value only
- How to render html with highcharts in ionic 2