Warning, file /graphics/kdiagram/examples/EmptyValues/mainwindow.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /**
0002  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include "mainwindow.h"
0021 
0022 #include <KChartChart>
0023 #include <KChartAbstractCoordinatePlane>
0024 #include <KChartCartesianAxis>
0025 #include <KChartBarDiagram>
0026 
0027 
0028 #include <QDebug>
0029 #include <QPen>
0030 #include <QHBoxLayout>
0031 
0032 using namespace KChart;
0033 
0034 MainWindow::MainWindow( QWidget* parent ) :
0035     QWidget( parent )
0036 {
0037     QHBoxLayout* chartLayout = new QHBoxLayout( this );
0038     m_chart = new Chart();
0039     chartLayout->addWidget( m_chart );
0040 
0041     m_model.loadFromCSV( ":/data" );
0042 
0043     // Set up the diagram
0044     m_bars = new BarDiagram();
0045     m_bars->setModel( &m_model );
0046     m_bars->addAxis( new CartesianAxis( m_bars ) );
0047 
0048     m_chart->coordinatePlane()->replaceDiagram( m_bars );
0049 
0050     CartesianCoordinatePlane *plane 
0051             = dynamic_cast<CartesianCoordinatePlane*>( m_chart->coordinatePlane() );
0052     Q_ASSERT( plane );
0053     // The values in the model are all zero, so set the size of the plane 
0054     // to something that is non-zero manually
0055     plane->setVerticalRange( QPair<qreal, qreal>( -2.0, 2.0 ) );
0056 }
0057