##// END OF EJS Templates
integrating bar charts to test app.. crashes for now
integrating bar charts to test app.. crashes for now

File last commit:

r164:8e580b305fe6
r164:8e580b305fe6
Show More
charttheme.cpp
177 lines | 5.5 KiB | text/x-c | CppLexer
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 #include "charttheme_p.h"
#include "qchart.h"
Michal Klocek
Refactor themes...
r143 //series
#include "barchartseries.h"
#include "stackedbarchartseries.h"
#include "percentbarchartseries.h"
Michal Klocek
Fix previous broken commit
r145 #include "qlinechartseries.h"
Jani Honkonen
Make pie work better with chartwidgettest
r163 #include "qpieseries.h"
Michal Klocek
Refactor themes...
r143 //items
#include "axisitem_p.h"
#include "bargroup.h"
#include "stackedbargroup.h"
Michal Klocek
Fix previous broken commit
r145 #include "linechartitem_p.h"
Michal Klocek
Refactor themes...
r143 #include "percentbargroup.h"
Jani Honkonen
Make pie work better with chartwidgettest
r163 #include "piepresenter.h"
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103
Michal Klocek
Refactor themes...
r143 //themes
#include "chartthemevanilla_p.h"
#include "chartthemeicy_p.h"
#include "chartthemegrayscale_p.h"
#include "chartthemescientific_p.h"
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103
Tero Ahola
tuning theme colors
r125
Michal Klocek
Refactor themes...
r143 QTCOMMERCIALCHART_BEGIN_NAMESPACE
/* TODO
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 case QChart::ChartThemeUnnamed1:
Tero Ahola
One more alternative for changing themes
r108 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff3fa9f5)), 2));
m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff7AC943)), 2));
m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF931E)), 2));
m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF1D25)), 2));
m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF7BAC)), 2));
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103
m_gradientStartColor = QColor(QRgb(0xfff3dc9e));
m_gradientEndColor = QColor(QRgb(0xffafafaf));
Michal Klocek
Refactor themes...
r143 */
Michal Klocek
Adds missing ids to theme classes
r153 ChartTheme::ChartTheme(QChart::ChartTheme id)
Michal Klocek
Refactor themes...
r143 {
Michal Klocek
Adds missing ids to theme classes
r153 m_id = id;
Michal Klocek
Refactor themes...
r143 m_seriesColor.append(QRgb(0xff000000));
m_seriesColor.append(QRgb(0xff707070));
m_gradientStartColor = QColor(QRgb(0xffffffff));
m_gradientEndColor = QColor(QRgb(0xffafafaf));
}
Michal Klocek
Adds missing ids to theme classes
r153 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
Michal Klocek
Refactor themes...
r143 {
switch(theme) {
case QChart::ChartThemeDefault:
return new ChartTheme();
case QChart::ChartThemeVanilla:
return new ChartThemeVanilla();
case QChart::ChartThemeIcy:
return new ChartThemeIcy();
case QChart::ChartThemeGrayscale:
return new ChartThemeGrayscale();
case QChart::ChartThemeScientific:
return new ChartThemeScientific();
}
}
void ChartTheme::decorate(QChart* chart)
{
QLinearGradient backgroundGradient;
backgroundGradient.setColorAt(0.0, m_gradientStartColor);
backgroundGradient.setColorAt(1.0, m_gradientEndColor);
backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
chart->setChartBackgroundBrush(backgroundGradient);
}
//TODO helper to by removed later
void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
{
switch(series->type())
{
case QChartSeries::SeriesTypeLine: {
Michal Klocek
Fix previous broken commit
r145 QLineChartSeries* s = static_cast<QLineChartSeries*>(series);
LineChartItem* i = static_cast<LineChartItem*>(item);
Michal Klocek
Refactor themes...
r143 decorate(i,s,count);
break;
}
case QChartSeries::SeriesTypeBar: {
BarChartSeries* b = static_cast<BarChartSeries*>(series);
BarGroup* i = static_cast<BarGroup*>(item);
decorate(i,b,count);
break;
}
case QChartSeries::SeriesTypeStackedBar: {
StackedBarChartSeries* s = static_cast<StackedBarChartSeries*>(series);
StackedBarGroup* i = static_cast<StackedBarGroup*>(item);
decorate(i,s,count);
break;
}
case QChartSeries::SeriesTypePercentBar: {
PercentBarChartSeries* s = static_cast<PercentBarChartSeries*>(series);
PercentBarGroup* i = static_cast<PercentBarGroup*>(item);
decorate(i,s,count);
break;
}
Jani Honkonen
Make pie work better with chartwidgettest
r163 case QChartSeries::SeriesTypePie: {
QPieSeries* s = static_cast<QPieSeries*>(series);
PiePresenter* i = static_cast<PiePresenter*>(item);
decorate(i,s,count);
break;
}
Michal Klocek
Refactor themes...
r143 default:
qDebug()<<"Wrong item to be decorated by theme";
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 break;
}
Michal Klocek
Refactor themes...
r143
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 }
Michal Klocek
Fix previous broken commit
r145 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count)
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 {
Michal Klocek
Adds to themes support to lineseries
r152 QPen pen;
if(pen != series->pen()){
item->setPen(series->pen());
return;
}
pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
pen.setWidthF(2);
item->setPen(pen);
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 }
Michal Klocek
Refactor themes...
r143 void ChartTheme::decorate(BarGroup* item, BarChartSeries* series,int count)
Tero Ahola
One more alternative for changing themes
r108 {
sauimone
integrating bar charts to test app.. crashes for now
r164 for (int i=0; i< m_seriesColor.count(); i++) {
item->addColor(m_seriesColor.at(i));
}
Michal Klocek
Refactor themes...
r143 item->addColor(QColor(255,0,0,128));
item->addColor(QColor(255,255,0,128));
item->addColor(QColor(0,255,0,128));
item->addColor(QColor(0,0,255,128));
item->addColor(QColor(255,128,0,128));
Tero Ahola
One more alternative for changing themes
r108 }
Michal Klocek
Refactor themes...
r143 void ChartTheme::decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count)
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 {
sauimone
integrating bar charts to test app.. crashes for now
r164 for (int i=0; i< m_seriesColor.count(); i++) {
item->addColor(m_seriesColor.at(i));
}
Michal Klocek
Refactor themes...
r143 item->addColor(QColor(255,0,0,128));
item->addColor(QColor(255,255,0,128));
item->addColor(QColor(0,255,0,128));
item->addColor(QColor(0,0,255,128));
item->addColor(QColor(255,128,0,128));
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 }
Michal Klocek
Refactor themes...
r143 void ChartTheme::decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count)
{
sauimone
integrating bar charts to test app.. crashes for now
r164 for (int i=0; i< m_seriesColor.count(); i++) {
item->addColor(m_seriesColor.at(i));
}
Michal Klocek
Refactor themes...
r143 item->addColor(QColor(255,0,0,128));
item->addColor(QColor(255,255,0,128));
item->addColor(QColor(0,255,0,128));
item->addColor(QColor(0,0,255,128));
item->addColor(QColor(255,128,0,128));
}
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103
Jani Honkonen
Make pie work better with chartwidgettest
r163 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/)
{
// TODO: Does not work well. We need to generate enough different colors
// based on available theme and not use the same color twice.
for (int i=0; i<series->count(); i++) {
QPieSlice slice = series->slice(i);
slice.m_color = m_seriesColor.at(i % m_seriesColor.count());
series->update(i, slice);
}
}
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103
QTCOMMERCIALCHART_END_NAMESPACE