Jump to content
Software FX Community

Line Chart with Multiple Series


BryanHood

Recommended Posts

I have a dataset with the following data (this is just a small portion):

Period_Day

Period

Total

1

Prior

456

1

Current

789

2

Prior

456

2

Current

789

3

Prior

456

3

Current

789

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

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

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

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

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;

// Rewind

It 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)

 

post-2932-13922400441075_thumb.jpg

Link to comment
Share on other sites

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...