1. #1
    Ext User
    Join Date
    Jan 2010
    Posts
    5
    Vote Rating
    0
    kamisama is on a distinguished road

      0  

    Exclamation ChartListener for Stacked bar chart

    ChartListener for Stacked bar chart


    Hi, I tried to add chart listener to the stacked bar chart as shown in following codes:
    Code:
                
    
                StackedBarChart barChart = new StackedBarChart();
              
    
                List<StackedBarChart.StackValue> data = new                       
    ArrayList<StackedBarChart.StackValue>();
                data.add(new StackedBarChart.StackValue(100, "#AF1E2D", "Text 1"));
                data.add(new StackedBarChart.StackValue(200, "#006B54", "Text 2"));
                data.add(new StackedBarChart.StackValue(400, "#003F87", "Text 3"));
                barChart.addStack(data);
    
                data = new ArrayList<StackedBarChart.StackValue>();
                data.add(new StackedBarChart.StackValue(200, "#AF1E2D", "Text 1"));
                data.add(new StackedBarChart.StackValue(400, "#006B54", "Text 2"));
                data.add(new StackedBarChart.StackValue(100, "#003F87", "Text 3"));
                barChart.addStack(data);
                
                barChart.addChartListener(new ChartListener() {
                    public void chartClick(ChartEvent ce) {
                        Info.display("Chart Clicked", "Yes");
                    
                    }
                });
    And I got following exception:

    java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.extjs.gxt.charts.client.model.charts.DataConfig


    Can someone help me to figure out how chart listener works for stacked bar chart?

  2. #2
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    and in which line in your example code the error was thrown?
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  3. #3
    Ext User
    Join Date
    Jan 2010
    Posts
    5
    Vote Rating
    0
    kamisama is on a distinguished road

      0  

    Default


    Code:
    barChart.addChartListener(new ChartListener() {
                    public void chartClick(ChartEvent ce) {
                        Info.display("Chart Clicked", "Yes");
                    
                    }
                });
    This part is the exception occurs, I checked GXT source code and compared different
    JSON data from the ChartModel class, I think there is a bug to handle the stacked
    bar chart click event in GXT.

  4. #4
    Ext User
    Join Date
    Jan 2010
    Posts
    5
    Vote Rating
    0
    kamisama is on a distinguished road

      0  

    Default


    Anyone has a idea about this?

  5. #5
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    can you post the full stacktrace of the error?
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  6. #6
    Ext User
    Join Date
    Jan 2010
    Posts
    5
    Vote Rating
    0
    kamisama is on a distinguished road

      0  

    Default


    Here is the full sample code:

    Code:
    import java.util.ArrayList;
    import java.util.List;
    
    import com.extjs.gxt.charts.client.Chart;
    import com.extjs.gxt.charts.client.event.ChartEvent;
    import com.extjs.gxt.charts.client.event.ChartListener;
    import com.extjs.gxt.charts.client.model.ChartModel;
    import com.extjs.gxt.charts.client.model.ToolTip;
    import com.extjs.gxt.charts.client.model.ToolTip.MouseStyle;
    import com.extjs.gxt.charts.client.model.axis.Keys;
    import com.extjs.gxt.charts.client.model.axis.XAxis;
    import com.extjs.gxt.charts.client.model.axis.YAxis;
    import com.extjs.gxt.charts.client.model.charts.StackedBarChart;
    import com.extjs.gxt.ui.client.widget.ContentPanel;
    import com.extjs.gxt.ui.client.widget.Info;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.Element;
    import com.google.gwt.user.client.ui.RootPanel;
    
    public class GXTChartSample implements EntryPoint {
    
        public void onModuleLoad() {
            RootPanel.get().add(new VerticalStackedChart());
        }
    
        class VerticalStackedChart extends ContentPanel {
    
            public VerticalStackedChart() {
                setBorders(false);
                setBodyBorder(false);
                setHeaderVisible(false);
                setHeight(500);
                setWidth(400);
            }
    
            @Override
            protected void onRender(Element parent, int index) {
                super.onRender(parent, index);
                XAxis xAxis = new XAxis();
                xAxis.setMin(0);
                xAxis.setMax(1);
                xAxis.setSteps(1);
    
                YAxis yAxis = new YAxis();
                yAxis.setMin(0);
                yAxis.setMax(100);
                yAxis.setSteps(10);
    
                StackedBarChart barChart = new StackedBarChart();
                barChart.setTooltip("#key# - #val#");
                Keys key1 = new Keys("Key 1", "#AF1E2D", 13);
                Keys key2 = new Keys("Key 1", "#006B54", 13);
                barChart.setKeys(key1,key2);
                List<StackedBarChart.StackValue> data = new ArrayList<StackedBarChart.StackValue>();
                data.add(new StackedBarChart.StackValue(10, "#AF1E2D"));
                data.add(new StackedBarChart.StackValue(20, "#006B54"));
                data.add(new StackedBarChart.StackValue(40, "#AF1E2D"));
                barChart.addStack(data);
                
                barChart.addChartListener(new ChartListener() {
    
                    @Override
                    public void chartClick(ChartEvent ce) {
    
                        Info.display("####3", "****");
    
                    }
    
                });
                
                ChartModel model = new ChartModel();
                model.setXAxis(xAxis);
                model.setYAxis(yAxis);
                model.setTooltipStyle(new ToolTip(MouseStyle.NORMAL));
                model.addChartConfig(barChart);
                
                Chart chart = new Chart("resources/chart/open-flash-chart.swf");
                
                chart.setChartModel(model);
                add(chart);
            }
        }
    }
    Here is the full stacktrace error output:

    Code:
    [ERROR] [gxtchartsample] Unable to load module entry point class com.chartsample.client.GXTChartSample (see associated exception for details)
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.extjs.gxt.charts.client.model.charts.DataConfig
        at com.extjs.gxt.charts.client.Chart.processModel(Chart.java:238)
        at com.extjs.gxt.charts.client.Chart.setChartModel(Chart.java:168)
        at com.chartsample.client.GXTChartSample$VerticalStackedChart.onRender(GXTChartSample.java:81)
        at com.extjs.gxt.ui.client.widget.Component.render(Component.java:971)
        at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1545)
        at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:471)
        at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:417)
        at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:119)
        at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:93)
        at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:75)
        at com.chartsample.client.GXTChartSample.onModuleLoad(GXTChartSample.java:25)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
        at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:619)
    This only happens while I add ChartListener to the stacked bar chart. The chart listener works for all type of charts except stacked one. I am wondering there is a trick for stacked bar chart listener. Anyone get the chart listener working on stacked bar chart?

  7. #7
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
    Arno.Nyhm is on a distinguished road

      0  

    Default


    your example code works well to reproduce the error. i got the same error as you.



    and: i get it working with this (maybe bad) hack.

    and i dont know if it is the right direction and if there are some bad side effencts with this patch:


    i replaced this line:
    PHP Code:
                StackedBarChart barChart = new StackedBarChart(); 
    with this code:

    PHP Code:
    StackedBarChart barChart = new StackedBarChart() {

                    @
    Override
                    
    public List<DataConfiggetValues() {
                        List<
    ArrayList<StackValue>> stackValues getStackValues();
                        
    ArrayList<DataConfignewValues = new ArrayList<DataConfig>();

                        for (
    ArrayList<StackValuearrayList stackValues) {
                            for (
    StackValue stackValue arrayList) {
                                
    newValues.add(stackValue);
                            }

                        }
                        return 
    newValues;
                    }
                }; 
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  8. #8
    Ext User
    Join Date
    Jan 2010
    Posts
    5
    Vote Rating
    0
    kamisama is on a distinguished road

      0  

    Default


    Yep, it is working with chart listener now, thx.
    So, is it bug or sth else?
    Last edited by sven; 5 Feb 2010 at 5:13 AM. Reason: This is a known issue and will be fixed in one of the upcomming releases.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi