SeriesGroups / TBarSeries label issue
Posted: Mon Sep 24, 2018 11:59 am
Greetings,
we have an issue with SeriesGroups option. X bar (Axis.Bottom) date time labels are located quite randomly.
How could we adjust your code so that group dates would appear correctly (centred) under group bars?
we have an issue with SeriesGroups option. X bar (Axis.Bottom) date time labels are located quite randomly.
How could we adjust your code so that group dates would appear correctly (centred) under group bars?
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
bar: TBarSeries;
begin
chart1.ClearChart;
chart1.Legend.Hide;
(chart1.SeriesGroups.Add as TSeriesGroup).Name:='A';
(chart1.SeriesGroups.Add as TSeriesGroup).Name:='B';
(chart1.SeriesGroups.Add as TSeriesGroup).Name:='C';
// chart1.BottomAxis.Automatic := false;
// chart1.BottomAxis.SetMinMax(strtodate('21.05.2018')-3,strtodate('30.05.2018')+3);
chart1.Axes.Bottom.LabelStyle := talPointValue;
// chart1.Axes.Bottom.LabelsSeparation := 0;
chart1.BottomAxis.DateTimeFormat := 'dd.mm.yyyy';
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('21.05.2018'), 85, 'test1');
chart1.SeriesGroups.Items[0].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('21.05.2018'), 19, 'test2');
chart1.SeriesGroups.Items[0].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('21.05.2018'), 15, 'test3');
chart1.SeriesGroups.Items[0].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('29.05.2018'), 151, 'test 4');
chart1.SeriesGroups.Items[1].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('29.05.2018'), 195, 'test 5');
chart1.SeriesGroups.Items[1].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('29.05.2018'), 101, 'test 6');
chart1.SeriesGroups.Items[1].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('30.05.2018'), 11, 'test 7');
chart1.SeriesGroups.Items[2].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('30.05.2018'), 105, 'test 8');
chart1.SeriesGroups.Items[2].Add(bar);
bar := chart1.AddSeries(TBarSeries) as TBarSeries;
bar.XValues.DateTime := true;
bar.AddXY(strtodate('30.05.2018'), 21, 'test 9');
chart1.SeriesGroups.Items[2].Add(bar);
end;