samron
samron

Reputation: 43

get access to chart-object in highchart

I´m not able to get access to the chart-object in highchart with the angularjs directive HIGHCHARTS-NG.

var chart = $scope.chartConfig.getHighcharts();

console.log("chart", chart);

Gives me an error: $scope.chartConfig.getHighcharts is not a function.

When I

console.log("chart", chartConfig);

the object offers me the getHighcharts()-function.

When I say

var chart = $scope.chartConfig
console.log("chart", chart);

it´s not offering the getHighCharts-function anymore!

I really need to get access to that chart-object.

Thanks

Upvotes: 1

Views: 2886

Answers (1)

Luis Nolazco
Luis Nolazco

Reputation: 1322

I will suggest to use the highcharts libraries how they are. Because in this case this is not an official pluggin, and the problem is that in a near future it might not be compatible anymore.

Anyway, to get the chart object you can try:

  1. Using the pluggin method .getHighChart. If you have this:

<highchart id="chart1" config="chartConfig"></highchart>

you can use func option;

$scope.chartConfig = {
...,
  func: function(chart){
     //play with chart
  }
}

which is a reference to the callback function when it creates the highchart object:

var x = new Highcharts(options, func);
  1. using jQuery

    var chart = $("#chart1").highcharts();

I hope it helps.

Regards, Luis

Upvotes: 2

Related Questions