TAChart with BGRABitmap lazarus / 55-TAChart ---------------------------------------------------------------------- circular · 2011-05-03 12:49 Hello, I've done a unit to draw TAChart with BGRABitmap. It draws with antialiasing on a TBGRABitmap or on a TCanvas. The unit is attached. It's in fact an upgrade to TAChartBGRA package, so if you use this package, you can replace tadrawerbgra.pas in it. But you can also use this unit by copying it where you want. To use it follow theses steps : - add a TAChart component to a form and define its content - set it to invisible - add a PaintBox - add TADrawerBGRA in uses clause - define an OnPaint handler for the PaintBox, and write this : Code: [Select]BGRADrawChart(Chart1, PaintBox1);   That's it. When you modify a chart parameter, call PaintBox.Invalidate to show the changes. Note: to make it work, you will need the last svn version of BGRABitmap or download the last zip file of BGRABitmap at http://sourceforge.net/projects/lazpaint/files/src/ ---------------------------------------------------------------------- circular · 2011-05-03 13:00 Here is a screenshot : ---------------------------------------------------------------------- Ask · 2011-05-03 14:06 What is the difference with components/tachart/demo/bgra ? ---------------------------------------------------------------------- circular · 2011-05-03 16:52 It's faster and it can show all types of graphs I suppose. I did not test every types of graph. It is also easier to use. ---------------------------------------------------------------------- JD · 2011-06-15 11:12 Quote from: Ask on May 03, 2011, 04:06:59 pmWhat is the difference with components/tachart/demo/bgra ? @Ask I believe that you're the one in charge of the TAChart component. I have a feature request. Can you do something about the 3D charts produced by TAChart? Honestly, they don't look good at all. The axes are hidden by the chart & it is a bit of a letdown. I still prefer using the deprecated TBarChart for 3D bar charts. I'm aware that it could be a lot of work but I want you to know that it will be greatly appreciated especially now that TAChart has been enhanced with BGRABitmap. ---------------------------------------------------------------------- circular · 2011-06-15 14:19 With BGRABitmap, it is possible to : - draw bar with phong lighting - draw 3D bar by combining polygons with antialiased junction with TBGRAMultishapeFiller (in BGRAPolygon unit) about Phong lighting: http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial_9 bar sample: Code: [Select]uses BGRABitmap, BGRABitmapTypes, BGRAPolygon; { TForm1 } procedure TForm1.FormPaint(Sender: TObject); var bmp: TBGRABitmap;     p1,p2,p3,p4,h: TPointF;     multi: TBGRAMultishapeFiller; begin   bmp := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRAWhite);   p1 := pointF(40,10);   p2 := pointF(80,10);   p3 := pointF(60,30);   p4 := pointF(20,30);   h := pointF(0,200);   multi := TBGRAMultishapeFiller.Create;   multi.AddPolygon([p1,p2,p3,p4],BGRA(192,192,255));   multi.AddPolygon([p4,p3,p3+h,p4+h],BGRA(140,140,255));   multi.AddPolygon([p3,p2,p2+h,p3+h],BGRA(0,0,192));   multi.Draw(bmp);   multi.Free;   bmp.Draw(Canvas,0,0);   bmp.Free; end; ---------------------------------------------------------------------- JD · 2011-06-15 16:37 @circular That's great. The 3D bar looks polished! Thanks a lot for the work you are putting into BGRABitmap. Is it possible for you to show a complete example of a 3D bar chart complete with axes using TAChart & BGRABitmap? I would like to see the position of the bars with respect to the depth of the axes. Thanks again, JD ---------------------------------------------------------------------- circular · 2011-06-15 20:45 This depends on Ask. To include theses changes, it is necessary to change some code in TAChart and add some functions in the back-end class. ---------------------------------------------------------------------- JD · 2011-06-15 21:36 Quote from: circular on June 15, 2011, 10:45:19 pmThis depends on Ask. To include theses changes, it is necessary to change some code in TAChart and add some functions in the back-end class. @Ask We need you, man!  The future of Lazarus' charting abilities is in your hands. ---------------------------------------------------------------------- circular · 2013-02-03 19:56 Here is a patch to fix BGRA chart font height, and to provide line cap and join style to pen style : ---------------------------------------------------------------------- Ask · 2013-02-04 02:08 Thanks, committed with modifications in r40168 and r40169. ---------------------------------------------------------------------- Ask · 2013-02-04 15:46 As a first step to proper integration between TAChart and BGRABitmap (as well as other back-ends in the future), I have implemented TChartGUIConnectorBGRA component in r40178. This is a non-visual component, which is located on "Chart" page of the palette. To use BGRA as a back-end of existing chart, all you have to do now is to put this component on a form and assign in to GUIConnector property of the chart -- no extra code required. The connector should work at design-time too. Single connector can be used by multiple charts. ---------------------------------------------------------------------- circular · 2013-02-04 15:54 Cool. ---------------------------------------------------------------------- circular · 2013-02-04 16:38 Here is a bug fix and a fine-tuning for TABGRAUtils, that takes into account the color of the point. ---------------------------------------------------------------------- Ask · 2013-02-04 17:35 Can you also update the "bgra" demo of TAChart? Otherwise, it will break after this patch. ---------------------------------------------------------------------- circular · 2013-02-04 18:02 Here you are (apparently, the path is not kept) : ---------------------------------------------------------------------- circular · 2013-02-04 18:45 It would be useful to have access to the drawer from the TChartGUIConnectorBGRA object, in order to define special properties. ---------------------------------------------------------------------- circular · 2013-02-07 09:25 Here is a tutorial on how to improve TAChart rendering with BGRABitmap : http://wiki.freepascal.org/BGRABitmap_tutorial_TAChart ---------------------------------------------------------------------- Ask · 2013-02-08 22:37 Patch applied with small modifications in r40212. Quotea tutorial on how to improve TAChart rendering with BGRABitmapWhen setting BarSeries.Depth = 10, I recommend to also set BarSeries.ZPosition = 10 and Chart.Depth = 10. This will avoid clipping of 3D bars. QuoteIt would be useful to have access to the drawer from the TChartGUIConnectorBGRA object, in order to define special propertiesYes, this was a part of the plan. Since r40214, GUI connectors notify connected charts about property changes, so everything is ready for this stage. See r40217 for an example of GUI connector property, based on AggPas connector. Note, however, that GUI connector should only contain properties which are 100% specific for the corresponding drawer. For example, pixel format, path to font files, choice of font rendering engine, antialiasing/resampling method are good candidates. On the other hand, 3D lighting parameters, gradients, etc are not suitable here. ---------------------------------------------------------------------- circular · 2013-02-09 09:41 Well, then you need to include at least those phong parameters : ambiant lighting : single = 1specular lighting : single = 0specular index : single = 10diffusion lighting : single = 0light direction : (single,single,single) =(sqrt(1/3),sqrt(1/3),sqrt(1/3)) (the signs will depend on how you define 3D axes)(default values are indicated to show the "no lighting" mode) ---------------------------------------------------------------------- circular · 2013-02-09 09:51 Quote from: Ask on February 08, 2013, 11:37:24 pmSince r40214, GUI connectors notify connected charts about property changes, so everything is ready for this stage. See r40217 for an example of GUI connector property, based on AggPas connector. Hmm, Broadcaster does not seem to have a specified message to convey. Is it an Invalidate broadcaster ? ---------------------------------------------------------------------- Ask · 2013-02-09 15:00 QuoteBroadcaster does not seem to have a specified message to convey. Is it an Invalidate broadcaster ?Basically, yes. The Broadcaster does pass the object which has initiated the broadcast, which is sometimes used for more detailed actions.