Scrolling one date at a time
Scrolling one date at a time
Hello,
I am new to TChart so this may be a simple question to answer. I have a bar graph with dates along the x axis and a TChartScrollBar. When I scroll the graph using the arrows on the scroll bar the graph moves one page at a time. I would like to move just one date (data point) at a time. How can I do this?
Thanks,
Dave.
I am new to TChart so this may be a simple question to answer. I have a bar graph with dates along the x axis and a TChartScrollBar. When I scroll the graph using the arrows on the scroll bar the graph moves one page at a time. I would like to move just one date (data point) at a time. How can I do this?
Thanks,
Dave.
Hi Dave,
Here there is an example doing it, I hope will help:
Here there is an example doing it, I hope will help:
Code: Select all
const PointsPerPage = 10;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
with Chart1.Axes.Bottom do
begin
Automatic := False;
Minimum := 0;
Maximum := PointsPerPage - 1;
end;
Chart1[0].FillSampleValues(50);
Series1.XValues.DateTime := true;
ScrollBar1.Max := Chart1[0].Count - PointsPerPage;
end;
procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
with Chart1.Axes.Bottom do
begin
Minimum := ScrollBar1.Position;
Maximum := ScrollBar1.Position + PointsPerPage - 1;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Thank you for the quick response. That was what I was looking for.
I noticed that when you turn off “Automatic”, bars that are added using Series1.Add (x,’’,clr) are not in proportion and the more bars you add the wider each bar gets. Is there another setting such as Automatic that will keep the correct proportion of the bars? That is, the bars do not automatically become wider with each add?
Thanks again,
Dave.
I noticed that when you turn off “Automatic”, bars that are added using Series1.Add (x,’’,clr) are not in proportion and the more bars you add the wider each bar gets. Is there another setting such as Automatic that will keep the correct proportion of the bars? That is, the bars do not automatically become wider with each add?
Thanks again,
Dave.
Hi Dave,
I'm not sure to understand you. I've added a button with the following code to the example above and it seems to work fine here.
If you still have problems with this, please, could you send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
I'm not sure to understand you. I've added a button with the following code to the example above and it seems to work fine here.
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1[0].Add(random*Chart1[0].MaxYValue,'',clTeeColor);
ScrollBar1.Max := ScrollBar1.Max + 1;
end;
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Yeray,
Thanks for your help. I am sure it is something I am missing in a property somewhere.
If Chart1.Axes.Bottom.Automatic is true, then the bars draw correctly side by side. If I set Automatic to false so that I can scroll, the bars are incorrect – they overlap and stack onto one another. I have removed the scroll bar from the example below to simplify it.
I have added two series to the chart; both are Standard bar, 3D and smooth. No other changes are made through the Edit Chart settings.
I am sure it is a simple setting I am missing, but I don’t know where to look. If you would like me to zip up the project and send it to you let me know.
I am using Delphi 2006, win 32.
Thanks,
Dave.
Thanks for your help. I am sure it is something I am missing in a property somewhere.
If Chart1.Axes.Bottom.Automatic is true, then the bars draw correctly side by side. If I set Automatic to false so that I can scroll, the bars are incorrect – they overlap and stack onto one another. I have removed the scroll bar from the example below to simplify it.
I have added two series to the chart; both are Standard bar, 3D and smooth. No other changes are made through the Edit Chart settings.
Code: Select all
procedure TfrmChartExample.FormShow(Sender: TObject);
begin
Chart1.MaxPointsPerPage:=10;
with Chart1.Axes.Bottom do
begin
Automatic := true; //If true, bars draw correctly.
//If false, bars are incorrect.
Maximum := Date + Chart1.MaxPointsPerPage-1;
Minimum := Date;
end;
Series1.XValues.DateTime := true;
Series2.XValues.DateTime := true;
end;
procedure TfrmChartExample.Button1Click(Sender: TObject);
var
i :integer;
x :double;
y :double;
begin
for i := 0 to 50 do
begin
x:= IncDay(Date, i);
y:= i+1;
if y>10 then y:=8;
series1.AddXY(x, y, '', clBlue);
series2.AddXY(x, y-1, '', clSkyBlue);
end;
end;
I am using Delphi 2006, win 32.
Thanks,
Dave.
Hi Dave,
Yes it would be better if you send us this example and, if possible, with a picture showing your result and maybe another showing the result you expected.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Yes it would be better if you send us this example and, if possible, with a picture showing your result and maybe another showing the result you expected.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Dave,
The Chart property MaxPointsPerPage is used when one wants to use the Chart pagination feature. On the other hand, you are scrolling your chart with a scrollbar. That's why setting this property your chart is confusing.
The following code works now for us here:
The Chart property MaxPointsPerPage is used when one wants to use the Chart pagination feature. On the other hand, you are scrolling your chart with a scrollbar. That's why setting this property your chart is confusing.
The following code works now for us here:
Code: Select all
procedure TfrmChartExample.FormShow(Sender: TObject);
var MaxPointsPerPage: Integer;
begin
MaxPointsPerPage:=10;
with Chart1.Axes.Bottom do
begin
Automatic := false;
Maximum := Date + MaxPointsPerPage-1;
Minimum := Date;
end;
Series1.XValues.DateTime := true;
Series2.XValues.DateTime := true;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Yeray,
Thanks! I have corrected the problem with the MaxPointsPerPage and the bars are now drawing correctly.
I gave up trying to use TChartScrollBar as I couldn’t get it to work with the dates. Using your ideas above, I added a regular scrollbar and added:
That works just the way I want it to!
Best regards,
Dave.
[/code]
Thanks! I have corrected the problem with the MaxPointsPerPage and the bars are now drawing correctly.
I gave up trying to use TChartScrollBar as I couldn’t get it to work with the dates. Using your ideas above, I added a regular scrollbar and added:
Code: Select all
procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
with Graph.Axes.Bottom do
begin
SetMinMax(StartDate + ScrollBar1.Position, StartDate + ScrollBar1.Position + PointsPerPage - 1);
end;
end;
Best regards,
Dave.
[/code]
Hi Dave,
Yes, we recommend to use the standard ScrollBar instead of TChartScrollBar because it presents some problems.
I'm happy to see it works fine!
Yes, we recommend to use the standard ScrollBar instead of TChartScrollBar because it presents some problems.
I'm happy to see it works fine!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |