This class includes a drawing histogram, pies and pseudo 3D pies.
It has very simple API and high level usability.
Licensed under LGPL 2.1
Example :
void MainWindow:

{
QWidget:

QPainter painter;
QFont font;
painter.begin(this);
Nightcharts PieChart;
PieChart.setType(Nightcharts:

PieChart.setLegendType(Nightcharts::Round);//{Round,Vertical}
PieChart.setCords(100,100,this->width()/1.5,this->height()/1.5);
PieChart.addPiece("Item1",QColor(200,10,50),34);
PieChart.addPiece("Item2",Qt::green,27);
PieChart.addPiece("Item3",Qt::cyan,14);
PieChart.addPiece("Item4",Qt::yellow,7);
PieChart.addPiece("Item5",Qt::blue,4);
PieChart.draw(&painter);
PieChart.drawLegend(&painter);
}
Updated : remove memory leak;
Initial angle can be set. so if you change it you can achieve the effect of motion of pie on its axis.
var : palpha = ;
Updated : Now the vertical legend has its own coordinates.
Use Nightcharts::setLegendCords(double x,double y);
Also changed rendering 3d Pie by removing the black frame. His screenshot was updated.
Updated : Added new option : Nightcharts::setShadows(bool);
Also changed rendering histogram and normal pie. Screenshots was updated.
Updated(2010/09/16) : Now when you create object does not need to pass QPainter; it is transmitted only in the methods draw/drawLegend. Also removed all memory leaks.
Updated(2015/04/01) : Posted code to github and soon there will be two new types of charts
(https://github.com/Nightmeister/nightcharts)
Write about found bugs please
Ratings & Comments
8 Comments
I run example and it work fine. But if I try write something like this: Quote:void MainWindow::on_pushButton_clicked()
{
PieChart->addPiece("dfgfg", Qt::black,10);
PieChart->draw(painter);
}
I've had message "The program has unexpectedly finished."?
Function "drawLegend" must return some value. Thanks for your job!
Function "drawLegend" must return some value. Thanks for your job!
Thank you for your code, I think this is greatly beautiful!
class moves into a new project. This will be a serious library for qt. Easy to use will be saved :)
Will be great if the chart can autoresize itself. Anyway, nice work man! Congratulations!
Really cool! I m waiting LineChart to make nice curves and more. I suggest to get inspiration from here : http://code.google.com/intl/fr-FR/apis/chart/ I already post a message here : http://www.qtcentre.org/threads/37703-Qt-Charts-API-create-static-and-animating-charts-for-your-application?p=173322&highlight=#post173322 Maybe we can join our force. Please upload your code on a repository like gitorious.
Agreed ! And a little doc would not hurt ;-)