Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Any idea how to turn on stacking for bar/column charts? It's possible in both Google (https://developers.google.com/chart/interactive/docs/gallery/columnchart...) and Highcharts (http://www.highcharts.com/demo/column-stacked). Looking through the API I thought it would be straightforward to override defaults, but the following has no effect:
function MYMODULE_charts_type_info_alter(&$chart_types) {
$chart_types['column']['stacking'] = TRUE;
}
Any other thoughts?
It would be nice if it was a configurable option in the View > Chart > Settings... but that's another problem.
Comments
Comment #1
timdavison CreditAttribution: timdavison commentedI think you need hook_chart_alter e.g.
function MYMODULE_chart_alter(&$chart, $chart_id) {
$chart['#stacking'] = true;
}
You can use the $chart_id to check it's the right chart to alter if you have more than one.
Comment #2
Pierre.Vriens CreditAttribution: Pierre.Vriens commentedThanks Tim for the suggestion about what might possibly be a solution for this issue. Hopefully Rob will further update the issue with the results after using your suggestion (i.e.: did it work?).
Note the parent issue I also added here ...
Comment #3
robcarrWorked for me.
Used following to ID and target specific charts:
Thanks @timdavison for your help. Sorry for delay in reply - Christmas and house move got in the way
Comment #5
funkeyrandy CreditAttribution: funkeyrandy commentedhow would this be added to the views chart types? I need a stacking chart generated from views
Comment #6
funkeyrandy CreditAttribution: funkeyrandy commentednever mind...accomplished with a module
Comment #7
katrien_w CreditAttribution: katrien_w commented@funkeyrandy: can you please share which module you accomplished this with?
Comment #8
funkeyrandy CreditAttribution: funkeyrandy as a volunteer commentedi just made a custom module like in #3