PDA

View Full Version : Qt Charts API: create static and animating charts for your application



dridk
10th January 2011, 23:22
Hello,

I plan to create a qt charts api in the same way than google charts tools. (http://code.google.com/intl/fr-FR/apis/chart/) With more option.

Why ?

Because I didn't find any nice library which do this job. Qwt is ugly and it's made for scientifist. If you know any other opensource library which do the same job, please tell me.
So, if you are interesting to help me in this project, please answer me . Then we will choice a repository ( gitorious, google code...) and define the API. ( QGraphicsItem or QML....)

I think this library is really important. Official Qt has no plan about that in the future release. And I guess it's not hard to build. But I cannot do it alone, and I need you.

xiaokui
11th January 2011, 02:03
good idea. I am interested in this project.

Eastwood (http://www.jfree.org/eastwood/)Eastwood Charts is an independent and open source implementation of the Google Chart API (http://code.google.com/intl/fr-FR/apis/chart/index.html).

high_flyer
11th January 2011, 10:47
A week ago or so, there was a similar thread.
Someone posted a link to qt-apps web site to a chart lib.
You might want to have a look there first.

Nightmaster
12th January 2011, 09:56
Hi Everyone!
Very nice idea, but my class changed and became not universal.
histogram now looks : http://img30.imageshack.us/img30/8013/exmpl.jpg
Can also use my source code, but everything is based on the QPainter. I have some time now :)

marcvanriet
12th January 2011, 11:38
Hi,

At first glance, it seems that the 'API' is just a text string filled with different kinds of information. Seems not right to use this as a method to interface with an object in C++.

Also, I would just create chart objects that paint on a painter object. Then you can paint the chart on anything. You can make a convenience class derived from QGraphicsItem to make it easier to put a chart on a QGraphicsView. And you can also make a widget derived class to put it on a dialog.

Regards,
Marc

Nightmaster
12th January 2011, 11:53
Right, need to think about how to use the concept of Google Charts in QT.
how it would look like?
The same Parameter? same Graphics? hm.

javimoya
15th January 2011, 20:52
is this project dead before born??

Nightmaster
16th January 2011, 07:50
I do not know, just I had something on qt-apps : http://qt-apps.org/content/show.php/NightCharts%28Draw+Charts%29?content=132560
I don't understand how the result will look. Because java and web version can be represented in this form : https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
Qt version not.

Nightmaster
21st January 2011, 17:05
Hey, any body live?

ComaWhite
22nd January 2011, 00:09
Hey, any body live?

No we are dead

dridk
7th February 2011, 22:48
No we are not !

Sorry, I havn't enable email notification.. So I didn't see any update! But Now I am here!

First :
I have created a repository on gitorious : http://gitorious.org/qtcharts. Please Join the qtcharts team !!

second :
API architecture :

I propose to create 3 sub project :

- 1 : QPainter Layer : draw all sharts from a QPainter
- 2 : QGraphicsItem : Create each sharts item using QPainter layer
- 3 : QChartData : Provide data to be load


class tree example :

QChartPainter
-QLineChartPainter
-QPieChartPainter


QGraphicsChartItem
-QGraphicsLineChartItem
-QGraphicsPieChartItem





Discussion

We have to speak together about qtcharts! So, please join #qtcharts on freenode!
If there is nobody, please wait !

So, now, I m waiting for your suggestion about the API architecture ? What about animation ? Interaction ? QML ?

marcvanriet
8th February 2011, 01:04
Can't find any qtcharts on freenode. Anyway :

Data :
- what data can you handle : integer / double values, labels, min/max indicators, complex values, quaternions, ...
- do you use a model-view approach or not ?
- will you have only 1 data series, or more (multiple lines in your graph)

Display :
- are you going to make different display classes for the qpainter and qgraphicsview ? Will be difficult to make sure they look the same. QGraphicsview is not required for just showing graphs, but is sure is handy for interactive graphs (selecting data points, pie slices, ...)
- are you going to stick to line charts and pie charts ? or also bar graphs, coloured maps, ...

Classes :
- I would make a 'QtCharts' object that can hold any kind of data, for 1 or more data 'lines', and also additional data like labels, min/max values, .... This object could then be painted by the painter classes, be it either pie or line.

Regards,
Marc

dridk
8th February 2011, 16:06
Yes, you are right! We have to provide a Model/view architecture!
And I didn't understand about your QtCharts object ?

About Data, a first approch is to split Uni-dimensional Data and Bi-Dimensionsal. And use QVariant as variable.

Exemple : Bidimensional
QChartData data;
data.add("jan", 23);
data.add("Feb", 32.3);
data.add("Mar", 14);

data.xAxis().setLabel("Month");
data.yAxis().setLabel("temperature);

Or : Unidimensional
QChartData data;
data.add("2");
data.add("4");
data.add("5");
data.add("6");

The question is : Do we have to provide the same Object for uni et bi dimensionnal ?
And what about Multi dimensional data ?

About display :

I agree with marc! Create a QPainter Layout and on the top, create Many QGraphicsItem.


So , The chat room is open on : irc.freenode.org #qtcharts

I m currently looking other API language.

You are all welcome to help us in this project!

Added after 4 minutes:

I just found this documentation ! It sounds great! Can be an example for qtcharts!

http://approximatrix.com/products/openchart2/documentation/images/arch.png

look the documentation here :
http://approximatrix.com/products/openchart2/documentation/developer-s-guide

Added after 29 minutes:

Here is a quickly preview ! It may be change ofcourse!

http://download.tuxfamily.org/omed/qtcharts/qtcharts.png

Added after 9 minutes:

How does it work :

QListChartModel * model = new QListChartModel;
model->setTitle("title");
model->addData("30", "20", "50");
model->setLabel("red", "green","blue");

QPieGraphicsChartItem * item = new QPieGraphicsChartItem;
item->setModel(model);
item->setBackgroundColor(Qt::white);
item->setColor("red", Qt::Red);

QGraphicsView * view = new QGraphicsView;
QGraphicsScene * scene = new QGraphicsScene(view);

scene->addItem(item);
view->show();

marcvanriet
8th February 2011, 23:00
Hi,

I'm not so familiar with the model/view architecture, but it seems a better approach to me to use the standard model classes, and not define your own. A programmer creates a QSqlQueryModel (which is a table model), and the ChartItem classes use this model (using myChart->setModel( mySqlQueryResults ). A convenience class can be made using QStandardItemModel in case you are not taking data from a database or so.

For a pie chart, you can say something like myChart->setPieFields( "country", "population" ) to say that the column 'country' must be used as labels for the pies, and 'population' for the values to display. You could define additional colums for other properties (e.g. color ).

For a line chart, you can then say something like :
- myChart->setXValues( "time") : define that the X values are in the 'time' column. If not defined, row number is used
- myChart->addLine( "progress" ) : add a line that takes data from the 'progress' column
- forecastline = myChart->addLine( "forecast" ) : add a second line taking data from the 'forecast' column
- forcastline->setMinMax( "forecastMin", "forecasrMax" ) : add minimum and maximum indicators for the forecast line for the 'forecastMin' and 'forecastMax' columns

Additional parameters / methods could specify the label, color, ...

The "myChart" is an object that contains different members for different elements of a chart (it contains different 'abstractgraphicschartitems' in your scheme). These are the lines as shown above, but also a title, axis definitions, legend, lighting effect, ...

I'm not sure about the painting. The easiest way is to define a PieChart class ( so like myChart = new PieChart() ) and a LineChart class (like myChart = new LineChart() ) and let them take care of the painting themselve. The approach of approximatrix is to define a renderer for each 'line' or 'data series'. This way it would be easy to make a chart that contains data presented in bars and also data in lines, which seems like a nice feature.

I'm going to read a bit more about view classes now.

Best regards,
Marc

Added after 10 minutes:

Seems I'm reinventing the wheel yet again...

Take a look at ItemViews Chart Example (http://doc.qt.nokia.com/latest/itemviews-chart.html)

Regards,
Marc

marcvanriet
9th February 2011, 12:39
Hi,

Found some more in google groups : see Ideas for Libqxt (http://groups.google.com/group/qt-gsoc/web/project-ideas?pli=1). There is some working code on https://bitbucket.org/aep/qt-charts/ that shows a line graph.

Best regareds,
Marc

Nightmaster
13th February 2011, 07:37
Glad you're alive :-)
A agree with Marcvanriet! Model architecture will be good. I think need to start with a complete description of the architecture.
Can't put on gitorious my developments on the drawing :( Try again

I don't know freenode is a single server or server group, but i'm on chat.freenode.net #qtcharts

marcvanriet
14th February 2011, 11:59
Hi,
I think chatting will be difficult because of the time zone differences (I'm in GMT-1).

Tried to load the project from gitorious, but got a 'server closed' message immediately.

One could also do some 'throw-away prototyping' first. E.g. take NightCharts (http://qt-apps.org/content/show.php/NightCharts%28Draw+Charts%29?content=132560) and transform it step-by-step into a more generic graph framework.

Qwt also uses separate classes for the graph, curve, legend, ... by the way. I'm not sure if it can be used with the model-view architecture.

Regards,
Marc

Nightmaster
14th February 2011, 12:55
My GMT +3.
IMHO, qwt was made with the unnecessary complexity. Qtcharts should be easy to use.
From Nightcharts can take part of rendering. I have achievements that are not included in nightcharts.

Sorry for my English, really do not have enough practice

marcvanriet
2nd March 2011, 19:44
We could also check out this : Birdeye visual analytics library (http://birdeye.googlecode.com/svn/branches/ng/examples/demo/BirdEyeExplorer.html)

Has a lot of different kinds of charts and combinations thereof.

Regards,
Marc

dridk
2nd March 2011, 20:49
Hello all,

I started yesterday to push my first commit on gitorious. I just create quickly the QChartDataModel:
So, if you want to test it :

git clone git://gitorious.org/qtcharts/qtcharts.git qtcharts

Be free to join us on gitorious : create an account and give me your nickname.

Another point, I create a mailing list to not overload the forum.
So, here is a public google group where you can join :

group site : http://groups.google.com/group/qtcharts-dev
mailing list : qtcharts-dev@googlegroups.com

Thanks for your interesting

ottoshmidt
5th March 2011, 09:16
Hey guys,

Not sure but how about having a look at Calligra Tables (former KSpread) source code. Might be they have good libs for building charts?


Oto

kernelsafe
8th December 2011, 02:18
hello, any news about the library?