LibEngsas
echartline.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  MA 02110-1301 USA.
18 */
19 
20 #ifndef ECHARTLINE_H
21 #define ECHARTLINE_H
22 
23 #include "echarts.h"
24 #include "echartbase.h"
25 
26 #include "echartvalues.h"
27 
28 #include <QMap>
29 #include <QColor>
30 #include <QVariant>
31 
54 {
55  Q_OBJECT
56  Q_PROPERTY(QString xTitle READ xTitle WRITE setXTitle)
57  Q_PROPERTY(QString yTitle READ yTitle WRITE setYTitle)
58  Q_PROPERTY(int xTicksAngle READ xTicksAngle WRITE setXTicksAngle)
59  public:
60  EChartLine(QWidget *parent = NULL);
61 
62  void setYTitle(QString yTitle);
63  inline QString yTitle() const { return myYTitle; }
64  void setXTitle(QString xTitle);
65  inline QString xTitle() const { return myXTitle; }
66  void setXTicksAngle(int angle);
75  int xTicksAngle() const;
76 
77  void setXTicks(const QList<QVariant> xTicks);
78  void setYTicks(const QList<QVariant> yTicks);
79 
80  protected:
81  void drawChart(QPainter *painter, QRect viewPort);
85  void mouseMoveEvent(QMouseEvent * event);
86 
87  private:
88  float linearInterpolation(const float dy, const float x1, const float x0, const float y0, const float x) const;
89 
90  QString myXTitle, myYTitle;
91  QList<QVariant> xTicks, yTicks;
92  bool xNumeric, yNumeric;
96  QMap<QString, QList<QPointF> > linesDrawn;
97  QPoint origin, currentPosition;
98  qreal currentXValue, currentYValue;
100 };
101 
102 #endif // ECHARTLINE_H
virtual void drawChart(QPainter *painter, QRect viewPort)=0
Function to draw the chart.
int myXTicksAngle
Definition: echartline.h:99
Base class for ECharts.To add values, call addDataSet(). How the values are treated or how many data ...
Definition: echartbase.h:56
qreal currentYValue
Definition: echartline.h:98
QList< QVariant > yTicks
Definition: echartline.h:91
A EWidget to display line chartsThe title of the whole chart can be set by setTitle(). Afterwards set the title of the x- (setXTitle()) and y-axis (setYTitle()). Now configure the x- and y-axis with setXTicks() and setYTicks(). The chart is configured now and you can add lines with addDataSet(). Make sure, that the values are added in the order of x- and y-ticks. If x-ticks and y-ticks are not numeric, x- and y-values can only contain exactly the values from x-ticks and y-ticks.
Definition: echartline.h:53
QString xTitle() const
Definition: echartline.h:65
QMap< QString, QList< QPointF > > linesDrawn
Definition: echartline.h:96
QPoint origin
Definition: echartline.h:97
#define E_CHARTS_EXPORT
Definition: echarts.h:31
QString myYTitle
Definition: echartline.h:90
bool yNumeric
Definition: echartline.h:92