Simple GDI+ wrapper for drawing charts.
- 📐 Draw coordinates grid.
- 📊 Draw bars.
- Support for line charts
- Support for circular diagram
- Resizable grid
- Custom chart legend
- Visual Studio 2022
Initialize GDI in WinMain
.
GDI_service gdi;
gdi.initGDI();
Add resource cleanup before closing the application
gdi.shutdownGDI();
Initialize drawing with a handle to a device context (HDC)
gdi.initDrawing(hdc);
Create and initialize chart_grid
structure. You can specify segment value, maximum value and chart size. To disable X-coordinates labels set disable_x_labels
flag to true
in drawCoordinateGrid
.
chart_grid chart_settings = { 500, 25000, Rect(60, 10, 740, 740) };
gdi.drawCoordinateGrid(chart_settings);
Initialize bar_collection
structure and use drawBars
method to render the bars.
bar_collection bars;
for (int i = 0; i < 10; ++i)
{
Color c(0 + (rand() % 255), 0 + (rand() % 255), 0 + (rand() % 255));
bar_item item;
item.value = 500 + (rand() % 25000);
item.label = L"val_" + std::to_wstring(item.value);
item.pen = new Pen{ c };
item.brush = new SolidBrush{ c };
bars.items.push_back(item);
}
gdi.drawBars(bars);
A complete sample is available here.