Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiBarHorizontalChart not reading stacked option properly #100

Closed
inolasco opened this issue Mar 25, 2015 · 5 comments
Closed

multiBarHorizontalChart not reading stacked option properly #100

inolasco opened this issue Mar 25, 2015 · 5 comments

Comments

@inolasco
Copy link
Contributor

It seems angular-nvd3 is treating the stacked parameter as an object instead of a boolean as it should be. So charts which had stacked: true are not correctly set as stacked.

Removing 'stacked' from :

                            else if ([
                                ....
                                'stack2',
                                'stacked',
                                'multibar',
                                ...
                            ].indexOf(key) >= 0){
                                if (options.chart[key] === undefined || options.chart[key] === null) {
                                    if (scope._config.extended) options.chart[key] = {};
                                }
                                configure(scope.chart[key], options.chart[key], options.chart.type);
                            }

Seems to fix it

This issue may apply to other bar chart variants as well

@inolasco inolasco reopened this Mar 25, 2015
@jsyrjala
Copy link

jsyrjala commented Apr 2, 2015

This affects also multiBarChart. Fix described by @inolasco seems to also fix multiBarChart.

I am using angular-nvd3 1.0.0-beta.

@allienx
Copy link

allienx commented Apr 7, 2015

I think this configuration was meant for overriding dispatch events for the stackedAreaChart:

$scope.options = {
  chart: {
    type: 'stackedAreaChart',
    ...
    stacked: {
      dispatch: {
        areaClick: function(event) {
          ...
        }
      }
    }
  }
}

But this creates a conflict for the stacked option of other charts.
Unfortunate naming convention by the NVD3 library. The fix by @inolasco works if you don't need to listen to stackedAreaChart events.

@inolasco
Copy link
Contributor Author

inolasco commented Apr 7, 2015

Indeed @allienx , you are correct. I figured stacked was probably used for something else as well, just didn't know what that 'else' was, which you've cleared up. So a better, real fix is needed, mine is just a temporary fix.

@ywplee
Copy link

ywplee commented May 5, 2015

Is there a permanent fix for this implemented yet?
If not, I can create a pull request based on the solution shown in the following code. I'm just adding a case handler for 'stackedAreaChart' model's stacked event (assuming stacked event gets only generated from the StackedAreaChart and 'stacked' property is used as an option on the other models).

else if ([
    'lines',
    'lines1',
    'lines2',
    'bars',
    'bars1',
    'bars2',
    'stack1',
    'stack2',
    'stacked',
    'multibar',
    'discretebar',
    'pie',
    'scatter',
    'bullet',
    'sparkline',
    'legend',
    'distX',
    'distY',
    'xAxis',
    'x2Axis',
    'yAxis',
    'yAxis1',
    'yAxis2',
    'y1Axis',
    'y2Axis',
    'y3Axis',
    'y4Axis',
    'interactiveLayer',
    'controls'
].indexOf(key) >= 0){
    // special case handler for stackedAreaChart model's stacked event
    // stacked is an option on the other models
    if (key === 'stacked' && options.chart.type !== 'stackedAreaChart') {
        scope.chart[key](options.chart[key]);
    } 
    else {
        if (options.chart[key] === undefined || options.chart[key] === null) {
            if (scope._config.extended) {
                options.chart[key] = {};
            }
        }
        configure(scope.chart[key], options.chart[key], options.chart.type);
    }
}

@NameFILIP
Copy link
Collaborator

Fixed, thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants