Zero on Y axis.

Share RGraph:   Share or Like RGraph on Facebook!

« 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 Raissam on 17th March 2014
Hi,

I have a stacked bar graph and my data came from sql..

i format all data and complete with 0 when no have data from tables.. my string is like this..

[[1,0,0,0,0,0],[1,0,0,0,0,0],[1,0,0,0,0,0],[1,0,0,1,0,0],[2,1,0,0,0,0],[1,0,0,0,0,0]]

but depends can be like that

[[1,0,0],[1,0,0],[0,0,1],[1,1,0],[2,0,0],[1,0,0]]

or

[[1,0,0,0,0],[1,0,0,0,0],[1,0,0,0,0],[1,0,1,0,0],[2,1,0,0,0],[1,0,0,0,0]]

its variable..

And i use this for show the values inside every bar:

.ondraw = function (obj)
                 {
                     for (var i=0; i<obj.coords.length; ++i) {
                         obj.context.fillStyle = 'white';
                         RGraph.Text(obj.context, 'Verdana', 10, obj.coords[i][0] + (obj.coords[i][2] / 2), obj.coords[i][1] + (obj.coords[i][3] / 2),obj.data_arr[i].toString(),'center', 'center', null,null,null,true);
                     }
                 }


Everithing shows right but my question is.

How i dont show the labels when the value is 0 on graph?

Tkss!
Posted by Enter your name... on 17th March 2014
Hi there,

Check the value in your original array. As you loop through the coords you can give you 'i' variable (the index) to this function:

var indices = RGraph.sequentialIndexToGrouped(index, data)

And that will give you back the correct indices to use with the data array.




Richard
Posted by Raissam on 18th March 2014
My original array is fine..

Have the same problem that another link

www.rgraph.net/forum/2013/03/18/bar-chart-how-to-not-show-0-values-140425.html

I dont want to show the label 0 on stacked bar..

My graph is like this..

pt-br.tinypic.com/r/wbxaw3/8

If i remove the 0 from original string.. the mess all and don't show on the right order.

Any idea?
Posted by Enter your name... on 18th March 2014
Hi there,

This looks pretty similar to the question that I've just answered:

[removed]

Richard

Add a reply




« Back to message list