hi,
i have a BarSeries that needs its Left axis 0 position to allways be the center of the chart.
here's an example :
what i have here are two bars with positive values,
below them is enough space for similer bar's with same but negative values.
to do this i have to force the Maximum and Minimum properties of the left axis.
the problem here is that without "Auto" property i cant know whats the REAL maximum because of the label margins and styles etc..
so what i need is basically a way to calculate or retreive the real maximum and minimum values taking in account all mark padding and size etc.
the current example was made by settin auto then setting it to manual and adjusting visually until it looks like auto mode..
this is kind of hard to explain but i hope you understood what im looking for.
thank you.[/img]
Centering the Left Axis on a certain position in bar series
-
- Newbie
- Posts: 3
- Joined: Thu Jan 31, 2008 12:00 am
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Aviel_Consist,
If I understood correctly what you are trying to achieve you could do something like in the example here. This a TeeChart Pro ActiveX with VB6 example but you shouldn't have much problems porting it to the VCL version. In case of any problem don't hesitate to let us know.
If I understood correctly what you are trying to achieve you could do something like in the example here. This a TeeChart Pro ActiveX with VB6 example but you shouldn't have much problems porting it to the VCL version. In case of any problem don't hesitate to let us know.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 3
- Joined: Thu Jan 31, 2008 12:00 am
Hi, i have tried the example you linked to, this is not exactly what i needed.. unless i did not port it right .. what this does is move the axis itself.
what i need is to make sure the maximum and minimum are both negatives of each other even in automatic mode..
so say if i have 2 bars with values 100, and 90.
the maximum for the left axis would be 100, and i would see the 0 mark at the bottom of the chart.
what i want is to have the minimum be the negative of the maximum that way the 0 mark would be on the center of the chart.
obviously i could just do Minimum := -Maximum BUT.. the maximum is calculated automatically by the Auto property which sets it a bit higher than the maximum bar value to show the label marks etc..
and i cant access this value.. or atleast i havent found how.
so either a way to do this.. or some sort of way to get the maximum TChart has set after the Auto property.
what i need is to make sure the maximum and minimum are both negatives of each other even in automatic mode..
so say if i have 2 bars with values 100, and 90.
the maximum for the left axis would be 100, and i would see the 0 mark at the bottom of the chart.
what i want is to have the minimum be the negative of the maximum that way the 0 mark would be on the center of the chart.
obviously i could just do Minimum := -Maximum BUT.. the maximum is calculated automatically by the Auto property which sets it a bit higher than the maximum bar value to show the label marks etc..
and i cant access this value.. or atleast i havent found how.
so either a way to do this.. or some sort of way to get the maximum TChart has set after the Auto property.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Aviel_Consist,
You can try doing something as in the code below. You can choose wheter using MarksOffset or not.
You can try doing something as in the code below. You can choose wheter using MarksOffset or not.
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var MarksOffset : integer;
begin
MarksOffset := Series1.Marks.Callout.Length;
Chart1.Axes.Left.SetMinMax(chart1.Axes.Left.Maximum + MarksOffset , -Series1.YValues.MaxValue);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues();
Chart1.Draw;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 3
- Joined: Thu Jan 31, 2008 12:00 am
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Aviel_Consist,
Ok, you can do something like this:
You could also calculate font height using textheight property.
Ok, you can do something like this:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Draw;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
Chart1.Axes.Left.SetMinMax(Series1.YValues.MaxValue , -Series1.YValues.MaxValue);
Chart1.Axes.Left.MaximumOffset := Series1.Marks.ArrowLength + Series1.Marks.Shadow.Size+ round(Series1.Marks.Font.Size) + Series1.Marks.Margins.Bottom
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |