My one bar stacked Horizontal Bar chart doesn't properly stack

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Paul Dubinsky on 7th January 2018
This code:

<canvas id='cvs71' width='500' height='150' style='float:left;'>
   [No canvas support]
var hbar = new RGraph.HBar({
     id: 'cvs71',
         data: [90.0,10.0],
         options: {
  textAccessible: true,
  grouping: 'stacked',
  colors: ['forestgreen','red'],
  scaleZerostart: true,
  gutterLeft: 100,
  shadow: true,
  shadowOffsety: -5,
  shadowOffsetx: 13,
  shadowBlur: 10,
  shadowColor: '#aaa',
  vmargin: 10,
  noaxes: true,
  labels: ['% Complete'],
  title: 'LE02 - Last 7 Days',
  titleSize: 24,
  xmax: 100,
  unitsPost: '%'


Produces a two bar graph with no red second data on either line. (Right panel)

Change the data to [[90.0,10.0],[80.0,20.0]] and the graph displays correctly. (Left panel)


Posted by Richard on 7th January 2018
Hi there,

You're missing a pair of square braces in your data. Instead of this:

data: [90.0, 10.0]

To get a stack it needs to be this:

data: [[90.0, 10.0]]

Because if you were to have multiple bars it would look like this:

data: [[90.0, 10.0], [65,35],[12,88]]


Add a reply

« Back to message list