EduardoDominguez / dwpe

Automatically exported from code.google.com/p/dwpe
MIT License
0 stars 0 forks source link

Add option(s) to customize the range of values that appear on each axis #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Sometimes the range of values is limited, like 180 to 300, and should not
start at zero.

Original issue reported on code.google.com by fg.mag...@gmail.com on 17 Mar 2010 at 3:14

GoogleCodeExporter commented 8 years ago
I guess the current behavior for line and area charts is to use the range from 
0 to
the max value.  It would be nice to have an option to set the range from min to 
max
values, or even to set the limits explicitly.

Original comment by afme...@gmail.com on 1 Apr 2010 at 2:32

GoogleCodeExporter commented 8 years ago
If this is the place for it, I'd like to +1 this idea. It's very limiting not 
having
a contextual y value.

Original comment by harryhob...@gmail.com on 9 Apr 2010 at 7:57

GoogleCodeExporter commented 8 years ago
Issue 18 has been merged into this issue.

Original comment by scottj...@gmail.com on 23 Apr 2010 at 8:32

GoogleCodeExporter commented 8 years ago
It would be nice to be able to set max = max + n steps and min = min - n steps.

Original comment by b.vandeb...@gmail.com on 27 Apr 2010 at 2:55

GoogleCodeExporter commented 8 years ago
I wanted to have such functionality, so made it ;-)
The range is defined in the visualize.jQuery.js file in the function 
scrapeTable().
Change the topValue and bottomValue parameter setting to this:

topValue: function(){
        if (o.topValue===false) {
            var topValue = 0;
            var allData = this.allData().join(',').split(',');
            $(allData).each(function(){
                if(parseFloat(this,10)>topValue) topValue = parseFloat(this);
            });
            return topValue;
        }
        else {
            return o.topValue;
        }
},
bottomValue: function(){
        if (o.bottomValue===false) {
            var bottomValue = 0;
            var allData = this.allData().join(',').split(',');
            $(allData).each(function(){
                if(this<bottomValue) bottomValue = parseFloat(this);
            });
            return bottomValue;
        }
        else {
            return o.bottomValue;
        }
},

AND You need to add 2 parameters to the default options: 
    topValue: false, // the value on top
    bottomValue: false // the value bottom

So if You have false as topValue and/or bottomValue it will be counted from the 
data. If You set it it will be used.

I'm waiting for any replies on this. Thanks!

Original comment by mr.tee...@gmail.com on 7 Sep 2010 at 9:37

GoogleCodeExporter commented 8 years ago
Just wanted to say a massive thank you to mr.teecee, that piece of code worked 
like a charm and was exactly what I needed. 

Thanks!

Original comment by BradKoeh...@gmail.com on 15 Sep 2010 at 1:42

GoogleCodeExporter commented 8 years ago
Thanks for this snippet.

The bottom value doesn't seem to be calculated for me though. My line charts 
start a zero unless I enter a value for bottomValue.

I can't tell for sure if that's expected behavior when using this snippet or 
not. Can someone confirm? And if so, perhaps suggest a way to calculate the 
bottom value?

Original comment by balsam.a...@gmail.com on 6 Dec 2010 at 4:44

GoogleCodeExporter commented 8 years ago
Hi Adam,
Please tell me what values do You use for that chart.

Thanks!

Original comment by mr.tee...@gmail.com on 6 Dec 2010 at 4:48

GoogleCodeExporter commented 8 years ago
The HTML from the table that is scraped is attached. It's a little goofy 
because it's generated by Drupal - but I did test with a 'clean' table as well.

Original comment by balsam.a...@gmail.com on 7 Dec 2010 at 3:40

Attachments:

GoogleCodeExporter commented 8 years ago
if rendering several graphs, each with various scales I use:

                topValue: function(){
                        var topValue = 0;
                        var allData = this.allData().join(',').split(',');
                        $(allData).each(function(){
                            if(parseFloat(this,10)>topValue) topValue = parseFloat(this);
                        });

                        var tempTopValue = topValue;

                        tempTopValue = tempTopValue / 10;

                        topValue = Math.ceil(tempTopValue) * 10;

                        return topValue;
                },

Original comment by nickpcal...@gmail.com on 13 Jan 2012 at 5:32