Question about TBarSeries lazarus / 55-TAChart ---------------------------------------------------------------------- ProgEd · 2013-03-15 00:22 I'm generating a graph as the result of some calculations. So far I've got the bar chart rotated so I have horizontal bars. Now I want to specify a max value for the Y axis (a range of 0 to 100). I'm also coding the instruction to add data as follows: FBar.AddXY(I, R, sCategories, clRed) where I is the X value (runs from 1 to 17) and R is the Y value (between 0 and 100). I'm assuming from the documentation that the third field would be the label that would be placed on the data, but I only get numbers, not the text. Clearly I have missed something, but what? So, the two questions: how do I specify a range for an axis and how do I get text on the axis? Thanks, Ed ---------------------------------------------------------------------- fred1933 · 2013-03-15 07:38 Hi, if you use TChart component, you can specify a range for X or/and Y axis by changing extent.XMax, extent.YMax.. extent.UseXMax,... fields of TChart component. You can directly change parameters in objects inspector. ---------------------------------------------------------------------- wp · 2013-03-15 08:33 You question regarding the axis labels is answered in http://www.lazar us.freepascal.org/index.php/topic,19820.msg113355.html#msg113355 ---------------------------------------------------------------------- ProgEd · 2013-03-15 15:22 Thanks for the two answers, they have helped. But I still have a small (major?) problem. The graph is drawn exactly the way I want it, but the labels on the axis are very inconsistent. Here's the code I'm using: Code: [Select]procedure TForm1.DoChart(Sender: TObject); var    I:                               Integer; begin    If FBar = nil then       begin          FBar := TBarSeries.Create(Chart1);          FBar.AxisIndexX := 0;        { Rotate the }          FBar.AxisIndexY := 1;        { graph axis }          Chart1.AddSeries(FBar);          FBar.Source := CSource;          Chart1.Extent.UseXMax := True;          Chart1.Extent.UseXMin := True;          Chart1.Extent.XMax := 100;          Chart1.Extent.XMin := 0;          Chart1.LeftAxis.Marks.Source := CSource;       end;    For I := 1 to 19 do       Begin          If iPct[I] < 70 then             CSource.Add(I, iPct[I], sCategories[I], clRed)          Else             CSource.Add(I, iPct[I]; sCategories[I], clBlue);       end; end; I can see the text being added to the CSource, but only some of the text values actually show up on the chart. Any ideas? Ed ---------------------------------------------------------------------- wp · 2013-03-15 21:46 What is "inconsistent"? Could you post a screenshot to explain what the issue is? ---------------------------------------------------------------------- ProgEd · 2013-03-16 01:16 I've been trying to send it, but the server keeps rejecting saying it's taking too long or is too big. Here's what I'm seeing, however, The chart formats the data correctly. The titles for each bar should be down the left side for each of the 19 bars. Only some are showing -- and that number varies! They are also shown out of order. For example, with one set of data I might see this: A   xxxxxxxxxxxxx      xxxxxxx      xxxxxxxxxxxxxxxxxxxx C   xxxxxxxxxxxxxxxxxx And with a different set of data, totally different text will be shown or omitted. Ed ---------------------------------------------------------------------- wp · 2013-03-16 12:00 Ok, I tried a demo on my own and could verify the issue. I guess, however, that this is not a bug, but a feature. You have to understand how the axis marks work: when you populate a listsource the first two parameters of the Add command are understood as the x and y coordinates, respectively, to which the label text is assigned. So, if you want the labels to appear at the y axis their coordinate is taken from the second parameter. But you had rotated the series which means that the y axis gets the values of the x axis, but the chart source finds the label positions from the original y values assigned to the chart source. A solution is to use a second list source for the labels alone. If you don't want to label the bars, you can drop the texts from the original source to save memory. The following idea works in my demo: Code: [Select]var   CDataSource: TListChartSource;   CLabelSource: TListChartSource; begin    for I := 1 to 19 do begin       If iPct[I] < 70 then         CDataSource.Add(I, iPct[I], '', clRed)       else         CDataSource.Add(I, iPct[I]. '', clBlue);       CLabelSource.Add(I, I, sCategories[I]);   end; end; The CDataSource is to be assigned to the Source property of the BarSeries, and the CLabelSource goes to the Source of yAxis.Marks. ---------------------------------------------------------------------- ProgEd · 2013-03-16 13:17 Thanks, that resolved the issue. I do, however, think it's a bug. Clearly the chart knows it's rotated, so one would think that the labels should also rotate. But the work-around you suggested has given me what I wanted. I really appreciate the help. Ed ---------------------------------------------------------------------- wp · 2013-03-16 21:18 QuoteClearly the chart knows it's rotated, so one would think that the labels should also rotate. This is only true for this simple chart. In general there are several series assigned to the axes, and they can be rotated or not. I know that this is not very common, but TAChart is flexible enough to handle even this case. Therefore it is a "feature", not a bug.