##// END OF EJS Templates
Revert "Fixes line uder grid issue"...
Revert "Fixes line uder grid issue" This reverts commit 3ea3ba4a33950ea7420e16913d228ed53fe566c3.

File last commit:

r173:5bd6f6e4373b
r191:0b54368f72bb
Show More
chartdataset.cpp
162 lines | 4.5 KiB | text/x-c | CppLexer
/ src / chartdataset.cpp
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "chartdataset_p.h"
Michal Klocek
Refactored for MVP...
r139 //series
Michal Klocek
Fix previous broken commit
r145 #include "qlinechartseries.h"
Michal Klocek
Refactored for MVP...
r139 #include "barchartseries.h"
#include "stackedbarchartseries.h"
#include "percentbarchartseries.h"
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 #include "qpieseries.h"
Tero Ahola
Integrated scatter again. Missing functionality....
r158 #include "qscatterseries.h"
Michal Klocek
Refactors qchart , adds line animation...
r131
QTCOMMERCIALCHART_BEGIN_NAMESPACE
ChartDataSet::ChartDataSet(QObject *parent):QObject(parent)
{
Domain domain;
m_domains<<domain;
}
ChartDataSet::~ChartDataSet()
{
// TODO Auto-generated destructor stub
}
const Domain& ChartDataSet::domain() const
{
return m_domains[m_domainIndex];
}
void ChartDataSet::addSeries(QChartSeries* series)
{
Michal Klocek
Refactored for MVP...
r139 // TODO: we should check the series not already added
m_chartSeries << series;
m_domainIndex = 0;
m_domains.resize(1);
Domain& domain = m_domains[m_domainIndex];
switch(series->type())
{
case QChartSeries::SeriesTypeLine: {
Michal Klocek
Fix previous broken commit
r145 QLineChartSeries* xyseries = static_cast<QLineChartSeries*>(series);
Michal Klocek
Refactored for MVP...
r139
for (int i = 0; i < xyseries->count(); i++)
{
qreal x = xyseries->x(i);
qreal y = xyseries->y(i);
domain.m_minX = qMin(domain.m_minX,x);
domain.m_minY = qMin(domain.m_minY,y);
domain.m_maxX = qMax(domain.m_maxX,x);
domain.m_maxY = qMax(domain.m_maxY,y);
}
break;
}
case QChartSeries::SeriesTypeBar: {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 qDebug() << "QChartSeries::SeriesTypeBar";
Michal Klocek
Refactored for MVP...
r139 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
sauimone
removed barchartseriesbase. functionality is now in model
r172 qreal x = barSeries->countCategories();
Michal Klocek
Refactored for MVP...
r139 qreal y = barSeries->max();
domain.m_minX = qMin(domain.m_minX,x);
domain.m_minY = qMin(domain.m_minY,y);
domain.m_maxX = qMax(domain.m_maxX,x);
domain.m_maxY = qMax(domain.m_maxY,y);
sauimone
added labels to series, intergrated with test app. minor hack to test app
r167 break;
Michal Klocek
Refactored for MVP...
r139 }
case QChartSeries::SeriesTypeStackedBar: {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 qDebug() << "QChartSeries::SeriesTypeStackedBar";
Michal Klocek
Refactored for MVP...
r139
StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
sauimone
removed barchartseriesbase. functionality is now in model
r172 qreal x = stackedBarSeries->countCategories();
qreal y = stackedBarSeries->maxCategorySum();
Michal Klocek
Refactored for MVP...
r139 domain.m_minX = qMin(domain.m_minX,x);
domain.m_minY = qMin(domain.m_minY,y);
domain.m_maxX = qMax(domain.m_maxX,x);
domain.m_maxY = qMax(domain.m_maxY,y);
break;
sauimone
added labels to series, intergrated with test app. minor hack to test app
r167 }
Michal Klocek
Refactored for MVP...
r139 case QChartSeries::SeriesTypePercentBar: {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 qDebug() << "QChartSeries::SeriesTypePercentBar";
Michal Klocek
Refactored for MVP...
r139
PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
sauimone
removed barchartseriesbase. functionality is now in model
r172 qreal x = percentBarSeries->countCategories();
Michal Klocek
Refactored for MVP...
r139 domain.m_minX = qMin(domain.m_minX,x);
domain.m_minY = 0;
domain.m_maxX = qMax(domain.m_maxX,x);
domain.m_maxY = 100;
break;
sauimone
added labels to series, intergrated with test app. minor hack to test app
r167 }
Michal Klocek
Refactored for MVP...
r139
Jani Honkonen
Pie chart refactoring
r142 case QChartSeries::SeriesTypePie: {
QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
// TODO: domain stuff
break;
}
Tero Ahola
Integrated scatter again. Missing functionality....
r158 case QChartSeries::SeriesTypeScatter: {
QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
Q_ASSERT(scatterSeries);
foreach (QPointF point, scatterSeries->data()) {
domain.m_minX = qMin(domain.m_minX, point.x());
domain.m_maxX = qMax(domain.m_maxX, point.x());
domain.m_minY = qMin(domain.m_minY, point.y());
domain.m_maxY = qMax(domain.m_maxY, point.y());
}
break;
}
Michal Klocek
Refactored for MVP...
r139 default: {
qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported";
return;
break;
}
}
emit seriesAdded(series);
emit domainChanged(domain);
}
bool ChartDataSet::nextDomain()
{
if (m_domainIndex < m_domains.count() - 1) {
m_domainIndex++;
emit domainChanged(m_domains[m_domainIndex]);
return true;
}
else {
return false;
}
}
bool ChartDataSet::previousDomain()
{
if (m_domainIndex > 0) {
m_domainIndex--;
emit domainChanged(m_domains[m_domainIndex]);
return true;
}
else {
return false;
}
}
void ChartDataSet::clearDomains()
{
if (m_domainIndex > 0) {
m_domainIndex = 0;
emit domainChanged(m_domains[m_domainIndex]);
}
}
void ChartDataSet::addDomain(const Domain& domain)
{
m_domains.resize(m_domainIndex + 1);
m_domains << domain;
m_domainIndex++;
emit domainChanged(domain);
Michal Klocek
Refactors qchart , adds line animation...
r131 }
#include "moc_chartdataset_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE