Page 1 of 1
Setting LabelFrequency of a chart
Posted: Mon Dec 16, 2013 4:24 pm
by DrTob
I create a new Chart on a sheet with
everything works well. But if I have many values excel only prints every second (or less) label.
If tried to set the label frequency with:
Code: Select all
chart.PlotArea.SerieAxis.CatSerAxisScaling.LabelsFrequency := 1;
but this results in an Error "Property has no data", because the record of "CatSerAxisScaling" is nil.
how can I set the labelfrequency and orientation of the chart?
Re: Setting LabelFrequency of a chart
Posted: Fri Dec 20, 2013 9:18 am
by larsa
Hello
Sorry, I have no idea how to do this. To find out how, create an excel file with the settings you want and check what values excel sets.
Re: Setting LabelFrequency of a chart
Posted: Mon Jan 06, 2014 2:11 pm
by DrTob
Hello,
i've figured out, that the right setting is
Sheet.PlotArea.CategoryAxis.CatSerAxisScaling.LabelsFrequency
however I'm not able to set this Value in a new created file.
If I open a created file in EXCEL (2013), the "best fitting" value is selected. If I save the File (without any changes!) and Reset LabelsFrequency to 1, the setting is used.
Sample:
Code: Select all
procedure CreateSample;
var
xls: TXLSReadWriteII4;
I: Integer;
chart : TDrwChart;
begin
xls := TXLSReadWriteII4.Create(nil);
try
xls.FileName := 'test.xls';
xls.Sheets.Add().Name := 'data';
for I := 0 to 99 do begin
xls.sheet[1].AsString[0,I] := 'Value' + IntToStr(I);
xls.Sheet[1].AsInteger[1,I] := Random(100);
end;
xls.sheet[0].Charts.Clear;
chart := xls.sheet[0].Charts.Add(0);
chart.Row1 := 6;
chart.Row2 := 30;
chart.Col1 := 0;
chart.Col2 := 12;
chart.series.Items[0].Values := '''data''!B1:B100';
chart.PlotArea.ValueAxis.ValueAxisScaling.MinValue := 0;
chart.PlotArea.ValueAxis.ValueAxisScaling.MaxValue := 100;
chart.PlotArea.ValueAxis.ValueAxisScaling.MajorInc := 10;
chart.series.Items[0].Category := '''data''!A1:A100';
chart.PlotArea.ValueAxis.Tick.MajorTick := ttOutside;
chart.PlotArea.ValueAxis.Tick.MinorTick := ttInvisible;
chart.PlotArea.HasLegend := false;
chart.PlotArea.CategoryAxis.CatSerAxisScaling.LabelsFrequency := 1;
xls.Write;
finally
xls.Free;
end;
end;
When I open the created XLS in EXCEL, only every fourth label is shown. After saving it (without any changes) and read it again, chart.PlotArea.CategoryAxis.CatSerAxisScaling.LabelsFrequency is 4. Resetting it to 1 has the desired effect, EXCEL now shows all Lables.
Why is the initial setting ignored?