I have a repeater in my page and i try to use a stepline with the repeater.
in the itemdatabound th bind the data to the chart by filtering. I checked the data after filter and i found all things are ok.
My problem is that the page display the stepline charts but the it repeat the same data in all the charts. I think that is a problem in the chart when it tries to generate the data.
Have you any idea why the chart does not display the data correctly?
Thank you in advance.
I'm not really sure what is your logic, but try coping the data in an array before set it as data source to the Chart. Just try adding:
...
uc.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:##.##>";
object[] objData = new object[dv.Count];
dv.CopyTo(objData, 0);
uc.Data.DataSource = objData;
uc.Data.IncludeColumn(0, true);
I tried the same code with a ListBox and it works fine. But when i use a chart control it does not works.
Here is my code with a chart control.
******************In my page************************
<body> <form id="form1" runat="server"> <div> <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound"> <HeaderTemplate> Liste des graphes </HeaderTemplate> <ItemTemplate> </BR> Region : <%# DataBinder.Eval(Container.DataItem, "Region") %> <igchart:UltraChart ID="UltraChart1" runat="server" EmptyChartText="Data Not Available." Version="8.3"> </igchart:UltraChart> </ItemTemplate> </asp:Repeater> </div> </form></body>
****************************************************
***********************In my code behind********************
using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;
using Infragistics.WebUI.UltraWebChart;using Infragistics.UltraChart.Shared.Styles;
namespace ChartsTutorials.Repeater{ public partial class StepLineRepeater : System.Web.UI.Page { DataSet ds = new DataSet(); DataTable dataTable;
protected void Page_Load(object sender, EventArgs e) { DataTable regionTable = ds.Tables.Add("Regiontbl");
regionTable.Columns.Add("RegionId", typeof(int)); regionTable.Columns.Add("Region", typeof(string)); regionTable.Rows.Add(1, "Laval"); regionTable.Rows.Add(2, "MTL"); regionTable.Rows.Add(3, "QC");
dataTable = ds.Tables.Add("Data"); DateTime today = DateTime.Now; dataTable.Columns.Add("DateTime", typeof(DateTime)); dataTable.Columns.Add("dt1", typeof(int)); dataTable.Columns.Add("RegionId", typeof(int)); dataTable.Columns.Add("Id", typeof(int)); dataTable.Rows.Add(today, 0, 1, 1); dataTable.Rows.Add(today.AddMinutes(5), 10, 1, 2); dataTable.Rows.Add(today.AddMinutes(10), -20, 1, 3); dataTable.Rows.Add(today.AddMinutes(15), null, 1, 4); dataTable.Rows.Add(today.AddMinutes(20), 40, 2, 5); dataTable.Rows.Add(today.AddMinutes(25), 110, 2, 6); dataTable.Rows.Add(today.AddMinutes(30), 120, 2, 7); dataTable.Rows.Add(today.AddMinutes(35), -130, 2, 8); dataTable.Rows.Add(today.AddMinutes(40), -140, 2, 9); dataTable.Rows.Add(today.AddMinutes(30), 10, 3, 7); dataTable.Rows.Add(today.AddMinutes(35), 20, 3, 8); dataTable.Rows.Add(today.AddMinutes(40), 60, 3, 9);
ds.Relations.Add("RegionWithData", regionTable.Columns["RegionId"], dataTable.Columns["RegionId"]);
Repeater1.DataSource = regionTable; Repeater1.DataBind();
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
DataTable dt = ds.Tables["Data"]; DataView dv = new DataView(); dv = dt.DefaultView; int value = (int)(((DataRowView)e.Item.DataItem).Row["RegionId"]); dv.RowFilter = "RegionId = " + value;
UltraChart uc = (UltraChart)e.Item.FindControl("UltraChart1");
uc.ChartType = ChartType.StepLineChart;
uc.Data.UseRowLabelsColumn = true; uc.Data.RowLabelsColumn = 0; uc.AreaChart.TreatDateTimeAsString = false;
uc.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL:dd, yyyy,mm:ss:fff>"; uc.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:##.##>";
uc.Data.DataSource = dv; uc.Data.IncludeColumn(0, true); uc.Data.IncludeColumn(1, true); uc.Data.IncludeColumn(2, false); uc.Data.IncludeColumn(3, false); uc.DataBind();
} }}***************************************************************
Some code will be good. Can you send me your page in which you are creating the charts?
This response does not resolve my problem. If you nedd more details or some code i can send you.
http://community.infragistics.com/forums/p/23774/87173.aspx#87173