Hi Support
I am building an application and would like to color/paint the back wall to indicate system operating conditions.
This color needs to match X-Axis values as this color 1 of 7 can vary with time or the X-Axis value.
I would like for this color to follow when the chart is zoomed.
Any hints would be great.
Regards
Mike
How To Color Chart / Back Wall to Align with X-Axis values
Re: How To Color Chart / Back Wall to Align with X-Axis values
Hello Mike,
I think you can be useful define a colors table and use the Chart GetAxisLabel event to change the walls color as you want. The simple code below give you an idea as you can do:
Hoping this helps you
Thanks in advance
I think you can be useful define a colors table and use the Chart GetAxisLabel event to change the walls color as you want. The simple code below give you an idea as you can do:
Code: Select all
uses Series;
var Series1:TLineSeries;
colorTable : array[1..7] of TColor;
procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
ValueIndex: Integer; var LabelText: string);
begin
if ValueIndex = 1 then
begin
Chart1.Walls.Back.Gradient.Visible :=false;
Chart1.Walls.Back.Color := colorTable[2];
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D := false;
Series1 := TLineSeries.Create(Self);
Chart1.AddSeries(Series1);
Series1.FillSampleValues(10);
//CrecteTableColrs
AddColors;
end;
procedure TForm1.AddColors;
begin
colorTable[1]:=clWhite;
colorTable[2] := clBlack;
colorTable[3] := clGray;
colorTable[4] := clRed;
colorTable[5] := clBlue;
colorTable[6] := clGreen;
colorTable[7] := clYellow;
end;
end.
Thanks in advance
Best Regards,
Sandra Pazos / 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 |
Re: How To Color Chart / Back Wall to Align with X-Axis values
Hello Sandra,
Thanks for the reply, I will use the code to get started and give you a reply
Regards
Mike
Thanks for the reply, I will use the code to get started and give you a reply
Regards
Mike
Re: How To Color Chart / Back Wall to Align with X-Axis values
Hello Sandra,
Tried your code and it works and I understand what is going on.
However, I may not have stated clearly what I am wanting to do.
In the example there are 10 X-Axis points.
Here's what I am trying to do
From points 0 to 2 use Color[3]
From points 3 to 7 use Color[6]
From points 8 to 9 use Color[4].
Basically painting the back wall a color as a function of X-Axis position.
Again Thanks for a clever way to paint the back wall.
Is what I'd like to do possible?
Regards
Mike
Tried your code and it works and I understand what is going on.
However, I may not have stated clearly what I am wanting to do.
In the example there are 10 X-Axis points.
Here's what I am trying to do
From points 0 to 2 use Color[3]
From points 3 to 7 use Color[6]
From points 8 to 9 use Color[4].
Basically painting the back wall a color as a function of X-Axis position.
Again Thanks for a clever way to paint the back wall.
Is what I'd like to do possible?
Regards
Mike
Re: How To Color Chart / Back Wall to Align with X-Axis values
Good afternon Mike,
Many thanks for the clarification.
I have modified the previous code we sent you, so Chart wall changes when you click in the concretely axis value position using the ClickAxis event. The code below shows you how:
Could you confirm is the code above works in your end?
Thanks in advance,
Many thanks for the clarification.
I have modified the previous code we sent you, so Chart wall changes when you click in the concretely axis value position using the ClickAxis event. The code below shows you how:
Code: Select all
uses Series;
var Series1:TLineSeries;
colorTable : array[1..7] of TColor;
procedure TForm1.Chart1ClickAxis(Sender: TCustomChart; Axis: TChartAxis;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Axis = Chart1.Axes.Bottom then
begin
if Axis.Clicked(X,Y) then
begin
if (Trunc(Axis.CalcPosPoint(X))= 0) or (Trunc(Axis.CalcPosPoint(X))= 1) or (Trunc(Axis.CalcPosPoint(X))= 2) then
begin
Chart1.Walls.Back.Gradient.Visible :=false;
Chart1.Walls.Back.Color := colorTable[2];
end
else if (Trunc(Axis.CalcPosPoint(X))= 3) or (Trunc(Axis.CalcPosPoint(X))= 4) or (Trunc(Axis.CalcPosPoint(X))= 5)or (Trunc(Axis.CalcPosPoint(X))= 6) or (Trunc(Axis.CalcPosPoint(X))= 7)then
begin
Chart1.Walls.Back.Gradient.Visible :=false;
Chart1.Walls.Back.Color := colorTable[1];
end
else if (Trunc(Axis.CalcPosPoint(X))= 8) or (Trunc(Axis.CalcPosPoint(X))= 9) or (Trunc(Axis.CalcPosPoint(X))= 10) then
begin
Chart1.Walls.Back.Gradient.Visible :=false;
Chart1.Walls.Back.Color := colorTable[3];
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D := false;
Series1 := TLineSeries.Create(Self);
Chart1.AddSeries(Series1);
Series1.FillSampleValues(10);
//CrecteTableColrs
AddColors;
end;
procedure TForm1.AddColors;
begin
colorTable[1]:=clWhite;
colorTable[2] := clBlack;
colorTable[3] := clGray;
colorTable[4] := clRed;
colorTable[5] := clBlue;
colorTable[6] := clGreen;
colorTable[7] := clYellow;
end;
Thanks in advance,
Best Regards,
Sandra Pazos / 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 |
Re: How To Color Chart / Back Wall to Align with X-Axis values
Hello Sandra,
I thought I had posted a reply however cannot find it.
I tried the code it works however not what I am looking to do.
While poking about I found a tool Color Band, looks like what I am trying to do.
The color band's orientation can be set so it looks promising.
Now am I correct each ColorBand can set a single color?
So for multiple colors I will need several bands?
Is there a preferred way to implement this so as not slow the execution?
Regards
Mike
I thought I had posted a reply however cannot find it.
I tried the code it works however not what I am looking to do.
While poking about I found a tool Color Band, looks like what I am trying to do.
The color band's orientation can be set so it looks promising.
Now am I correct each ColorBand can set a single color?
So for multiple colors I will need several bands?
Is there a preferred way to implement this so as not slow the execution?
Regards
Mike
Re: How To Color Chart / Back Wall to Align with X-Axis values
Hello Mike,
Hoping this helps
Thanks in advance
Yes, you can set a solid color for each color band. Also, if you are interested, you can set a hatch or gradient to ColorBand ToolNow am I correct each ColorBand can set a single color?
If you want see multiple colors simultaneously, is needed use multiple color bands, but is possible use a Colorband and changes the color if you want use that in different time periods.So for multiple colors I will need several bands?
The uses of colorbands tool shouldn’t cause performance problems, but in the case you detected any problems, don’t hesitate to contact with us.Is there a preferred way to implement this so as not slow the execution?
Hoping this helps
Thanks in advance
Best Regards,
Sandra Pazos / 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 |
Re: How To Color Chart / Back Wall to Align with X-Axis values
Hello Sandra,
Thanks for the reply.
I will let you know if there are any performance issues
Mike
Thanks for the reply.
I will let you know if there are any performance issues
Mike