[ 5 posts ]

Tobias Grott

  • Username: tobiasgrott
  • Joined: Tue May 15, 2012 9:57 pm
  • Posts: 2
  • Offline
  • Profile

negative Values in Column Chart display wrong

Post Posted: Tue May 15, 2012 10:22 pm
+0-
Hello,

there seems to be a problem with the column chart if some series has negative values then the base line is moved to negative values.

I would expect that if there is one series with negative values then this column has to go down from the zero line and the other columns start from zero line and go up.

Currently the behavior is that the "zero" line is moved to the biggest negative value and all columns start from this level:
For example I have used the code from the examples page:

(function() {
YUI().use('charts', function (Y)
{
var myDataValues = [
{category:"5/1/2010", values:2000, expenses:3700, revenue:2200},
{category:"5/2/2010", values:50, expenses:9100, revenue:-100},
{category:"5/3/2010", values:400, expenses:1100, revenue:-500},
{category:"5/4/2010", values:200, expenses:1900, revenue:-1500},
{category:"5/5/2010", values:5000, expenses:5000, revenue:2650}
];

var mychart = new Y.Chart({dataProvider:myDataValues, render:"#mychart", type:"column"});
});
})();

then all columns render from -1500.
Is this expected behavior or a bug

Alberto Santini

YUI Contributor

  • Offline
  • Profile

Re: negative Values in Column Chart display wrong

Post Posted: Wed May 16, 2012 5:25 am
+0-
Hello Tobias.

Maybe it is related with the following ticket:
http://yuilibrary.com/projects/yui3/ticket/2531700

Regards,
IceBox

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 435
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile

Re: negative Values in Column Chart display wrong

Post Posted: Wed May 16, 2012 10:12 am
+0-
I have opened a ticket here and will get a fix in for the next pr release.
http://yuilibrary.com/projects/yui3/ticket/2532327


Below is patch (minimally tested) that you can use until the next pr.

chartsbug2532327Patch.js

Click here to see the revision history on this Gist.

Just embed this code before your charts instantiation. Post back if you run into any issues with the patch.

Thanks,
Tripp

Tobias Grott

  • Username: tobiasgrott
  • Joined: Tue May 15, 2012 9:57 pm
  • Posts: 2
  • Offline
  • Profile

Re: negative Values in Column Chart display wrong

Post Posted: Wed May 30, 2012 5:43 am
+0-
Thank you very much for your quick reply and the bugfix. The code seems to work.

While testing there appeared two minor issues.
When having a chart with positive and negative values there is noch "axes line" Zero line displayed and only the Columns go up and down from this point.
My workaround for this was to enable the horizontal gridlines.
This way there were several horizontal lines displayed.

But in some cases there wasn't any of the gridlines at the zero level there the key showAlwaysZero has to be set to true

Code:
horizontalGridlines: {
   styles: {
      line: {
         color: "#dad8c9"
      }
   }
},
axes:{
   yAxis: {
      alwaysShowZero: true
   }
}


Perhaps it might be useful to draw a zero line in this cases or set those ticks at the yAxis by Default.

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 435
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile

Re: negative Values in Column Chart display wrong

Post Posted: Wed May 30, 2012 7:27 pm
+0-
Currently, there is no notion of a "zero gridline". Feel free to file a ticket. In the interim, you can access the chart's graphic reference and explicitly draw a line. Below is a link to a gist that draws a line at 85%. You should be able to adjust the algorithm to draw a line on the zero value.

https://gist.github.com/2003595

Please post back if you have any issues, I'll be happy to help sort it with you.

Thanks,
Tripp
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum