Hi,
Is it possible to have different color bars in a bar chart for DbAdvChart? How do I do that.
Much appreciated.
Regards
Marius
Hello,
I have the same worries, did you find the solution?
Regards
After loading all data in the DBChart, you need to loop the points and set the Color value of that point.
AdvChartView1.BeginUpdate;
for I := 0 to Length(AdvChartView1.Panes[0].Series[0].Points) - 1 do
AdvChartView1.Panes[0].Series[0].Points.Color :=
AdvChartView1.EndUpdate;
Kind Regards,
Scheldeman PIeter
Thanks fo your answer.
I
did what you told me, but it does not work. it does nothing!I have a ctHistogram and I want the bars to be different colors according to my values, I must still use the property "Points"?
Regards
If it does nothing then can you at least provide a sample that demonstrates your issue?
Pieter
I have a graph (TDBAdvGDIPChartView) with 1 series (with chartType: = ctHistogram).
I would like on this series, bars of histograms have different color for each value. For example, the histogram of this site: Dictionnaire de mathématiques
After setting the dataset active use:
DBAdvGDIPChartView1.BeginUpdate;
with DBAdvGDIPChartView1.Panes[0].Series[0] do
begin
for I := 0 to Length(Points) - 1 do
begin
Points.Color := //;
end;
end;
DBAdvGDIPChartView1.EndUpdate;
This should update your bar colors, you can fetch the value with Points.SingleValue.
Regards,
Pieter
I'm so sorry but it dosen't work.I have no message error and the bars stay white... I give a part of my code :
Connexion(tsds, cds, FALSE); /// DECONNEXION avant de mettre les parametres au graphique
DBAdvGDIPChartView1.BeginUpdate;
with DBAdvGDIPChartView1.Panes[0] do
// Propriété de Panneau d'un graphique
begin
Series.Clear;
DataSource := ds;
XAxis.Size:= 300;
XAxis.Text:='';
YAxis.Text:= Edit1.Text;
YAxis.AutoUnits:= FALSE;
// Création de la série
DBAdvGDIPChartView1.BeginUpdate;
with DBAdvGDIPChartView1.Panes[0] do
// Propriété de Panneau d'un graphique
begin
Series.Clear;
DataSource := ds;
XAxis.Size:= 300;
XAxis.Text:='';
YAxis.Text:= Edit1.Text;
YAxis.AutoUnits:= FALSE;
// Création de la série
Series.Add;
with Series[0] do
begin
chartType:= ctHistogram;
FieldNameValue:= valueY;
FieldNameXAxis:= valueX;
LegendText:= 'OMR_KGH';
LineColor:= clRed;
for Z := 0 to length(Points)-1 do
begin
Points[Z].Color:= clGreen;
end;
begin
chartType:= ctHistogram;
FieldNameValue:= valueY;
FieldNameXAxis:= valueX;
LegendText:= 'OMR_KGH';
LineColor:= clRed;
for Z := 0 to length(Points)-1 do
begin
Points[Z].Color:= clGreen;
end;
end;
Your dataset connection is turned off, so there will be no points inside the series.
As said in the previous post, you need to change the color AFTER setting the dataset to active.
I'm sorry, it works.
Thanks and have a good day.