BryanHood Posted July 6, 2007 Report Share Posted July 6, 2007 I have a dataset with the following data (this is just a small portion): Period_Day Period Total 1Prior456 1Current789 2Prior456 2Current789 3Prior456 3Current789 I want to create a Line chart with 2 lines. One for the "Prior" series, and one for the "Current" series. My X-Axis would be Period_Day, and my Y-Axis would be the Total. How do I accomplish this? Link to comment Share on other sites More sharing options...
Frank Posted July 7, 2007 Report Share Posted July 7, 2007 You need to use the CrossTab data provider. Please check the programmer's guide for details. Link to comment Share on other sites More sharing options...
BryanHood Posted July 9, 2007 Author Report Share Posted July 9, 2007 I found the CrosstabDataProvider class in the programmer's guide. However, I am not sure how to proceed. Do you have any examples that I can look at? Thanks, Bryan Link to comment Share on other sites More sharing options...
Frank Posted July 13, 2007 Report Share Posted July 13, 2007 In the programmer's guide, there is a link to a sample project. Programmer's Guide -> Pasing Data -> Crosstab Data Provider Launch "Passing Data using Crosstab" Application Link to comment Share on other sites More sharing options...
BryanHood Posted July 18, 2007 Author Report Share Posted July 18, 2007 The Crosstab Data Provider works awesome! Now that my stacked bar chart is using my Crosstab Data, is there a way to use the same Crosstab Data Provider to populate a grid? If I can't do this, is there a way to "export" the data grid from the chart into my gridview? The gridview doesn't like to be bound to the chart.datasource. Thanks again, Bryan Link to comment Share on other sites More sharing options...
Frank Posted July 18, 2007 Report Share Posted July 18, 2007 No you can not export the chart to a GridView. You can export it to a text format and maybe (I'm not a GridView expert) the GridView can read from that. I think if you google a little you may find code for doing a crosstab in a SQL store procedure too. Link to comment Share on other sites More sharing options...
BryanHood Posted July 19, 2007 Author Report Share Posted July 19, 2007 I don't want to export the chart itself to a GridView, but the underlying data. Basically, if you show the "Data Grid", I need this data to enter into my GridView. Thanks Link to comment Share on other sites More sharing options...
Frank Posted July 19, 2007 Report Share Posted July 19, 2007 I understand. But Chart FX does not know anything about GridViews or any other Grid Control. The text file option is the only posibility I see. Link to comment Share on other sites More sharing options...
BryanHood Posted July 19, 2007 Author Report Share Posted July 19, 2007 When I tried to export the chart using the memory stream, I only received the "Chart" setup info. (See code below) MemoryStream ms = new MemoryStream(); fxDailyValue.Export( FileFormat.Xml, ms);ms.Seek(0, SeekOrigin.Begin);TextReader reader = new StreamReader(ms); string xml = reader.ReadToEnd();Is there another way to get at the underlying data? I did notice that the "Chart" object is an image in PNG format, and when you do display the "Grid View", that also is part of the built image, and when you scroll through the data, the image gets rebuilt for each scroll position. Link to comment Share on other sites More sharing options...
Frank Posted July 19, 2007 Report Share Posted July 19, 2007 XML is not the way. This is for properties not data. Use FileFormat.Text instead. Link to comment Share on other sites More sharing options...
BryanHood Posted July 19, 2007 Author Report Share Posted July 19, 2007 When I try this: fxDailyValue.Export(FileFormat.Text, ms); The Export command seems to close the stream, and I can't get to it. Do I have to send it to a file, and read it from there? Link to comment Share on other sites More sharing options...
Frank Posted July 19, 2007 Report Share Posted July 19, 2007 I don;t get that at all. Are you using the latest Service Pack? I used this code and works like a charm: MemoryStream ms = new MemoryStream(); Chart1.Export(FileFormat.Text,ms); ms.Position = 0; Chart2.Import(FileFormat.Text,ms); Link to comment Share on other sites More sharing options...
BryanHood Posted July 20, 2007 Author Report Share Posted July 20, 2007 Here are the DLL's that I am using, and their version numbers: ChartFX.WebForms.Base 7.0.2664.18353 ChartFX.WebForms.Data 7.0.2664.18657 ChartFX.WebForms.Dhtml 7.0.2664.18403 ChartFX.WebForms 7.0.2664.18534 Link to comment Share on other sites More sharing options...
Frank Posted July 20, 2007 Report Share Posted July 20, 2007 These are the latest dlls. Please attach a sample program that fails. The code I posted works perfectly. Link to comment Share on other sites More sharing options...
BryanHood Posted July 20, 2007 Author Report Share Posted July 20, 2007 The following will save the data to a text file on my desktop with no problem: fxDailyValue.Export(FileFormat.Text, @"C:\Users\bclauss\Desktop\Chart.txt"); This causes an error: MemoryStream ms = new MemoryStream(); fxDailyValue.Export(FileFormat.Text, ms); ms.Position = 0; // RewindIt appears that the WebForms version of the Export method closes the memory stream when it uses the FileFormat.Text. My error detail is as follows: System.ObjectDisposedException was unhandled by user code Message="Cannot access a closed Stream." Source="mscorlib" ObjectName="" StackTrace: at System.IO.__Error.StreamIsClosed() at System.IO.MemoryStream.set_Position(Int64 value) at Test3.bind_Grids(String strDate) in c:\Dev\TroubleCalls\Test3.aspx.cs:line 629 at Test3.Page_Load(Object sender, EventArgs e) in c:\Dev\TroubleCalls\Test3.aspx.cs:line 109 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Link to comment Share on other sites More sharing options...
Frank Posted July 20, 2007 Report Share Posted July 20, 2007 This is the form I tested with. Please try it and let me know what you get: <%@ Page Language="C#" %> <%@ Register Assembly="ChartFX.WebForms" Namespace="ChartFX.WebForms" TagPrefix="chartfx7" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">protected void Page_Load (object sender,EventArgs e) { Chart1.Data.Series = 1; Chart1.Data.Points = 5;Chart1.Series[0].Text = "Data"; Chart1.Data[0,0] = 10; Chart1.Data[0,1] = 20; Chart1.Data[0,2] = 30; Chart1.Data[0,3] = 40; Chart1.Data[0,4] = 50; System.IO.MemoryStream ms = new System.IO.MemoryStream();Chart1.Export(FileFormat.Text,ms); ms.Position = 0; Chart2.Import(FileFormat.Text,ms);}</script> <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>Untitled Page</title> </head><body><form id="form1" runat="server"><div><chartfx7:Chart ID="Chart1" runat="server"></chartfx7:Chart><chartfx7:Chart ID="Chart2" runat="server"></chartfx7:Chart> </div></form> </body></html> Link to comment Share on other sites More sharing options...
BryanHood Posted July 20, 2007 Author Report Share Posted July 20, 2007 Same problem with the stream being closed after the Export. I pasted the code exactly like you had in the example. Server Error in '/TroubleCalls' Application. Cannot access a closed Stream. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ObjectDisposedException: Cannot access a closed Stream. Source Error: Line 27: Line 28: System.IO.MemoryStream ms = new System.IO.MemoryStream();Chart1.Export(FileFormat.Text,ms); Line 30: Line 31: Chart2.Import(FileFormat.Text,ms); Source File: c:\Dev\TroubleCalls\Test4.aspx Line: 29 Stack Trace: [ObjectDisposedException: Cannot access a closed Stream.] System.IO.__Error.StreamIsClosed() +56 System.IO.MemoryStream.set_Position(Int64 value) +2066900 ASP.test4_aspx.Page_Load(Object sender, EventArgs e) in c:\Dev\TroubleCalls\Test4.aspx:29 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061 Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833 Link to comment Share on other sites More sharing options...
JuanC Posted July 20, 2007 Report Share Posted July 20, 2007 We fixed an issue related to closing this stream a couple of weeks ago (after 2664 was released). Please send an email to support at softwarefx dot com and we will send you instructions on how to download a hotfix for this issue. Regards, JuanC Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.