0

Image of my graph

I have a graph made with cxGrid from DevExpress and on the X axis I have a date But when there is a lot of data in the graph these dates are cut to just 2 or 4 digits

How can I change it so the X axis only show text at every 5 or 10 values?

OZ8HP
  • 1,443
  • 4
  • 31
  • 61

1 Answers1

0

You should implement paging into your application. You can do that by overriding OnDataChanged and OnFilterRecord of your grid's ChartView.DataController:

   aChartView.DataController.OnDataChanged  := cvChartDataControllerDataChanged;
   aChartView.DataController.OnFilterRecord := cvChartDataControllerFilterRecord;

The point is to use OnFilterRecord to display just a limited amount of records at a time. That makes your chart presentable, otherwise you get too many data points. The most important one is OnFilterRecord. Here's an example:

procedure TSomeGrid.cvChartDataControllerFilterRecord(ADataController: TcxCustomDataController; ARecordIndex: Integer; var Accept: Boolean);
begin
// inspect the number of all records
   FNoOfRecords := ADataController.RecordCount;
//FStartRecordNo and FEndRecordNo are relative to the FCurrentPageNo
//calculated elsewhere OnDataChanged
   if FCurrentPageNo > 0 then
      Accept := (ARecordIndex >= FStartRecordNo) and (ARecordIndex <= FEndRecordNo)
   else
      Accept := ARecordIndex < FMaxChartRecords;
end;
Mihaela
  • 2,482
  • 3
  • 21
  • 27
  • If this results in some data not being showed in the graph, this is not an option. It is essential that all records are shown so the end user gets the best picture. – OZ8HP Mar 05 '12 at 17:45
  • Well that's how I dealt with it. There are just so many pixels per inch. But if that's not what you need then my approach is not right for you. What you need is to somehow override OnGetText or similar, of your x axis. I do think that DevExpress user groups might be better suited for this question. They answered any questions I had within 2-4 hours, and often with code example. Their support is great, so maybe you should try there. – Mihaela Mar 05 '12 at 18:18
  • Your approach might be usable but I am having som trouble figuring out how to use it. There is a sample of my form in the file www.hugopedersen.dk/_guest/cxGridGraph.zip if someone should be able to telle me how. – OZ8HP Mar 05 '12 at 18:58
  • The name of the file is in fact www.hugopedersen.dk/_guest/grid.zip – OZ8HP Mar 06 '12 at 08:16
  • I'm sorry but I don't have the time to inspect your source code. But if you would elaborate here on what your problem is I might help. The chart view as any other grid view may be filtered to display just a portion of available data. You implement filtering by overriding OnFilterRecord in regards to the current page. Say you're on the first page, than you would put, for example, Accept := (ARecordIndex > 0) and (ArecordIndex <=10) for the first page, and so on (showing 10 records per page, should be pretty readable in DevEx chart) – Mihaela Mar 06 '12 at 23:01
  • your suggestion does what I was afraid of - it removes some of my data and that makes the graph unusable for mi users. It becomes less accurate and that is not acceptable for them. Otherwise it does remove some of the dates as I want, but I need all the data still. – OZ8HP Mar 11 '12 at 17:46