Style individual Labels on Gantt-Rows in a VCL TeeChart - delphi

I am using TeeChart (Build 2020.30.200525) in a Delphi XE3 VCL-Application.
In that application I am setting up a Gantt series and I would like to style an individual row label on the left axis to set it apart from the others.
Something like changing the color or font-style of the label or highlighting it by using a background.
How could I achieve this?
I have found the OnGetAxisLabel event which I ca use to change the text of the labels.
And I have also tried Axes.Left.Items, but that only has a single element even after I have added several Values to the Gantt-Series.

You need to force a chart repaint to populate the axis items. Ie:
uses VclTee.GanttCh;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.AddSeries(TGanttSeries).FillSampleValues;
Chart1.Draw; // Force a repaint to populate Axis Items
Chart1.Axes.Left.Items.Automatic:=False;
Chart1.Axes.Left.Items[2].Format.Font.Color:=clRed;
end;

Related

Change color in tcxgrid column in delphi?

I have two grids:
in one form and compare between two value I need to change the color of the column in the grid when the two values are not equal
TotalYear:=0 ;
while not (mTblDetail.eof) do
begin
TotalYear:=TotalMonth +mTblDetail.FieldByName('Target_').AsFloat;
mTblDetail.Next;
end;
TotalMonth:=0;
while not(DataSet.Eof) do
begin
TotalMonth:=TotalMonth+DataSet.FieldByName('Target_').AsFloat;
DataSet.Next;
end;
I need to compare the two values and change the color
if(TotalYear<>TotalMonth) then
I tried to use this :
DataSet.Columns[8].Color:= clRed
but is displays an error "Not Accepted". How Can change the color of a column of a Tcxgrid?
Coloring in cxGrids is best done via cxStyles. Drop a TcxStyleRepository on the form and add some styles. You can assign them to the View.Styles.* properties or via events like OnGetContentStyle. I'm sure the online help contains an overview with screenshots and examples.

How to add values to an exisiting TPieSeries via Delphi Xe7

As the title suggest, how can I add a value to an already existing pie slice in a TPieseries within the TChart component.
delphi XE7 for iOS FMX
Access the indexed values through the TPieSeries.PieValues property.
Make an addition with the existing value. You can preinitialize the pie values with zero.
Series1.PieValues[2] := Series1.PieValues[2] + 10;
A better approach is to accumulate the values before adding them into the chart.

Zooming with mouse: marquee color

When I use zooming with mouse on a chart (TeeChart) (left button and drag bottom right) cursor draws a marquee rectangle for zoom area. Marquee line is barely visible in light-grey color. Is there any way to change the color of marquee line (something like black, red etc) to make it more contrast and easy to see?
I'm using VCL TChart 4.04.
I think this is not possible in TChart v.4.04, or at least haven't found any property which might do this.
At least in TChart v.8.03 (the one shipped with Delphi 2009) there are properties TChart.Zoom.Brush and TChart.Zoom.Pen where you can set the colors and other properties for the selection rectangle. So, if you would have the newer version of TChart you might use something like this:
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Zoom.Pen.Width := 2;
Chart1.Zoom.Pen.Color := clRed;
end;

ListView and coloring cellls

I have ListView (vsReport) and StringGrid and what I want is if I click on some element in ListView, particular cells in StringGrid have to change colors. How do I do it?
Path is filled with 1 (move up) and 0(move right), it starts in left bottom and ends in right top corner, and I have to color these cells.
Thanks for the answers, I handled with my problem, but there's another little issue, how can I leave text in cells visible? FillRect fills the entire cell.
procedure TForm1.ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
var aRect: TRect;
a,x,y:integer;
path:string;
begin
path:=ListView1.Items[Item.Index].Caption;
x:=0;
y:=StringGrid1.RowCount;
for a := 0 to length(path) do
begin
if path[a]='1' then y:=y-1 else x:=x+1;
aRect := StringGrid1.CellRect(x-1,y-1);
StringGrid1.Canvas.Brush.Color := clBlue;
StringGrid1.Canvas.FillRect(aRect);
end;
end;
Realize that a cell's color change should be permanent, so that when the StringGrid is painted again, e.g. when the StringGrid was obfuscated by a dialog, also the special colors should be painted again.
Thus you need to store the desired colors somewhere. Say you want to use an array for that, then make a choice between:
Storing the special colors along with the grid coordinates in a one-dimensional array. This is good for memory usage, but you would need to search this entire array for the specific coordinate which the StringGrid's OnDrawCell handler (see step 3) provides,
Storing only the special colors in a two-dimensional array. This is good for speed when drawing, but you need to synchronize the array's column and row bounds to that of the StringGrid,
Or, when you do not need the Objects property of the StringGrid for any purpose, you could employ this property for color storage by typecasting the color to and from a TObject. Shout if you need help with that.
Paint the colored cells in a StringGrid's OnDrawCell event handler (search here on Stack Overflow for [Delphi] StringGrid OnDrawCell when in need of assistance with that).
The ListView's OnSelectItem event exposes the Item which is clicked or otherwise selected.
Retrieve necessery information from that item or its sub-items to determine which cell is to be changed in what color.
Add that information to the chosen storage solution of step 2.
Realize that when all painting now is done "automatically", just a call to StringGrid.Repaint should be enough.

Report Builder Spacing DBMemo Delphi

I am using a DBMemo (TPPDBMemo) component in reportbuilder within delphi. The Stretch property is true but the control doesn't always stretch itself out correctly within the region.
For example if there is lower case text, that dips downward, eg, chars like p,g,q... The bottom part of the text will get cut off if it's on the last line.
I tried adding an event to the onPrint to slightly grow the DBMemo when it prints,
procedure Tfrm.ppDBMemPrint(Sender: TObject);
begin
ppDBMem.Height := ppDBMem.Height + 10;
end;
But this didn't work.
Any thoughts on how this can be achieved. If I could simply add a border to the DBMemo that would be ideal, although I do not see that property anywhere.
Thank you!

Resources