##// END OF EJS Templates
Color themes now enabled for scatter, pie and line series.
Color themes now enabled for scatter, pie and line series.

File last commit:

r67:8474a34cb818
r75:cdad8ac737ab
Show More
xylinechartitem.cpp
67 lines | 1.6 KiB | text/x-c | CppLexer
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include "xylinechartitem_p.h"
Michal Klocek
Add zoom support...
r67 #include "axisitem_p.h"
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include "qxychartseries.h"
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include <QDebug>
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor current draft to fit int current design specs...
r21
Michal Klocek
Add zoom support...
r67 XYLineChartItem::XYLineChartItem(QXYChartSeries* series,QGraphicsItem *parent):ChartItem(parent),
m_series(series),
m_dirty(false)
Michal Klocek
Refactor current draft to fit int current design specs...
r21 {
}
Michal Klocek
Add zoom support...
r67 void XYLineChartItem::setSize(const QSize& size)
Michal Klocek
Refactor current draft to fit int current design specs...
r21 {
Michal Klocek
Add zoom support...
r67 m_rect=QRect(0,0,size.width(),size.height());
m_dirty=true;
}
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Add zoom support...
r67 void XYLineChartItem::setPlotDomain(const PlotDomain& data)
{
m_plotDomain=data;
m_dirty=true;
}
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Add zoom support...
r67 QRectF XYLineChartItem::boundingRect() const
{
return m_polyline.boundingRect();
}
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Add zoom support...
r67 void XYLineChartItem::updateGeometry()
{
if (!m_rect.isValid()) return;
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Add zoom support...
r67 const qreal deltaX = (m_rect.width()-1)/m_plotDomain.spanX();
const qreal deltaY = (m_rect.height()-1)/m_plotDomain.spanY();
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Add zoom support...
r67 m_polyline.clear();
m_polyline.resize(m_series->count());
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Add zoom support...
r67 for (int j = 0; j < m_series->count(); ++j) {
qreal dx = m_series->x(j) - m_plotDomain.m_minX;
qreal dy = m_series->y(j) - m_plotDomain.m_minY;
qreal x = (dx * deltaX) + m_rect.left();
qreal y = - (dy * deltaY) + m_rect.bottom();
m_polyline[j] = QPointF(x, y);
}
Michal Klocek
Refactor current draft to fit int current design specs...
r21
}
void XYLineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
{
Michal Klocek
Add zoom support...
r67 //TODO: remove it
if (m_dirty) {
updateGeometry();
m_dirty=false;
}
painter->setClipRect(m_rect.adjusted(+1, +1, -1, -1));
Michal Klocek
Refactor current draft to fit int current design specs...
r21 painter->setPen(m_series->color());
painter->drawPolyline(m_polyline);
}
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE