[OPEN] [#377] Bug report in V 2.2.0

  1. #1

    [OPEN] [#377] Bug report in V 2.2.0

    Hello

    I just encounter a bug to set the maximum value on an axis chart.

    Here a code example:
    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        public string[] COLORS = new string[]{"rgb(47, 162, 223)", "rgb(60, 133, 46)", "rgb(234, 102, 17)", "rgb(154, 176, 213)", "rgb(186, 10, 25)", "rgb(40, 40, 40)", "rgb(60, 60, 60)"};
        
        protected void Page_Load(object sender, EventArgs e)
        {
            List<object> data = new List<object> 
            { 
                new { Date = new DateTime(2009, 1, 1),  IE = 44.8, Firefox = 45.5, Chrome = 3.9,  Safari = 3,   Opera = 2.3, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 2, 1),  IE = 43.6, Firefox = 46.4, Chrome = 4,    Safari = 3,   Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 3, 1),  IE = 43.3, Firefox = 46.5, Chrome = 4.2,  Safari = 3.1, Opera = 2.3, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 4, 1),  IE = 42.1, Firefox = 47.1, Chrome = 4.9,  Safari = 3,   Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 5, 1),  IE = 41,   Firefox = 47.7, Chrome = 5.5,  Safari = 3,   Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 6, 1),  IE = 40.7, Firefox = 47.3, Chrome = 6,    Safari = 3.1, Opera = 2.1, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 7, 1),  IE = 39.4, Firefox = 47.9, Chrome = 6.5,  Safari = 3.3, Opera = 2.1, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 8, 1),  IE = 39.3, Firefox = 47.4, Chrome = 7,    Safari = 3.3, Opera = 2.1, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 9, 1),  IE = 39.6, Firefox = 46.6, Chrome = 7.1,  Safari = 3.6, Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 10, 1), IE = 37.5, Firefox = 47.5, Chrome = 8,    Safari = 3.8, Opera = 2.3, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 11, 1), IE = 37.7, Firefox = 47,   Chrome = 8.5,  Safari = 3.8, Opera = 2.3, Other = 25, Max=50 },
                new { Date = new DateTime(2009, 12, 1), IE = 37.2, Firefox = 46.4, Chrome = 9.8,  Safari = 3.6, Opera = 2.3, Other = 25, Max=50 },                
                new { Date = new DateTime(2010, 1, 1),  IE = 36.2, Firefox = 46.3, Chrome = 10.8, Safari = 3.7, Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 2, 1),  IE = 35.3, Firefox = 46.5, Chrome = 11.6, Safari = 3.8, Opera = 2.1, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 3, 1),  IE = 34.9, Firefox = 46.2, Chrome = 12.3, Safari = 3.7, Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 4, 1),  IE = 33.4, Firefox = 46.4, Chrome = 13.6, Safari = 3.7, Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 5, 1),  IE = 32.2, Firefox = 46.9, Chrome = 14.5, Safari = 3.5, Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 6, 1),  IE = 31,   Firefox = 46.6, Chrome = 15.9, Safari = 3.6, Opera = 2.1, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 7, 1),  IE = 30.4, Firefox = 46.4, Chrome = 16.7, Safari = 3.4, Opera = 2.3, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 8, 1),  IE = 30.7, Firefox = 45.8, Chrome = 17,   Safari = 3.5, Opera = 2.3, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 9, 1),  IE = 31.1, Firefox = 45.1, Chrome = 17.3, Safari = 3.7, Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 10, 1), IE = 29.7, Firefox = 44.1, Chrome = 19.2, Safari = 3.9, Opera = 2.2, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 11, 1), IE = 28.6, Firefox = 44,   Chrome = 20.5, Safari = 4.0, Opera = 2.3, Other = 25, Max=50 },
                new { Date = new DateTime(2010, 12, 1), IE = 27.5, Firefox = 43.5, Chrome = 22.4, Safari = 3.8, Opera = 2.2, Other = 25, Max=50 }
            };
    
            Store store = this.Chart1.GetStore();
            
            store.DataSource = data;
            store.DataBind();
        }
    </script> 
        <script>
            var fixeMaxValueForChart = function (store, data) {
                App.Chart1.axes.items[0].maximum = 10;
                App.Chart1.redraw();
            }
        </script>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Area BrowserStats - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />   
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
            <h1>Area - BrowserStats</h1>
    
            <p>Display browser usage trends in an area series.</p>
            
            <p>This chart uses custom gradients for the colors and the legend is interactive.</p>
            
            <p>Click or hover on the legend items to highlight and remove them from the chart</p>
    
            <ext:ChartTheme ID="ChartTheme1" 
                runat="server" 
                ThemeName="Browser" 
                Colors="<%# COLORS %>"
                AutoDataBind="true"
                />            
    
            <ext:Panel ID="Panel1" 
                runat="server"
                Title="What is the trend in Browser Usage?"
                Width="800"
                Height="600"
                Layout="FitLayout">           
                <Items>
                    <ext:Chart 
                        ID="Chart1" 
                        runat="server"
                        StyleSpec="background:#fff;"                   
                        Animate="true">
                        <LegendConfig Position="Right" />
                        <Store>
                            <ext:Store ID="Store1" runat="server">                           
                                <Model>
                                    <ext:Model ID="Model1" runat="server">
                                        <Fields>
                                            <ext:ModelField Name="Date" Type="Date" />
                                            <ext:ModelField Name="IE" />
                                            <ext:ModelField Name="Chrome" />
                                            <ext:ModelField Name="Firefox" />
                                            <ext:ModelField Name="Safari" />
                                            <ext:ModelField Name="Opera" />
                                            <ext:ModelField Name="Other" />
                                            <ext:ModelField Name="Max" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                                <Listeners>
                                    <Load Fn="fixeMaxValueForChart"></Load>
                                </Listeners>
                            </ext:Store>
                        </Store>
                        <Axes>
                            <ext:NumericAxis                             
                                Fields="IE,Chrome,Firefox,Safari,Opera,Other, Max"
                                Title="Usage %"
                                Grid="true"
                                Decimals="0"
                                />
                            <ext:CategoryAxis 
                                Position="Bottom"
                                Fields="Date"
                                Title="Month of the Year"
                                Grid="true">
                                <Label>
                                    <Renderer Handler="return Ext.Date.format(value, 'M d');" />
                                </Label>
                            </ext:CategoryAxis>
                        </Axes>
                        <Series>
                            <ext:LineSeries Axis="Left" XField="Date" YField="IE" Title="IE">
                            </ext:LineSeries>
                            <ext:LineSeries Axis="Left" XField="Date" YField="Chrome" Title="Chrome">
                            </ext:LineSeries>
                            <ext:LineSeries Axis="Left" XField="Date" YField="Firefox" Title="Firefox">
                            </ext:LineSeries>
                            <ext:LineSeries Axis="Left" XField="Date" YField="Safari" Title="Safari">
                            </ext:LineSeries>
                            <ext:LineSeries Axis="Left" XField="Date" YField="Opera" Title="Opera">
                            </ext:LineSeries>
                            <ext:LineSeries Axis="Left" XField="Date" YField="Max" Title="Max">
                            </ext:LineSeries>
                            <ext:AreaSeries 
                                Axis="Left"
                                Highlight="true"
                                YField="Other, Max">
                                    <Style Opacity="0.86" StrokeWidth="1" Stroke="#666"  />
                                </ext:AreaSeries>
                        </Series>
                    </ext:Chart>
                </Items>
            </ext:Panel>
        </form>    
    </body>
    </html>
    The max value is well set but the chart is not redrawn.

    Result compile against 2.1 version, works as wanted:

    Click image for larger version. 

