##// END OF EJS Templates
Scaling for scatter series
Scaling for scatter series

File last commit:

r108:4cbe204cc325
r111:0d50fe03d2e8
Show More
xylinechartitem.cpp
72 lines | 1.7 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
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 XYLineChartItem::XYLineChartItem(QXYChartSeries* series,QGraphicsItem *parent) :
Tero Ahola
Refactoring continued: restored ChartItem class
r104 ChartItem(parent),
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 m_series(series),
m_pathItem(new QGraphicsPathItem(this))
Michal Klocek
Refactor current draft to fit int current design specs...
r21 {
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 setFlags(QGraphicsItem::ItemClipsChildrenToShape);
Michal Klocek
Refactor current draft to fit int current design specs...
r21 }
Tero Ahola
Refactoring continued: restored ChartItem class
r104 void XYLineChartItem::setSize(const QSize &size)
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 {
m_rect = QRect(0, 0, size.width(), size.height());
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 prepareGeometryChange();
updateGeometry();
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 }
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85
Michal Klocek
Add zoom support...
r67 void XYLineChartItem::setPlotDomain(const PlotDomain& data)
{
m_plotDomain=data;
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 prepareGeometryChange();
updateGeometry();
Michal Klocek
Add zoom support...
r67 }
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Add zoom support...
r67 QRectF XYLineChartItem::boundingRect() const
{
Tero Ahola
One more alternative for changing themes
r108 return m_rect;
}
void XYLineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
m_pathItem->setPen(m_series->pen());
Michal Klocek
Add zoom support...
r67 }
Tero Ahola
One more alternative for changing themes
r108
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 /*
QPainterPath XYLineChartItem::shape() const
{
return m_pathItem->shape();
}
*/
Michal Klocek
Add zoom support...
r67 void XYLineChartItem::updateGeometry()
{
if (!m_rect.isValid()) return;
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 const qreal deltaX = m_rect.width()/m_plotDomain.spanX();
const qreal deltaY = m_rect.height()/m_plotDomain.spanY();
Michal Klocek
Refactor xyplotdata...
r25
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 QPainterPath path;
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();
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 if(j==0) path.moveTo(x,y);
else path.lineTo(x,y);
Michal Klocek
Add zoom support...
r67 }
Michal Klocek
Refactor current draft to fit int current design specs...
r21
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 m_pathItem->setPath(path);
Tero Ahola
One more alternative for changing themes
r108 m_pathItem->setPen(m_series->pen());
Michal Klocek
Add gradient bacground support...
r86 m_pathItem->setBrush(Qt::NoBrush);
Michal Klocek
Refactor current draft to fit int current design specs...
r21 }
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE