Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Bar Chart: Set dynamically series and axe.

  1. #1
    Sencha User
    Join Date
    Jul 2011
    Location
    Holland
    Posts
    98
    Answers
    2

    Default Bar Chart: Set dynamically series and axe.

    In a Bar-chart, I would like to set the series and axe dynamically. I figured out I should use the functions setSeries() and setAxes(). The thing is, they don't work. The graph stays empty.

    When I define the Series and Axes just in the chart-config, it all works fine. But doing that, it's not dynamic anymore.

    I attached a few images to make the case more clear. The code is mockup, I removed some non-relevant parts.

    Could anyone please help me? Thanks.

    Image 1: The chart definition.


    Image 2: The logic



    Image 3: The output. No bars here.

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,108
    Answers
    342

    Default

    Are there any errors in the console?

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Location
    Holland
    Posts
    98
    Answers
    2

    Default

    Nop, not any error in the console. Using Chrome and Safari on Mac.

  4. #4
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,108
    Answers
    342

    Default

    line 56 doesn't look correct Ext.getStore('myStore').record2. Probably should be Ext.getStore('myStore').add(record2)

  5. #5
    Sencha User
    Join Date
    Jul 2011
    Location
    Holland
    Posts
    98
    Answers
    2

    Default

    Hm I see. That's just an error in my mock-up code.

    Will it help if I create an example project and post it online?

  6. #6
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,108
    Answers
    342

    Default

    What debugging have you done so far? I see you are trying to dynamically add a series to a chart, dynamically add an axes and then dynamically adding records to your store.
    I would suggest doing 1 dynamic element at a time while doing the other 2 statically in order to narrow down the scope of the issue.
    You can post a fiddle here: https://fiddle.sencha.com/#home

  7. #7
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,108
    Answers
    342

    Default

    I would start with a static store as I do not believe charts dynamically update on their own when the store data changes. You may have to issue a refresh to the view. At least that was the way in Ext.

  8. #8
    Sencha User
    Join Date
    Jul 2011
    Location
    Holland
    Posts
    98
    Answers
    2

    Default

    Hm yea I should use Fiddle, but somehow it's easier to upload the whole package :p

    Static:
    http://virtual-life.net/meuk/myApp_static/

    Dynamic Series
    http://virtual-life.net/meuk/myApp_dynamic/

    Complete source download (it's about the app.js):
    http://virtual-life.net/meuk/myApp_dynamic/charts.zip

    Just the app.js files:
    http://virtual-life.net/meuk/myApp_d.../app_static.js
    http://virtual-life.net/meuk/myApp_d...app_dynamic.js

    Right now the dynamic series does give an error. I don't really know why. It says
    Uncaught TypeError: Cannot read property 'length' of undefined

    The upload will finish in 5 minutes.

  9. #9

    Default

    Any solution on this one?

  10. #10
    Sencha User
    Join Date
    Jul 2011
    Location
    Holland
    Posts
    98
    Answers
    2

    Default

    Not really, only a workaround. The workaround is to destroy and recreate the whole chart every time it needs to be updated.

Page 1 of 2 12 LastLast

Posting Permissions

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