Skip to content

bexolder2/ChartLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChartLib

Charting cpp lib for Windows

Simple GDI+ wrapper for drawing charts.

📊 Screenshots

📖 Features

  • 📐 Draw coordinates grid.
  • 📊 Draw bars.

📑 Roadmap

  • Support for line charts
  • Support for circular diagram
  • Resizable grid
  • Custom chart legend

Build

  • Visual Studio 2022

Usage

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.

About

Simple GDI+ wrapper for drawing charts

Resources

Stars

Watchers

Forks

Languages