Question

I've been looking around and couldn't find an answer for it, and I don't think it's a difficult solution, but I can't figure out how to do it.

I draw a grouped bar chart with RGraph. This is done with the following code:

  var tooltip = createToolTip();
  bar4 = new RGraph.Bar('graph_tab1', objectSoap1.getValue());
  bar4.Set('chart.colors', ['Gradient(#c01:red)', 'Gradient(#05D:blue)', 'Gradient(#0f0:green)', 'Gradient(#f0f:pink)']); 
  bar4.Set('chart.labels', objectSoap1.getLabel());
  bar4.Set('chart.numyticks', 8);
  bar4.Set('chart.ylabels.count', 6);
  bar4.Set('chart.variant', '2d');
  bar4.Set('chart.strokestyle', 'rgba(0,0,0,0)');
  bar4.Set('chart.hmargin.grouped', 0);
  bar4.Set('chart.background.grid.autofit.numhlines', 6);
  RGraph.Effects.Bar.Grow(bar4);

now if I hit a button it had to change from grouped to stacked. I do this with the following code:

  bar4.Set('chart.grouping', 'stacked')
  RGraph.Effects.Bar.Grow(bar4);

it draws a stacked graph.. but the problem is the y-axis doesn't change.

as an example, if I have a grouped bar chart, with values 5, 10 and 15. the max y-value will be 15. But if I stack these values, the value will be 30, and with this piece of code the barchart will grow to far, because it's going to a value 30, and the y-axis only goes to 15.

I hope it's clear what I mean and somebody can help me out.

Was it helpful?

Solution

There's an example of switching from grouped to stacked here:

http://dev.rgraph.net/fiddle/view/cfa8b72f8a9988527269abdfc7d34384

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top