Results 1 to 4 of 4

Thread: BarSeries.drawLabels() doesn't account for multiple yFields, throws NPEs

    Success! Looks like we've fixed this one. According to our records the fix was applied for a bug in our system in a recent build.
  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
      0  

    Default BarSeries.drawLabels() doesn't account for multiple yFields, throws NPEs

    I have a BarSeries with 2 yFields and a labelConfig. My store has 9 items, so with two yFields that means there are 18 rects drawn. BarSeries.calculatePaths() has logic that alternates between the two fields for each of the 9 items. BarSeries.drawLabels(), however, does not -- it uses the number of rects to try to get the labels, so it's inaccurate and throws an exception once you exceed the store's bounds.

    You should be able to reproduce this by adding a labelConfig to your grouped barchart example.

  2. #2
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
      0  

    Default found a workaround

    BarSeries should override setLabelText. In the meantime, here's my workaround (the difference is the call to getStoreIndex):

    public class MyOtherBarSeries<M> extends BarSeries<M>
    {
    @Override
    protected void setLabelText(Sprite sprite, int index) {
    if (sprite instanceof TextSprite) {
    TextSprite text = (TextSprite) sprite;
    if (labelConfig.getLabelProvider() != null) {
    text.setText(labelConfig.getLabelProvider().getLabel(chart.getCurrentStore().get(getStoreIndex(index)),
    getValueProvider(index)));
    }
    }
    }
    }

  3. #3
    Sencha User BrendanC's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Vote Rating
    3
      0  

    Default

    Thanks for bringing this to my attention. This has now been fixed and will be in the next release.

  4. #4
    Sencha User BrendanC's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Vote Rating
    3
      0  

    Default

    GXT 3.0.1 has been released and contains this fix.

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
  •