1. #1
    Sencha Premium Member
    Join Date
    Feb 2013
    Posts
    9
    Vote Rating
    0
    svasilak is on a distinguished road

      0  

    Default In Barchart cannot set corresponding labelField for each yField specified?

    In Barchart cannot set corresponding labelField for each yField specified?


    In the Barchart I cannot set corresponding labelField values for each yField specified. Is there a workaround?

    I have a Barchart for which in the Ext.chart.series.Bar I have two (2) yField datastore columns specified to show side by side bars of both fields. I would like a textual label to indicate the value for each bar. This only seems possible for exactly one (1) yField as labelField is a dropdown accepting only a single value to correspond to all yFields.

  2. #2
    Sencha - Architect Dev Team
    Join Date
    Jan 2009
    Location
    Frederick, Maryland
    Posts
    857
    Vote Rating
    32
    jminnick has a spectacular aura about jminnick has a spectacular aura about

      0  

    Default


    Quote Originally Posted by svasilak View Post
    In the Barchart I cannot set corresponding labelField values for each yField specified. Is there a workaround?

    I have a Barchart for which in the Ext.chart.series.Bar I have two (2) yField datastore columns specified to show side by side bars of both fields. I would like a textual label to indicate the value for each bar. This only seems possible for exactly one (1) yField as labelField is a dropdown accepting only a single value to correspond to all yFields.
    You can use Process Config as a workaroud. There you can do something like this:

    Code:
        config.series:[{
             ...
        }]
    
        return config;
    Jason Minnick
    Sencha Architect Development Team

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2013
    Posts
    9
    Vote Rating
    0
    svasilak is on a distinguished road

      0  

    Default


    Thanks for the info on process config. I can use this in a number places.

    For the labelField specifying an array of more than one field to correspond to each yField does not work in the Barchart. Please let me know if I am missing something here.

    Given:

    yField: ['wins','losses']

    This:

    labelField: ['wins','losses']

    does not work for me. No label is rendered.

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    ckd is on a distinguished road

      0  

    Default


    The labelField is meant to be a string, but then it draws the same label on each yField sprite which is a bug.

    This can be fixed by overriding Ext.chart.series.Series's updateLabelData method like this :

    updateLabelData: function () {
    var me = this,
    store = me.getStore(),
    items = store.getData().items,
    sprites = me.getSprites(),
    labelField = Ext.isArray(me.getLabelField())?me.getLabelField():[me.getLabelField()],
    i, ln, ln2, labels;
    if (sprites.length > 0) {
    for (i = 0, ln = sprites.length; i < ln; i++) {
    var field = sprites[i]._field;
    if (field && Ext.Array.contains(labelField, field)) {
    labels = [];

    for (j = 0, ln2 = items.length; j < ln2; j++) {
    labels.push(items[j].get(field));
    }
    sprites[i].setAttributes({labels: labels});
    }
    }
    }
    },

    With this you can pass in an array or a string for labelFields, and it'll draw the correct label on each sprite

  5. #5
    Sencha Premium Member
    Join Date
    Feb 2013
    Posts
    9
    Vote Rating
    0
    svasilak is on a distinguished road

      0  

    Default


    Yes it works perfectly now.

    Thanks kindly!

Thread Participants: 2