Add charttip in code behind

  1. #1

    Add charttip in code behind

    Im trying to add a charttip in code behind with a value of the Xfield, but the value of the xfield dont apear in the charttip.

    How can i make it work?

    Post the code below....

    Please help!

    Thanks
    Last edited by cerqueira81; Jun 21, 2012 at 2:23 PM.
  2. #2
    Please see tip #3 at the following location,

    http://forums.ext.net/showthread.php...ation-Required
    Geoffrey McGill
    Founder
  3. #3

    again

    duplicated post...
    Last edited by cerqueira81; Jun 21, 2012 at 1:28 PM.
  4. #4

    again

    Sorry here my code:

    <%@ Page Language="C#" %>

    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
    CarregarSeries();
    CarregarEixos();
    }

    protected void CarregarSeries()
    {
    Chart1.Series.Clear();

    Ext.Net.ColumnSeries col = new Ext.Net.ColumnSeries();
    col.Axis = Ext.Net.Position.Left;
    col.XField = new string[] { "XField" };
    col.YField = new string[] { "YField1" };
    col.Title = "Visitas";

    Ext.Net.SpriteAttributes.Config cf = new Ext.Net.SpriteAttributes.Config();
    cf.Fill = "#4682B4";

    col.Style = new Ext.Net.SpriteAttributes();
    col.Style.Fill = new Ext.Net.SpriteAttributes(cf).Fill;

    Ext.Net.ChartTip.Config tp = new Ext.Net.ChartTip.Config
    {
    TrackMouse = true,
    Width = 200,
    Height = 30,
    ItemID = "tip1"
    };
    //tp.Title = "";

    tp.Renderer.Handler = "this.setTitle('Hora: ' + storeItem.get('XField') + ' Qtde Visitas: ' + storeItem.get('YField1') );"; here the problem... this doesnt work....

    col.Tips = new Ext.Net.ChartTip(tp);

    Chart1.Series.Add(col);
    }

    protected void CarregarEixos()
    {
    Chart1.Axes.Clear();

    Ext.Net.NumericAxis axis = new Ext.Net.NumericAxis();
    Ext.Net.CategoryAxis caxis = new Ext.Net.CategoryAxis();

    axis.Fields = new string[] { "YField1", "YField2", "YField3" };
    axis.Title = Tituloeixoy;
    axis.Grid = true;
    axis.Minimum = 0;

    caxis.Position = Ext.Net.Position.Bottom;
    caxis.Fields = new string[] { "XField" };
    caxis.Title = Tituloeixox;

    Ext.Net.SpriteAttributes.Config cf = new Ext.Net.SpriteAttributes.Config();
    cf.Font = "9px Arial";

    caxis.Label = new Ext.Net.AxisLabel();
    caxis.Label.Font = new Ext.Net.SpriteAttributes(cf).Font;

    axis.Label = new Ext.Net.AxisLabel();
    axis.Label.Font = new Ext.Net.SpriteAttributes(cf).Font;

    Ext.Net.SpriteAttributes.Config cft = new Ext.Net.SpriteAttributes.Config();
    cft.Font = "14px Arial";

    caxis.LabelTitle = new Ext.Net.AxisLabel();
    caxis.LabelTitle.Font = new Ext.Net.SpriteAttributes(cft).Font;

    axis.LabelTitle = new Ext.Net.AxisLabel();
    axis.LabelTitle.Font = new Ext.Net.SpriteAttributes(cft).Font;

    Chart1.Axes.Add(axis);
    Chart1.Axes.Add(caxis);

    this.Chart1.Render();
    }

    protected DataTable CarregarDados()
    {
    DataSet ds = new DataSet();
    BaseAccess db = new BaseAccess();

    db.CommandText = Sql;

    db.CommandType = CommandType.Text;

    db.AddParameter("?codigocliente", Session["codigocliente"]);

    ds = db.ExecuteDataSet(db.CommandText);

    return ds.Tables[0];

    }
    </script>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Ext.NET Example</title>
    </head>
    <body>
    <form runat="server">
    <ext:ResourceManager runat="server" />

    <ext:Panel ID="Panel1"
    runat="server"
    Width="600"
    Height="300"
    Layout="FitLayout"
    AutoHeight="true">

    <Items>
    <ext:Chart ID="Chart1"
    runat="server"
    Shadow="true"
    Theme="White"
    Animate="true"
    AutoSize="True">
    <LegendConfig Position="Top" />
    <Store>
    <ext:Store ID="Store1"
    runat="server"
    DataSource="<%# CarregarDados() %>"
    AutoDataBind="true">
    <Model>
    <ext:Model ID="Model1" runat="server">
    <Fields>
    <ext:ModelField Name="XField" />
    <ext:ModelField Name="YField1" />
    <ext:ModelField Name="YField2" />
    <ext:ModelField Name="YField3" />
    <ext:ModelField Name="YField4" />
    </Fields>
    </ext:Model>
    </Model>
    </ext:Store>
    </Store>
    <Background>
    <Gradient GradientID="backgroundGradient" Angle="45">
    <Stops>
    <ext:GradientStop Offset="0" Color="#FFFFFF" />
    <ext:GradientStop Offset="100" Color="#D3D3D3" />
    </Stops>
    </Gradient>
    </Background>

    </ext:Chart>
    </Items>
    </ext:Panel>
    </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Add ChartTip to BarSeries
    By T3rryChan in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jul 09, 2012, 4:16 PM
  2. [CLOSED] [Razor] How to use ChartTip?
    By Stijn in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Jun 05, 2012, 12:34 PM
  3. Replies: 2
    Last Post: Feb 01, 2012, 6:56 AM
  4. Replies: 1
    Last Post: Jul 07, 2011, 8:34 PM
  5. Convert FormPanel from Html-Code to VB.Net Code
    By stephan1985 in forum 1.x Help
    Replies: 1
    Last Post: Jan 27, 2010, 3:47 PM

Posting Permissions