Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Modifying a chart programmatically

    I am using SmartGWT version v11.1p_2018-02-21/PowerEdition Deployment. I have a grid which I a working with that I wish to display as a chart:

    Click image for larger version

Name:	Grid.JPG
Views:	76
Size:	9.3 KB
ID:	253960

    I am calling ListGrid.chartData() with the Region column as the label field. This results in a nice chart:

    Click image for larger version

Name:	Chart1.JPG
Views:	41
Size:	16.9 KB
ID:	253961

    I then use the popup menu to swap the facets and unstack the bars:

    Click image for larger version

Name:	Chart2.JPG
Views:	40
Size:	17.1 KB
ID:	253962

    Is there a way to programmatically make changes to the FacetChart returned from the call to ListGrid.chartData() so that it appears like this?


    #2
    setStacked(false) controls stacking. As far as swapping facets, you can retrieve the facets array, reverse it, and create new chart from that - the internal logic to swap facets does roughly that, so you wouldn't be doing something slower.

    Another approach is to just create your own chart directly instead of using chartData(). chartData() is actually quite a short method, it just creates a facet definition from the list of fields, then supplies data to the chart.

    Comment

    Working...
    X