Trouble with eval version designtime properties fail to work
Posted: Tue Feb 14, 2006 9:01 pm
Hi,
I am using the eval version for TChart.Net with Delphi 2006 on a Windows XP pc. I am working with ASP.NET and I can get a chart to display. If I setup a series in designtime, when I run the ASP.NET app the chart is blank. When I inpect the seriescount in the debugges, it is 0.
Also, I tried creating the series at runtime. This works, but none of the axis appear. It seems like they do not exist. Is there a setting that makes designtime settings persist into the actual runtime? I am a longtime user of TChart for Win32, but have struggled with implementing the chart in ASP.NET. I am disappointed at the lack of any examples in Delphi. I am trying to use the C# examples, but even one Delphi code based example would be invaluable. If I can get this to work, I will show my superior to justify purchasing, but right now I can't figure out what is wrong. Any help would be appreciated.
Here is my code:
.pas
pqisdb := TORA_PQISDB.Create;
//build datatable
chartdt := DataTable.Create('charteff');
dc := DataColumn.Create('XFIELD', TypeOf(string));
chartdt.Columns.Add(dc);
dc := DataColumn.Create('BEGTIME', TypeOf(DateTime));
adc[0] := dc;
chartdt.Columns.Add(dc);
chartdt.PrimaryKey := adc;
chartdt.PrimaryKey := adc;
for i := 1 to 4 do
begin
dc := DataColumn.Create('YFIELD'+i.ToString, TypeOf(system.double));
chartdt.Columns.Add(dc);
end;
pdate := fromdate+0.25;
while pdate <= todate do
begin
dr := chartdt.NewRow;
case Convert.ToInt32( ddlTimeBasis.SelectedValue) of
1: begin //daily
dr['XFIELD'] := pdate.ToString;
dr['BEGTIME'] := pdate.ToString;
pdate := pdate + 1;
ptype := 'D';
end;
2: begin //monthly
dr['XFIELD'] := pdate.Month.ToString + '/' + pdate.Year.ToString;
dr['BEGTIME'] := pdate.ToString;
pdate := pdate.AddMonth(1);
ptype := 'M';
end;
3: begin //yearly
dr['XFIELD'] := pdate.Year.ToString;
dr['BEGTIME'] := pdate.ToString;
pdate := pdate.AddMonth(12);
ptype := 'T';
end;
end;
chartdt.Rows.Add(dr);
end;
//get prop_row
if ListBox1.SelectedValue <> '' then
begin
dr := effdt.Rows.Find(ListBox1.SelectedValue);
heading := dr['HEADING'].ToString;
prop_row := dr['PROP_ROW'].ToString;
for i := 1 to 4 do
begin
pqisdb.cctype := millinfo.cctype;
pqisdb.OpenConnection;
asql := pqisdb.BuildSQL_DailyEffByDateRange(true, true,
millinfo.lineno.ToString, fromdate, todate, ptype, prop_row);
bdpdr := pqisdb.GetDataReader(asql);
while bdpdr.Read do
begin
//update each row with the correct value
dr := chartdt.Rows.Find(bdpdr.Item['BEGTIME']);
if bdpdr.Item['FAVG'].ToString <> '' then
dr['YFIELD'+i.ToString] := bdpdr.Item['FAVG']
else
dr['YFIELD'+i.ToString] := '0';
end;
end;
for i := 1 to 4 do
begin
WebChart1.Chart.Series.Add(Steema.TeeChart.Styles.Bar.Create);
WebChart1.Chart.Series[i-1].Title := heading;
WebChart1.Chart.Series[i-1].DataSource := chartdt;
WebChart1.Chart.Series[i-1].XValues.DateTime := true;
WebChart1.Chart.Series[i-1].XValues.DataMember := 'BEGTIME';
WebChart1.Chart.Series[i-1].YValues.DataMember := 'YFIELD'+i.ToString;
WebChart1.Chart.Series[i-1].LabelMember := 'XFIELD';
WebChart1.Chart.Series[i-1].ShowInLegend := true;
WebChart1.Chart.Series[i-1].Marks.Visible := false;
WebChart1.Chart.Series[i-1].HorizAxis := Steema.TeeChart.Styles.HorizontalAxis.Bottom;
WebChart1.Chart.Series[i-1].VertAxis := Steema.TeeChart.Styles.VerticalAxis.Right;
end;
end;
pqisdb.CloseConnection;
.aspx code
<form runat="server">
<p>
<uc1:UPM_Header id="UserControl1" runat="server"></uc1:UPM_Header>
</p>
<p>
<ASP:Panel id="Panel1" style="POSITION: relative" runat="server" width="537px" height="49px">Choose Time Period:
<ASP:DropDownList id="ddlTimePeriod" runat="server">
<ASP:ListItem value="1" selected="True">Last 30 days</ASP:ListItem>
<ASP:ListItem value="2">Last 6 months</ASP:ListItem>
<ASP:ListItem value="3">Last 12 months</ASP:ListItem>
<ASP:ListItem value="4">Last 2 years</ASP:ListItem>
<ASP:ListItem value="5">Last 5 years</ASP:ListItem>
</ASP:DropDownList> Choose Time Basis:
<ASP:DropDownList id="ddlTimeBasis" runat="server">
<ASP:ListItem value="1" selected="True">By Day</ASP:ListItem>
<ASP:ListItem value="2">By Month</ASP:ListItem>
<ASP:ListItem value="3">By Year</ASP:ListItem>
</ASP:DropDownList></ASP:Panel><br>
<ASP:ListBox id="ListBox1" runat="server" autopostback="True" height="383px"></ASP:ListBox>
<tchart:WebChart id="WebChart1" runat="server" tempchart="File" clickedy="0" clickedx="0" getchartfile="GetChart.aspx" autopostback="False" width="634px" height="370px" config=""></tchart:WebChart>
</p>
</form>
I am using the eval version for TChart.Net with Delphi 2006 on a Windows XP pc. I am working with ASP.NET and I can get a chart to display. If I setup a series in designtime, when I run the ASP.NET app the chart is blank. When I inpect the seriescount in the debugges, it is 0.
Also, I tried creating the series at runtime. This works, but none of the axis appear. It seems like they do not exist. Is there a setting that makes designtime settings persist into the actual runtime? I am a longtime user of TChart for Win32, but have struggled with implementing the chart in ASP.NET. I am disappointed at the lack of any examples in Delphi. I am trying to use the C# examples, but even one Delphi code based example would be invaluable. If I can get this to work, I will show my superior to justify purchasing, but right now I can't figure out what is wrong. Any help would be appreciated.
Here is my code:
.pas
pqisdb := TORA_PQISDB.Create;
//build datatable
chartdt := DataTable.Create('charteff');
dc := DataColumn.Create('XFIELD', TypeOf(string));
chartdt.Columns.Add(dc);
dc := DataColumn.Create('BEGTIME', TypeOf(DateTime));
adc[0] := dc;
chartdt.Columns.Add(dc);
chartdt.PrimaryKey := adc;
chartdt.PrimaryKey := adc;
for i := 1 to 4 do
begin
dc := DataColumn.Create('YFIELD'+i.ToString, TypeOf(system.double));
chartdt.Columns.Add(dc);
end;
pdate := fromdate+0.25;
while pdate <= todate do
begin
dr := chartdt.NewRow;
case Convert.ToInt32( ddlTimeBasis.SelectedValue) of
1: begin //daily
dr['XFIELD'] := pdate.ToString;
dr['BEGTIME'] := pdate.ToString;
pdate := pdate + 1;
ptype := 'D';
end;
2: begin //monthly
dr['XFIELD'] := pdate.Month.ToString + '/' + pdate.Year.ToString;
dr['BEGTIME'] := pdate.ToString;
pdate := pdate.AddMonth(1);
ptype := 'M';
end;
3: begin //yearly
dr['XFIELD'] := pdate.Year.ToString;
dr['BEGTIME'] := pdate.ToString;
pdate := pdate.AddMonth(12);
ptype := 'T';
end;
end;
chartdt.Rows.Add(dr);
end;
//get prop_row
if ListBox1.SelectedValue <> '' then
begin
dr := effdt.Rows.Find(ListBox1.SelectedValue);
heading := dr['HEADING'].ToString;
prop_row := dr['PROP_ROW'].ToString;
for i := 1 to 4 do
begin
pqisdb.cctype := millinfo.cctype;
pqisdb.OpenConnection;
asql := pqisdb.BuildSQL_DailyEffByDateRange(true, true,
millinfo.lineno.ToString, fromdate, todate, ptype, prop_row);
bdpdr := pqisdb.GetDataReader(asql);
while bdpdr.Read do
begin
//update each row with the correct value
dr := chartdt.Rows.Find(bdpdr.Item['BEGTIME']);
if bdpdr.Item['FAVG'].ToString <> '' then
dr['YFIELD'+i.ToString] := bdpdr.Item['FAVG']
else
dr['YFIELD'+i.ToString] := '0';
end;
end;
for i := 1 to 4 do
begin
WebChart1.Chart.Series.Add(Steema.TeeChart.Styles.Bar.Create);
WebChart1.Chart.Series[i-1].Title := heading;
WebChart1.Chart.Series[i-1].DataSource := chartdt;
WebChart1.Chart.Series[i-1].XValues.DateTime := true;
WebChart1.Chart.Series[i-1].XValues.DataMember := 'BEGTIME';
WebChart1.Chart.Series[i-1].YValues.DataMember := 'YFIELD'+i.ToString;
WebChart1.Chart.Series[i-1].LabelMember := 'XFIELD';
WebChart1.Chart.Series[i-1].ShowInLegend := true;
WebChart1.Chart.Series[i-1].Marks.Visible := false;
WebChart1.Chart.Series[i-1].HorizAxis := Steema.TeeChart.Styles.HorizontalAxis.Bottom;
WebChart1.Chart.Series[i-1].VertAxis := Steema.TeeChart.Styles.VerticalAxis.Right;
end;
end;
pqisdb.CloseConnection;
.aspx code
<form runat="server">
<p>
<uc1:UPM_Header id="UserControl1" runat="server"></uc1:UPM_Header>
</p>
<p>
<ASP:Panel id="Panel1" style="POSITION: relative" runat="server" width="537px" height="49px">Choose Time Period:
<ASP:DropDownList id="ddlTimePeriod" runat="server">
<ASP:ListItem value="1" selected="True">Last 30 days</ASP:ListItem>
<ASP:ListItem value="2">Last 6 months</ASP:ListItem>
<ASP:ListItem value="3">Last 12 months</ASP:ListItem>
<ASP:ListItem value="4">Last 2 years</ASP:ListItem>
<ASP:ListItem value="5">Last 5 years</ASP:ListItem>
</ASP:DropDownList> Choose Time Basis:
<ASP:DropDownList id="ddlTimeBasis" runat="server">
<ASP:ListItem value="1" selected="True">By Day</ASP:ListItem>
<ASP:ListItem value="2">By Month</ASP:ListItem>
<ASP:ListItem value="3">By Year</ASP:ListItem>
</ASP:DropDownList></ASP:Panel><br>
<ASP:ListBox id="ListBox1" runat="server" autopostback="True" height="383px"></ASP:ListBox>
<tchart:WebChart id="WebChart1" runat="server" tempchart="File" clickedy="0" clickedx="0" getchartfile="GetChart.aspx" autopostback="False" width="634px" height="370px" config=""></tchart:WebChart>
</p>
</form>