2
#include <KDChartChart>
3
#include <KDChartPolarDiagram>
4
#include <KDChartDataValueAttributes>
6
using namespace KDChart;
8
class ChartWidget : public QWidget {
11
explicit ChartWidget(QWidget* parent=0)
15
// initialize the ItemModel and fill in some data
16
m_model.insertRows( 0, 10 );
17
m_model.insertColumns( 0, 5 );
19
for ( int column = 0; column < m_model.columnCount(); ++column ) {
20
for ( int row = 0; row < m_model.rowCount(); ++row ) {
21
QModelIndex index = m_model.index( row, column );
22
m_model.setData( index, QVariant( value++ ) );
25
// We need a Polar plane for the Polar type
26
PolarCoordinatePlane* polarPlane = new PolarCoordinatePlane( &m_chart );
27
// replace the default Cartesian plane with
29
m_chart.replaceCoordinatePlane( polarPlane );
31
// assign the model to our polar diagram
32
PolarDiagram* diagram = new PolarDiagram;
33
diagram->setModel(&m_model);
35
// Configure some Polar specifical attributes
37
// Display data values
38
// not implemented yet - disable for now
39
const QFont font(QFont( "Comic", 10 ));
40
const int colCount = diagram->model()->columnCount();
41
for ( int iColumn = 0; iColumn<colCount; ++iColumn ) {
42
DataValueAttributes dva( diagram->dataValueAttributes( iColumn ) );
43
TextAttributes ta( dva.textAttributes() );
46
ta .setPen( QPen( Qt::gray ) );
47
ta.setVisible( true );
48
dva.setTextAttributes( ta );
49
dva.setVisible( true );
50
diagram->setDataValueAttributes( iColumn, dva);
54
// Assign our diagram to the Chart
55
m_chart.coordinatePlane()->replaceDiagram(diagram);
57
QVBoxLayout* l = new QVBoxLayout(this);
58
l->addWidget(&m_chart);
59
m_chart.setGlobalLeadingTop( 5 );
60
m_chart.setGlobalLeadingBottom( 5 );
66
QStandardItemModel m_model;
69
int main( int argc, char** argv ) {
70
QApplication app( argc, argv );