Page 1 of 1

No plot on the chart

Posted: Fri Apr 04, 2008 3:27 pm
by 13048060
We have recently purchased Teechart for .NET for visual studio.net 2003. We have installed the componenet on a Development server running VS.NET 2003 and .NET framework 1.1. We cannot updagrade to .NET framework 2.0 at this time.

At the end of installing the component, we got an error message "To run this application, you first must install one of the following versions of .NET framework: v2.0.50727" I hit "OK" on the error message and installation completes successfully and installs the component. Apparently, I am able to add Teechart control to the project and edit properties and populate the chart with Series.FillSamplevalues() and get the chart working.

But I am having hard time with populating the chart with data from a dataset

These are the steps I followed.

Added a reference in the project to Teechart, dragged and dropped a Webchart cotrol. added a Getchart.aspx page with appropriate code for Page_Load()

On the webform where I have the webchart, I have the following code.

Code: Select all

Protected WithEvents WebChart1 As Steema.TeeChart.Web.WebChart
Private CandleSeries1 As Steema.TeeChart.Styles.Candle
Private Chart1 As Steema.TeeChart.Chart
I am calling the sub routine GenerateTeeChart(tab) in Page_Load()

I have verified Datatable tab has data in it with 90 rows.

Code: Select all

Public Sub GenerateTeeChart(ByVal tab As DataTable)
//this is what the examples code illustrated in the help documentation
Chart1 = WebChart1.Chart
CandleSeries1 = New Steema.TeeChart.Styles.Candle
Chart1.Series.Add(CandleSeries1)
CandleSeries1.YValues.DataMember = tab.Columns("Throughput").ToString()
CandleSeries1.LabelMember = tab.Columns("Time").ToString()
CandleSeries1.DataSource = tab
Chart1.Legend.Visible = True
Chart1.Axes.Bottom.Labels.Angle = 90
Steema.TeeChart.Themes.ColorPalettes.ApplyPalette(Chart1.Chart, 7)
End Sub
With this code, I dont have anything on the chart. I wish I could attach the image here. But let me describe what I see.

I see the axes and there is only one label "0" at the center of left "Y" axis and one label "12:00AM" on bottom X Axis. Nothing else on the plot.

What am I missing here? Please help

Posted: Fri Apr 04, 2008 3:47 pm
by narcis
Hi Kalyan,

You could try adding the line below after setting the series datasource.

Code: Select all

CandleSeries1.CheckDataSource

Posted: Fri Apr 04, 2008 5:21 pm
by 13048060
Narcis,
I did add the line. No change in the output

Posted: Fri Apr 04, 2008 6:16 pm
by 13048060
Narcis,
can you please let me know what is the problem? I have added the line of code CandleSeries1.CheckDataSource as you suggested. I still have the same problem.

Posted: Mon Apr 07, 2008 7:15 am
by narcis
Hi Kalyan,

Can you reproduce the issue in a simple example as the one Christopher Ireland posted here? If so, could you please send it at news://www.steema.net/steema.public.attachments newsgroup or at our upload page?

Thanks in advance.

Posted: Tue Apr 08, 2008 7:03 pm
by 13048060
Narcis,
I have uploaded a zipped VB.NET web project using your upload page.
The file name is SteemaTest.zip. I have used my name as Kalyan and email as lkareti@sfwmd.gov. Please acknowledge the receipt of the same.

For the sake of example, instead of connecting to the database, I have used an XML file as datasource which I have used to populate my dataset.

As you can see there are 229 tows in my datatable.

I still ahve the same problem where I get a blank chart image as output.

I hope you will be able to suggest a solution for this.

Thanks
Kalyan

Posted: Tue Apr 08, 2008 7:06 pm
by 13048060
As I mentioned earlier, I am working with ,.NET framework 1.1 and VS.NET 2003


Thanks
Kalyan

Posted: Wed Apr 09, 2008 11:20 am
by narcis
Hi Kalyan,

Thanks for the example project.

There are 2 problems here:

1. You are using a Candle series and you are assigning only X and Y values where you should assing Open, High, Low and Close values.

2. Using your example and a Line series instead of a Candle, X values are not loaded correctly because they are defined as string while TeeChart would expect them to be either Double or DateTime.

To solve that you could provide those values in the xml table as being double values and use FromOADate/ToOADate methos to convert them as necessary. Alternativelly you could loop through the table records and parse them or create a new column for those values, for example:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}		

		private void InitializeChart()
		{
			DataSet ds = new DataSet("NewDataSet");
			System.IO.FileStream fstr = new System.IO.FileStream(@"C:\Inetpub\wwwroot\SteemaTest\CommStats.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read);
			ds.ReadXml(fstr);
			DataTable tab = new DataTable("TrendView");
			tab = ds.Tables[0];
			fstr.Close();

			DataColumn DTIME = new DataColumn("DTIME", Type.GetType("System.DateTime"));
			tab.Columns.Add(DTIME);

			for (int i = 0; i < tab.Rows.Count; i++)
			{
				string tmpStr = tab.Rows[i][0].ToString();
				DateTime tmpDate = Convert.ToDateTime(tmpStr);
				tab.Rows[i][tab.Columns.Count - 1] = tmpDate;
			}

			GenerateTeeChart(tab);
		}

		public void GenerateTeeChart(DataTable tab)
		{			
			tChart1.Legend.Visible = true;
			tChart1.Axes.Bottom.Labels.Angle = 90;
			Steema.TeeChart.Themes.ColorPalettes.ApplyPalette(tChart1.Chart, 7);

			Steema.TeeChart.Styles.Line Line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			Line1.Clear();
			Line1.XValues.DateTime = true;
			Line1.DataSource = tab;			
			Line1.YValues.DataMember = "Throughput";
			Line1.XValues.DataMember = "DTIME";
			Line1.LabelMember = "Time";
			Line1.CheckDataSource();
		}
You can try porting it to VB.NET using any of those conversion engines:

Kamal Patel's conversor
Carlos Aguilar's conversor

If this doesn't help don't hesitate to let us know.

Posted: Wed Apr 09, 2008 11:41 am
by narcis
Hi Kalyan,

For completeness, here's VB code:

Code: Select all

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As New DataSet("NewDataSet")
        Dim fstr As New FileStream(Server.MapPath(".") & "/CommStats.xml", FileMode.Open, FileAccess.Read)
        ds.ReadXml(fstr)
        Dim tab As New DataTable("TrendView")
        tab = ds.Tables(0)
        fstr.Close()

        Dim DTIME As DataColumn = New DataColumn("DTIME", Type.GetType("System.DateTime"))
        tab.Columns.Add(DTIME)

        For i As Integer = 0 To tab.Rows.Count - 1
            Dim tmpStr As String = tab.Rows(i)(0).ToString
            Dim tmpDate As DateTime = Convert.ToDateTime(tmpStr)
            tab.Rows(i)((tab.Columns.Count - 1)) = tmpDate
        Next

        GenerateTeeChart(tab)
    End Sub
    Public Sub GenerateTeeChart(ByVal tab As DataTable)
        Response.Write("rowcount=" & tab.Rows.Count & ", " & tab.Columns(0).ColumnName & ", " & tab.Columns(2).ColumnName)
        Chart1 = WebChart1.Chart
        Dim Line1 As New Steema.TeeChart.Styles.Line(Chart1.Chart)

        Chart1.Legend.Visible = True
        Chart1.Axes.Bottom.Labels.Angle = 90
        Steema.TeeChart.Themes.ColorPalettes.ApplyPalette(Chart1.Chart, 7)

        Line1.XValues.DateTime = True

        Line1.Clear()
        Line1.DataSource = tab
        Line1.YValues.DataMember = "Throughput"
        Line1.XValues.DataMember = "DTIME"
        Line1.LabelMember = "Time"

        Line1.CheckDataSource()
    End Sub

Problem with LabelMember and more

Posted: Mon Apr 28, 2008 3:12 pm
by 13048060
Narcis
Thanks for the resolution. I did get the chart using the code exactly as you suggested. But I still have one problem and Need a suggestion.

1. I am getting the chart plotted. I have the Time column containing DateTime values. But Time labels on X axis are showing only the date and not datetime. Furthermore, I cannot use the Line1.LableMember = "Time" line of code. It hangs up the page forever. I comment this lineof code, the page works fine but display only date labels not datetime lables.

2. We have a specific requirement like this.

Column 1 - Time (dateTime values)
Column 2 - Connection Throughput (percentage values 0-100)
column 3 - Connection CostFactor (values are '1' or '2')

Basically what it means is, For each hour, we maintain communication througput percentage for our devices that use a connection (primary - 1 or secondary -2)

Line style works fine for plotting Time vs Throughput. But we are looking for a chart style that will plot Time vs. Throughput and change color (or someother visual representation on the chart) if the connection CostFactor is 2.

Can you please suggest if I could use any of the available styles to acheive this?

I would appreciate your help
Thanks
Kalyan

Posted: Mon Apr 28, 2008 3:32 pm
by narcis
Hi Kalyan,

Please find below the answers to your questions:

1. You could try setting DateTimeFormat as shown in Tutorial 4 - Axis Control. You'll find the tutorials at TeeChart's program group.

2. In that case you may be interested in using Points series and use the GetPointerStyle event for checking connection costfactor and set point's color accordingly, for example:

Code: Select all

		void points1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
		{
			if (tab.Rows[2][e.ValueIndex] == 1)
			{
				e.Color = Color.Blue;
			}
			else 
			{
				e.Color = Color.Red;
			}
		}
Hope this helps!