Results 1 to 4 of 4

Thread: Custom renderer function for chart legend labels

  1. #1
    Sencha User
    Join Date
    Sep 2018
    Posts
    2
    Vote Rating
    0
      0  

    Default Answered: Custom renderer function for chart legend labels

    Hello
    I'd like to apply custom renderer function to chart legend fields. That is if text displayed in the legend field is too long, trim it and add some other logic. I'm attaching the fragment of code that I thought would work for me, but it does not. I'm using ExtJs 6.2.0


    Code:
    series: [{   
     type: seriesType,
        angleField: angleField,
        donut: donut,
        label: {
            field: labelField,
        },
        renderer: function (sprite, config, rendererData, index) {
    var label = rendererData.store.getData().items[index].get('Name');
    return {text : label.substr(0,8)};
        },
    }],

  2. Hello,

    There is no renderer method for chart legend. By default legend takes same text as label.


    You can use label's renderer method to customize text for the label and set a custom field with value converted in store as label's field which will be set as text for legend.


    Please see the fiddle where I have truncated names as you described :
    https://fiddle.sencha.com/#view/editor&fiddle/2nbd

    Regards,
    Kumar
    Sencha Support.

  3. #2
    Ext Team Member
    Join Date
    Sep 2017
    Posts
    624
    Answers
    3
    Vote Rating
    -303
      -1  

    Default

    Hello- I have sent this over to the support team. They will reach out to you at their earliest convenience to provide assistance. Thank you for your patience!

    Michele

  4. #3
    Ext Support Team
    Join Date
    Jan 2018
    Posts
    91
    Answers
    2
    Vote Rating
    -131
      1  

    Default

    Hello,

    There is no renderer method for chart legend. By default legend takes same text as label.


    You can use label's renderer method to customize text for the label and set a custom field with value converted in store as label's field which will be set as text for legend.


    Please see the fiddle where I have truncated names as you described :
    https://fiddle.sencha.com/#view/editor&fiddle/2nbd

    Regards,
    Kumar
    Sencha Support.

  5. #4
    Sencha User
    Join Date
    Sep 2018
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Thanks. It's a nice workaround for my problem.

Similar Threads

  1. Pie chart without labels (but with a legend)
    By paulg@ibcos in forum Ext 5: Q&A
    Replies: 4
    Last Post: 7 Nov 2014, 7:41 AM
  2. Replies: 4
    Last Post: 14 Aug 2014, 9:08 AM
  3. Add renderer in Chart Pie legend
    By fabio.policeno in forum Ext: Q&A
    Replies: 4
    Last Post: 26 Oct 2012, 2:43 AM
  4. Radar chart legend labels are on top of each other
    By hallikpapa in forum Ext: Discussion
    Replies: 0
    Last Post: 11 May 2011, 8:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •