Quartz / Chartbuilder

A front-end charting application that facilitates easy creation of simple beautiful charts
http://quartz.github.io/Chartbuilder
MIT License
2.1k stars 354 forks source link

Initialize tangle axis with zero instead of 30 #236

Closed roberthuttinger closed 8 years ago

roberthuttinger commented 8 years ago

Tried explicitly setting defaults to zero but it looks like there is a check to return '' on zero. Setting the default to zero allows the zero to be displayed, but the binding is done on the fly so there is no external trigger for updating.

Im sure this is a simple issue, any idea where I can set the min == 0 in main.js?

nsonnad commented 8 years ago

The default is based on the domain of the data (or 0 by default for column charts). It only gets set to an explicit value once it is customized. Do you just want it to be 0 on the default data or for any data that is pasted in?

roberthuttinger commented 8 years ago

0 default for any new data that is created. that should be the default. It looks like it is 30 now (calculated)

nsonnad commented 8 years ago

For any data, or just the initial data?

roberthuttinger commented 8 years ago

Any new data with no calculation. If the range were 800-1000 the base would still be zero The user could then change it, but zero should be the default

nsonnad commented 8 years ago

To do this, you'll want to modify the behavior of the compute_scale_domain helper function, found here.

you could change this (line 75)

if (!scaleObj.domain || !scaleObj.custom) {
    if (opts.nice) {
        _domain = niced;
    } else {
        _domain = extent;
    }
    defaultMin = true;
    defaultMax = true;
} else {

to

if (!scaleObj.domain || !scaleObj.custom) {
    if (opts.nice) {
        _domain = [0, d3.max(niced)];
    } else {
        _domain = [0, d3.max(extent)];
    }
    defaultMin = true;
    defaultMax = true;
} else {

though you may need something a bit fancier for negative numbers (eg sorting)

roberthuttinger commented 8 years ago

Awesome! I noticed that section but the syntax escaped me, and still wasnt sure after testing.

Bug was present, fixed and now works perfectly! thanks!