Name:	21.png 
Views:	11 
Size:	37.8 KB 
ID:	7190

    And 2.2 version, didn't work:
    Click image for larger version. 

Name:	22.png 
Views:	10 
Size:	58.5 KB 
ID:	7189

    To note that text display in upper window is different too.
    Last edited by Baidaly; Nov 12, 2013 at 2:42 AM. Reason: [OPEN] [#377]
  2. #2
    Hi @feanor91,

    For some reason, the maximum setting is ignored with stacked charts. It is written in the docs:
    http://docs.sencha.com/extjs/4.2.1/#...ic-cfg-maximum

    See also the comments. Two developers disagree. Yes, it looks weird.

    Well, I can suggest to try this override.
    Ext.chart.axis.Numeric.override({
        processView: function() {
            var me = this,
                chart = me.chart,
                series = chart.series.items,
                i, l;
    
            for (i = 0, l = series.length; i < l; i++) {
                if (series[i].stacked) {
                    // Do not constrain stacked charts (bar, column, or area).
                    delete me.minimum;
                    //delete me.maximum; 
                    me.constrain = false;
                    break;
                }
            }
    
            if (me.constrain) {
                me.doConstrain();
            }
        }
    });
  3. #3
    Thanks Daniil, effectively, it looks weird...Is a bug/improvment report oppened? If not, may be good to have one, because in either way, maximum value computed by default for my chart is tottaly silly.

    By the way, I will try your code and report back.
  4. #4
  5. #5
    Quote Originally Posted by Daniil View Post
    Thanks a lot.
  6. #6
    Quote Originally Posted by Daniil View Post
    Hi @feanor91,

    For some reason, the maximum setting is ignored with stacked charts. It is written in the docs:
    http://docs.sencha.com/extjs/4.2.1/#...ic-cfg-maximum

    See also the comments. Two developers disagree. Yes, it looks weird.

    Well, I can suggest to try this override.
    Ext.chart.axis.Numeric.override({
        processView: function() {
            var me = this,
                chart = me.chart,
                series = chart.series.items,
                i, l;
    
            for (i = 0, l = series.length; i < l; i++) {
                if (series[i].stacked) {
                    // Do not constrain stacked charts (bar, column, or area).
                    delete me.minimum;
                    //delete me.maximum; 
                    me.constrain = false;
                    break;
                }
            }
    
            if (me.constrain) {
                me.doConstrain();
            }
        }
    });
    Hello

    Finally I have some time to continue test.

    I'm not fammiliar with overriding ext function. Please can you bee more clear on where I put that code? I think it is c# code but I get a lot of errors when putting code into my example.
  7. #7
    It is JavaScript.
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script type="text/javascript">
            /* the override goes here */
        </script>
    </head>
  8. #8
    Works perfectly, thanks a lot

Similar Threads

  1. [CLOSED] Bug on Chart Report
    By pandeyd in forum 2.x Help
    Replies: 2
    Last Post: Nov 01, 2013, 4:27 AM
  2. [CLOSED] Crystal Report
    By FpNetWorth in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Dec 19, 2012, 4:03 PM
  3. Replies: 3
    Last Post: Jan 09, 2012, 10:09 PM
  4. Crystal Report and Ext.net
    By sonlas7y20 in forum 1.x Help
    Replies: 7
    Last Post: Dec 29, 2011, 2:27 PM
  5. Report in new Tab FF/IE
    By Maia in forum 1.x Help
    Replies: 1
    Last Post: Jun 10, 2009, 3:23 PM

Posting Permissions