1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Dallas/Fort Worth
    Posts
    43
    Vote Rating
    2
    ben.gillis is on a distinguished road

      0  

    Default Unanswered: onCreateLabel does not provide documented arguments

    Unanswered: onCreateLabel does not provide documented arguments


    onCreateLabel says it gets four arguments: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.chart.Label.

    I
    t is only receiving one argument, the storeItem, when I specify this:


    label: {
    field: 'BusinessUnitName',
    display: 'rotate',
    contrast: true,
    font: '14px Calibri',
    renderer: function (storeItem, item, i, display) { // <=== item, i and display all undefined
    ...
    }
    }

    I tried the above per this answer in the forum: http://www.sencha.com/forum/showthre...=onCreateLabel.


    Trying the following, it is never called.

    label: {
    field: 'BusinessUnitName',
    display: 'rotate',
    contrast: true,
    font: '14px Calibri',
    onCreateLabel: function (storeItem, item, i, display) { // <=== item, i and display all undefined
    ...
    }
    }

    There are no examples on this, e.g. http://docs.sencha.com/ext-js/4-0/#!/api/Ext.chart.Label



    It's just one's and zero's, what could go wrong?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I would not use onCreateLabel as it is private and internal code is using the method. The renderer only has the two arguments as documented.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Dallas/Fort Worth
    Posts
    43
    Vote Rating
    2
    ben.gillis is on a distinguished road

      0  

    Default


    I'm getting one argument. Is this the wrong way to use renderer?

    label: {
    field: 'BusinessUnitName',
    display: 'rotate',
    contrast: true,
    font: '14px Calibri',
    renderer: function (storeItem, item, i, display) { // <=== item, i and display all undefined
    ...
    }
    }


    fwiw, when labels don't print, I get 'undefined' for all my legend items. They are one-in-the same? My legend is defined as:

    legend: {
    position: 'right',
    labelFont: '0.8em Arial'
    },
    It's just one's and zero's, what could go wrong?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The renderer on the label config object will have two arguments, the storeItem and item. The labels and legend should be independent of one and another.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Location
    Dallas/Fort Worth
    Posts
    43
    Vote Rating
    2
    ben.gillis is on a distinguished road

      0  

    Default


    > The labels and legend should be independent of one and another.
    If my labels aren't printed, then my legend items are all 'undefined'. I don't see enough in the doc to know where to start figuring out why.

    If I do not specify labels, I get 'undefined' in the legend doing this:

    var items = {
    xtype: 'chart',
    style: 'background:#FDF7D0',
    animate: true,
    store: _dataStore,
    shadow: true,
    legend: {
    position: 'right',
    labelFont: '0.8em Arial'
    },
    insetPadding: 4,
    theme: 'Base:gradients',
    series: [{
    type: 'pie',
    field: 'Consumption',
    showInLegend: true,
    donut: false,
    highlight: {
    segment: {
    margin: 20
    }
    }


    }]
    }
    _winMyChart.removeAll();
    _winMyChart.add(items);
    It's just one's and zero's, what could go wrong?

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The renderer won't take affect until you mouse over it and the tooltip pops up
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Sencha User
    Join Date
    Oct 2011
    Location
    Dallas/Fort Worth
    Posts
    43
    Vote Rating
    2
    ben.gillis is on a distinguished road

      0  

    Default


    Also, regarding the "I am only getting one argument" in the label renderer. The label callback doesn't give the callback function enough information for me to tell what to render for the label.

    This is a column chart.

    There are two data items plotted in side-by-side columns. Here's my dataStore:

    var dataStore = Ext.create('Ext.data.JsonStore', {
    fields: ['MyColumnType', 'Column1Volume', 'Column2Volume'],
    data: Data
    })

    So, ... in my label callback I want to specify a label above each column with it's corresponding volume:

    label: {
    display: 'outside',
    'text-anchor': 'middle',
    field: '???', // If I specify Column1Volume, that's all I get. Ditto for Column2Volume
    renderer: Ext.util.Format.numberRenderer('0,0'),
    orientation: 'horizontal',
    color: '#333'//,
    renderer: function (storeItem, item) {
    // HOW DO I KNOW IF COLUMN 1 OR 2???
    // ALL THAT IS BEING RECEIVED IS A NUMBER IN 'storeItem' and 'item' is undefined.
    }
    It's just one's and zero's, what could go wrong?

  8. #8
    Sencha User
    Join Date
    Oct 2011
    Location
    Dallas/Fort Worth
    Posts
    43
    Vote Rating
    2
    ben.gillis is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    ...The renderer only has the two arguments as documented.
    Per this, the renderer has only one argument, the value:

    renderer
    : FunctionOptional function for formatting the label into a displayable value. Default value: function(v) { return v; }

    (See http://docs.sencha.com/ext-js/4-0/#!...xt.chart.Label)

    Therefore, how can the label callback tell to which item the one-and-only value applies to?
    It's just one's and zero's, what could go wrong?

Thread Participants: 1