Skip to content

No correct support for multiples yAxis #201

@ValentinH

Description

@ValentinH

Highcharts allows to specify several yAxis for a given chart (a demo can be see here: http://www.highcharts.com/demo/combo-multi-axes).

However, this is not properly handle by highcharts-ng:

  • multiple yAxis configuration can be passed as an array of axis to the configuration.
  • BUT all the extremes (min/max) management is done expecting a single axis instead of a possible array.

For instance, this (link to source):

var processExtremes = function(chart, axis, axisName) {
      if(axis.currentMin || axis.currentMax) {
        chart[axisName][0].setExtremes(axis.currentMin, axis.currentMax, true);
      }
    };

sets only the first axe extremes provided axis is an Axis on not an Array of Axis.

Again, for the watch on config.yAxis, the code is:

angular.forEach(axisNames, function(axisName) {
          scope.$watch('config.' + axisName, function (newAxes, oldAxes) {
            if (newAxes === oldAxes) return;
            if(newAxes) {
              chart[axisName][0].update(newAxes, false);
              updateZoom(chart[axisName][0], angular.copy(newAxes));
              chart.redraw();
            }
          }, true);
        });

and for my opinion it should be something like this:

angular.forEach(axisNames, function(axisName) {
          scope.$watch('config.' + axisName, function (newAxes, oldAxes) {
            if (newAxes === oldAxes) return;
            if(newAxes) {
                if(newAxes instanceof Array) {
                    for(var axe_index in newAxes) {
                        var axe = newAxes[axe_index];
                        if(axe_index < chart[axisName].length) {
                            chart[axisName][axe_index].update(axe, false);
                            updateZoom(chart[axisName][axe_index], angular.copy(axe));
                        }
                    }
                }
                else {
                    chart[axisName][0].update(newAxes, false);
                    updateZoom(chart[axisName][0], angular.copy(newAxes));
                }
                chart.redraw();
            }
          }, true);
        });

What do you think? If this last suggestion is OK, I can make a pull request.

Thanks by advance,
Valentin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions