Overview
TeeChart provides powerful custom drawing capabilities through its Canvas API, allowing you to draw directly on charts and create custom visualizations beyond standard series types. The Canvas API supports multiple rendering engines including GDI, GDI+, OpenGL, and Skia.Canvas Drawing Fundamentals
Drawing on Chart Events
Use chart events to add custom drawing to your charts:OnBeforeDraw- Before any chart element is drawnOnAfterDraw- After all elements are drawnSeries.OnAfterDrawValues- After series values are painted
Advanced Canvas Features
Anti-Aliasing
Create smooth, high-quality graphics with anti-aliasing: Source:VCL/TeeNew/Canvas_AntiAlias.pas:40
180-Degree Rotation
Rotate chart elements for special effects: Source:VCL/TeeNew/Canvas_180Rotation.pas
Grayscale Conversion
Convert charts to grayscale for printing or special effects: Source:VCL/TeeNew/Canvas_GrayScale.pas
Custom Pen Styles
Dotted Pen Patterns:VCL/TeeNew/Canvas_DotPen.pas
Transparency Effects
Source:VCL/TeeNew/Canvas_Transparency.pas
3D Canvas Drawing
Draw3D Component
TheTDraw3D component provides a dedicated 3D drawing surface:
Source: VCL/TeeNew/Draw3D_Canvas.pas:64
Available 3D Shapes
Cube(X0, X1, Y0, Y1, Z0, Z1, Dark3D)- Draw 3D boxPyramid(Vertical, X0, X1, Y0, Y1, Z0, Z1, ZTop)- Draw pyramidCone(Vertical, X0, X1, Y0, Y1, Z0, Z1, Dark3D)- Draw coneCylinder(Vertical, Left, Top, Right, Bottom, Z0, Z1, Dark3D)- Draw cylinder
VCL/TeeNew/Canvas_Cone.pas
Canvas Rendering Engines
GDI+ Canvas
Enhanced rendering with gradients and alpha blending: Source:VCL/TeeNew/Canvas_GDIPlus_New.pas:39
- High-quality anti-aliasing
- Alpha transparency
- Advanced gradient fills
- Better text rendering
Smooth Stretching
Source:VCL/TeeNew/Canvas_SmoothStretch.pas
Enable smooth image stretching for high-quality scaling:
Advanced Techniques
Rotated Ellipses
Source:VCL/TeeNew/Canvas_RotatedEllipse.pas
Rotation Center Control
Source:VCL/TeeNew/Canvas_RotCenter.pas
Control the center point for chart rotation:
Orthogonal Angle
Source:VCL/TeeNew/Canvas_OrthoAngle.pas
Custom Shape Pictures
Source:VCL/TeeNew/Canvas_CustomShapePicture.pas
Font Pictures
Source:VCL/TeeNew/Canvas_FontPicture.pas
Use font symbols as custom point markers.
Performance Considerations
When to Use Custom Drawing
Best for:- Annotations and labels
- Custom indicators
- Geometric overlays
- Special effects
- Mixed 2D/3D visualizations
- Large datasets (use optimized series instead)
- Real-time high-frequency updates
- Simple standard visualizations
Optimization Tips
-
Minimize OnAfterDraw Operations
-
Use Appropriate Pen Styles
-
Batch Drawing Operations
-
Choose the Right Canvas
- GDI: Fast, but no anti-aliasing
- GDI+: Good quality, moderate speed
- OpenGL: Best for 3D and high-performance
- Skia: High quality, good performance
Expert Tips
Coordinate Systems
Clipping Regions
Z-Order Control
Use different events to control drawing order:OnBeforeDrawSeries- Behind seriesOnAfterDrawSeries- In front of seriesOnAfterDraw- On top of everything
Related Examples
VCL/TeeNew/Canvas_CompactChart.pas- Compact chart layoutsVCL/TeeNew/Canvas_PyramidTrunc.pas- Truncated pyramidsVCL/TeeMaker/TeeBlockCanvas.pas- Advanced 3D block drawing
See Also
- OpenGL Rendering - Hardware-accelerated graphics
- Performance - Optimization techniques
- Draw3D Component - 3D drawing reference
