[CLOSED] show only whole numbers instead of decimals in the “Y” axis in chart

Page 2 of 2 FirstFirst 12
  1. #11
    Quote Originally Posted by Baidaly View Post
    You should initialize Label field before setting Renderer:

    <%@ Page Language="C#" %>
    <%@ Import Namespace="Ext.Net.Examples" %>
     
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
     
    <script runat="server">
         
        protected void Page_Load(object sender, EventArgs e)
        {
            Chart1.Axes.Add(new NumericAxis
                {
                    Fields = new[] { "Data1" },
                    Position = Position.Bottom,
                    Grid = true,
                    Minimum = 0,
                    Label = new AxisLabel()
                });
            Chart1.Axes.Add(new CategoryAxis
                {
                    Fields = new[] { "Name" },
                    Position = Position.Left,
                    Title = "Month of the Year"
                });
            Chart1.Axes[0].Label.Renderer.Handler = @"
                                        if (value.toString().indexOf('.') === -1){
                                            return value;
                                        } else {
                                            return '';
                                        }";
        }
        public List<ChartData> Data
        {
            get
            {
                return new List<ChartData>
                    {
                        new ChartData() { Name = "1", Data1 = 1 },
                        new ChartData() { Name = "2", Data1 = 2.4 },
                        new ChartData() { Name = "3", Data1 = 3.6 },
                        new ChartData() { Name = "4", Data1 = 5 },
                    };
            }
        }
     
    </script>
     
    <!DOCTYPE html>
     
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
     
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
     
            <ext:Panel
                runat="server"
                Title="Bar Chart"
                Width="800"
                Height="600"
                Layout="FitLayout">
                <Items>
                    <ext:Chart
                        ID="Chart1"
                        runat="server"
                        Shadow="true"
                        Animate="true">
                        <Store>
                            <ext:Store
                                runat="server"
                                Data="<%# Data %>" 
                                AutoDataBind="true">                           
                                <Model>
                                    <ext:Model runat="server">
                                        <Fields>
                                            <ext:ModelField Name="Name" />
                                            <ext:ModelField Name="Data1" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
     
                        <Axes>
                                                 
                        </Axes>
     
                        <Series>
                            <ext:BarSeries
                                Axis="Bottom"
                                Highlight="true"
                                XField="Name"
                                YField="Data1">
                                <Tips TrackMouse="true" Width="140" Height="28">
                                    <Renderer Handler="this.setTitle(storeItem.get('Name') + ': ' + storeItem.get('Data1') + ' views');" />
                                </Tips>
                                <Label
                                    Display="InsideEnd"
                                    Field="Data1"
                                    Orientation="Horizontal"
                                    Color="#333"
                                    TextAnchor="middle"
                                    />
                            </ext:BarSeries>
                        </Series>
                    </ext:Chart>
                </Items>
            </ext:Panel>
        </form>    
    </body>
    </html>
    }


    not working,

    this code:

    Dim store = chrtGraficaIndicesDePersonal.GetStore
    
                    store.Model.Clear()
                    store.Reader.Clear()
                    Dim m = New Model
                    m.Name = "Mod"
                    m.Fields.Add(New ModelField("Cantidad"))
                    m.Fields.Add(New ModelField("NombreMes"))
                    Dim AxesX = New CategoryAxis()
                    Dim AxesY = New NumericAxis()
    
                    AxesY.Fields = {"Cantidad"}
                    AxesY.Grid = True
                    AxesY.Title = "Asegurados"
                    AxesY.Minimum = 0
                    AxesY.Label = New Ext.Net.AxisLabel()
    
                    AxesY.Position = Position.Left
    
                    AxesX.Fields = {"NombreMes"}
                    AxesX.Position = Position.Bottom
                    AxesX.Title = "Periodos"
    
                    Dim MySerie = New ColumnSeries
                    MySerie.SeriesID = "IdSerie"
                    MySerie.Axis = Position.Left
                    MySerie.Highlight = True
    
                    MySerie.XField = {"NombreMes"}
                    MySerie.YField = {"Cantidad"}
                    Dim tp As New Ext.Net.ChartTip.Config
                    tp.TrackMouse = True
                    tp.Width = 200
                    tp.Height = 30
                    tp.ItemID = "tip"
                    MySerie.Tips = New Ext.Net.ChartTip(tp)
                    MySerie.Tips.Renderer.Handler = "this.setTitle(storeItem.get('NombreMes') + ': ' + storeItem.get('Cantidad'));"
                  
                    chrtGraficaIndicesDePersonal.Series.Add(MySerie)
                    chrtGraficaIndicesDePersonal.Legend = True
                    chrtGraficaIndicesDePersonal.Axes.Add(AxesY)
                    chrtGraficaIndicesDePersonal.Axes.Add(AxesX)
                    chrtGraficaIndicesDePersonal.Axes(0).Label.Renderer.Handler = "if (value.toString().indexOf('.') === -1){return value;} else {Return '';}"
    
                    Dim a = chrtGraficaIndicesDePersonal.GetSprite("Titulo")
                    a.Text = "Indices de personal del " + iAnio.ToString() + " - " + strConcepto
                    
                    store.Model.Add(m)
                    store.DataSource = ocData
                    store.DataBind()
                    chrtGraficaIndicesDePersonal.Render(True)
    
    
    thanks!
  2. #12
    What error do you receive? Can you provide full test case to reproduce?
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 1
    Last Post: Nov 25, 2013, 5:13 PM
  2. [OPEN] [#192] Chart axis setTitle
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 10, 2013, 6:02 PM
  3. [CLOSED] Chart - Decimals Number
    By pdcase in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 22, 2012, 7:46 AM
  4. Replies: 2
    Last Post: Aug 13, 2012, 2:12 PM
  5. [CLOSED] Area chart starting axis
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 05, 2012, 8:56 PM

Posting Permissions