简体   繁体   中英

Angular Highcharts-ng how to set additional data series as tooltip

I have an array of data for values and an array of data for sample counts and I would like to display both in the tooltip for the point on the line chart.

I am using a web call to populate the arrays of data using an angular.forEach loop. I then set the data series of the chart as:

var all_values= [];
var all_samples= [];
var timespan= [];

angular.forEach($scope.data, function (value, key) {
  all_values.push(value.All_Values); //y axis values
  all_samples.push(value.All_Samples); //additional tooltip data
  timespan.push(values.TimeSpan); //this is for the x axis
});

$scope.chartConfig.series[0].data = all_values;

All of this works fine but how can I get my all_samples to be included in the data series so that I can display it on the tooltip?

If you want to display extra info in tooltip, then you need to set custom pointFormat / pointFroamtter / format / formatter - depends how much you would like to change tooltip display. Next, you could have external array for extra info or you could just add more properties to each data point. If you are using arrays for data points, then use keys .

Example: http://jsfiddle.net/ge2rbgt9/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM