Jump to content
Software FX Community

Line Chart with Multiple Series


BryanHood
 Share

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...