1. #1
    Sencha User
    Join Date
    Nov 2007
    Posts
    294
    Vote Rating
    0
    Answers
    1
    Sesshomurai is on a distinguished road

      0  

    Default Unanswered: Chart bar values less than 1?

    Unanswered: Chart bar values less than 1?


    Hi,
    I have a chart where some of the bar values are less than one, but the bar is not visible. Is there a way to make the bar visible when the value is less than 1?

    thanks

  2. #2
    Sencha User
    Join Date
    Nov 2007
    Posts
    294
    Vote Rating
    0
    Answers
    1
    Sesshomurai is on a distinguished road

      0  

    Default


    Does the bar/column chart support logarithmic scaling?

  3. #3
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Posts
    31
    Vote Rating
    0
    marrrck is on a distinguished road

      0  

    Default


    The answer to your second question, I think, is no, logarithmic scaling isn't implemented yet. And unfortunately it still isn't implemented in 4.1 (at least based on the latest preview release).

    In regards to your first question, the x/y type charts (bar, line, column, etc) do not seem to handle very small numbers very well. I've been wrestling with this problem as well, and it seems like the problem is lines 221-223 in Axis.js:

    Code:
            //normalize min max for snapEnds.
            if (min != max && (max != Math.floor(max))) {
                max = Math.floor(max) + 1;
            }
    What this does, is always set the max of the axis to 1 whenever it is less than one. So if you have a series with max and min values between, say 0.01 and 0.04, this code changes the range displayed in the chart to 0.01 - 1.00. In a chart like this, all the actual columns might not be visible if the chart isn't very tall, since 0.04 is at the very bottom of the scale. Without seeing more specifically what you are trying to do, I can't be sure this is actually the problem you are facing, but what worked for me is overriding the getRange() method in the Numeric axis I was using and just commenting out those lines seemed to worked. For example:

    (this is from my chart definition code):
    Code:
    axes : [
                                    {
                                        type : 'Numeric',
                                        position : 'left',
                                        fields : [ 'totalCost', 'lowCost' ],
                                        title : false,
                                        adjustMinimumByMajorUnit : true,
                                        label : {},
                                        getRange : function() {
                                            var me = this, 
                                            store = me.chart.getChartStore(), 
                                            fields = me.fields, 
                                            ln = fields.length, 
                                            math = Math, 
                                            mmax = math.max, 
                                            mmin = math.min, 
                                            aggregate = false, 
                                            min = isNaN(me.minimum) ? Infinity : me.minimum, 
                                            max = isNaN(me.maximum) ? -Infinity    : me.maximum, 
                                            total = 0, i, l, value, values, rec, 
                                            excludes = [], 
                                            series = me.chart.series.items;
    
    
                                            // if one series is stacked I have to
                                            // aggregate the
                                            // values
                                            // for the scale.
                                            // TODO(zhangbei): the code below does
                                            // not support
                                            // series that stack on 1 side but
                                            // non-stacked axis
                                            // listed in axis config. For example, a
                                            // Area series
                                            // whose axis : ['left', 'bottom'].
                                            // Assuming only stack on y-axis.
                                            // CHANGED BY Nicolas: I removed the
                                            // check `me.position
                                            // == 'left'` and `me.position ==
                                            // 'right'` since
                                            // it was constraining the minmax
                                            // calculation to y-axis
                                            // stacked
                                            // visualizations.
                                            for (i = 0, l = series.length; !aggregate
                                                    && i < l; i++) {
                                                aggregate = aggregate
                                                        || series[i].stacked;
                                                excludes = series[i].__excludes
                                                        || excludes;
                                            }
                                            store
                                                    .each(function(record) {
                                                        if (aggregate) {
                                                            if (!isFinite(min)) {
                                                                min = 0;
                                                            }
                                                            for (values = [ 0, 0 ],
                                                                    i = 0; i < ln; i++) {
                                                                if (excludes[i]) {
                                                                    continue;
                                                                }
                                                                rec = record
                                                                        .get(fields[i]);
                                                                values[+(rec > 0)] += math
                                                                        .abs(rec);
                                                            }
                                                            max = mmax(max,
                                                                    -values[0],
                                                                    +values[1]);
                                                            min = mmin(min,
                                                                    -values[0],
                                                                    +values[1]);
                                                        } else {
                                                            for (i = 0; i < ln; i++) {
                                                                if (excludes[i]) {
                                                                    continue;
                                                                }
                                                                value = record
                                                                        .get(fields[i]);
                                                                max = mmax(max,
                                                                        +value);
                                                                min = mmin(min,
                                                                        +value);
                                                            }
                                                        }
                                                    });
                                            if (!isFinite(max)) {
                                                max = me.prevMax || 0;
                                            }
                                            if (!isFinite(min)) {
                                                min = me.prevMin || 0;
                                            }
                                            // FIXME: this is what is causing the
                                            // max to always be 1?
                                            // normalize min max for snapEnds.
                                            // if (min != max && (max !=
                                            // Math.floor(max))) {
                                            // max = Math.floor(max) + 1;
                                            // }
    
    
                                            if (!isNaN(me.minimum)) {
                                                min = me.minimum;
                                            }
    
    
                                            if (!isNaN(me.maximum)) {
                                                max = me.maximum;
                                            }
    
    
                                            return {
                                                min : min,
                                                max : max
                                            };
                                        }
                                    }, {
                                        type : 'Category',
                                        //.. and so on
                                    } ],
    With this code, my chart's axis correctly displays a range of 0.01 - 0.04 and the columns appear as you would expect.

    Hope this helps. (I'm going to submit a bug for this as well and see what they say)....

    Marc

  4. #4
    Sencha User
    Join Date
    Aug 2011
    Posts
    55
    Vote Rating
    0
    Answers
    3
    brokentwig is on a distinguished road

      0  

    Default


    Not sure if this will help or not, but you might try setting your field types to float in your model. Extjs seems to default to int or string otherwise.

Thread Participants: 2