improved step plots (JKQTPstepHorizontalGraph, JKQTPstepVerticalGraph) with 3 step-modes (left/center/right), instead of only two (right/center)

added example for step plots
This commit is contained in:
jkriege2 2018-12-06 21:41:35 +01:00
parent a02d7ea3d2
commit 08d51390b3
14 changed files with 369 additions and 23 deletions

View File

@ -20,8 +20,9 @@ All test-projects are Qt-projects that use qmake to build. You can load them int
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest1_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest) | [Very Basic Example (Line Graph)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest) | `JKQTPxyLineGraph`<br/>C++-style QVector arrays of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_speed_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_speed) | [Line Graph with Live Data / Speed Test](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_speed) | `JKQTPxyLineGraph`<br/>external `std::array<double,N>` data, not owned by datastore<br/>live-data, measure plotting speed<br/>tipps to increas plotting speed |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_symbols_and_styles_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_styles) | [Line Graph with Different Symbols and Line Styles](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_styles) | `JKQTPxyLineGraph`<br/>C++ vector of data<br/>setting line styles and symbol styles<br/>automatic graph coloring |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_symbols_and_errors_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_errors) | [Simple Line/Symbol Graph With Errorbars](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_errors) | `JKQTPxyLineErrorGraph`<br/>C-style arrays of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_errorbarstyles_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_errorbarstyles) | [Different Types of Errorindicators](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_errorbarstyles) | `JKQTPxyLineErrorGraph`<br/>different styles of error indicators for x- and y-errors<br>C++-style QVector for data<br/>styling error indicators<br/>moving key and formatting plotter grid |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_stepplots_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_stepplots) | [Step Line Plots in Different Styles](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_stepplots) | `JKQTPxyLineGraph`<br/>C++ vector of data<br/>setting line styles and symbol styles<br/>automatic graph coloring |
| [Simple Line/Symbol Graph With Errorbars](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_errors) | `JKQTPxyLineErrorGraph`<br/>C-style arrays of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_errorbarstyles_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_errorbarstyles) | [Different Types of Error Indicators](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_errorbarstyles) | `JKQTPxyLineErrorGraph`<br/>different styles of error indicators for x- and y-errors<br>C++-style QVector for data<br/>styling error indicators<br/>moving key and formatting plotter grid |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_barchart_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_barchart) | [Simple Bar Charts](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_barchart) | `JKQTPbarVerticalGraph`<br/>C-style arrays of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/JKQTPbarVerticalGraphStacked_small.png)<br>![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/JKQTPbarHorizontalGraphStacked_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_stackedbars) | [Stacked Bar Charts](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_stackedbars) | `JKQTPbarVerticalStackableGraph`, `JKQTPbarHorizontalStackableGraph`<br/>C++-style vectors of data |

View File

@ -540,7 +540,7 @@ JKQTPstepHorizontalGraph::JKQTPstepHorizontalGraph(JKQtBasePlotter* parent):
fillStyle=Qt::SolidPattern;
drawLine=true;
fillCurve=true;
valuesCentered=false;
stepType=JKQTPstepLeft;
if (parent) { // get style settings from parent object
@ -563,7 +563,7 @@ JKQTPstepHorizontalGraph::JKQTPstepHorizontalGraph(JKQtPlotter* parent):
fillStyle=Qt::SolidPattern;
drawLine=true;
fillCurve=true;
valuesCentered=false;
stepType=JKQTPstepLeft;
if (parent) { // get style settings from parent object
@ -650,8 +650,8 @@ void JKQTPstepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
// double ystart=-1;
double x0=xAxis->x2p(0);
if (parent->getXAxis()->isLogAxis()) x0=xAxis->x2p(parent->getXAxis()->getMin());
// double y0=yAxis->x2p(0);
// if (parent->getYAxis()->isLogAxis()) y0=yAxis->x2p(parent->getYAxis()->getMin());
double y0=yAxis->x2p(0);
if (parent->getYAxis()->isLogAxis()) y0=yAxis->x2p(parent->getYAxis()->getMin());
bool subsequentItem=false;
intSortData();
for (int iii=imin; iii<imax; iii++) {
@ -668,7 +668,7 @@ void JKQTPstepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
//double xl2=x;
//double yl2=y;
if (valuesCentered) {
if (stepType==JKQTPstepCenter) {
double d=(x-xold);
pf.lineTo(xold+d/2.0, yold);
pf.lineTo(xold+d/2.0, y);
@ -678,7 +678,14 @@ void JKQTPstepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
pl.lineTo(xold+d/2.0, y);
pl.lineTo(x, y);
}
} else {
} else if (stepType==JKQTPstepLeft) {
pf.lineTo(xold, y);
pf.lineTo(x, y);
if (drawLine) {
pl.lineTo(xold, y);
pl.lineTo(x, y);
}
} else if (stepType==JKQTPstepRight) {
pf.lineTo(x, yold);
pf.lineTo(x, y);
if (drawLine) {
@ -690,7 +697,7 @@ void JKQTPstepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
//std::cout<<"line ("<<xl1<<", "<<yl1<<") -- ("<<xl2<<", "<<yl2<<")"<<std::endl;
} else {
if (drawLine) pl.moveTo(x,y);
pf.moveTo(x0, y);
pf.moveTo(x, y0);
pf.lineTo(x, y);
//xstart=x;
//ystart=y0;
@ -701,7 +708,7 @@ void JKQTPstepHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
}
}
if (fillCurve) {
pf.lineTo(x0, yold);
pf.lineTo(xold, y0);
pf.closeSubpath();
}
painter.save();
@ -784,8 +791,8 @@ void JKQTPstepVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
double xold=-1;
double yold=-1;
// double x0=xAxis->x2p(0);
// if (parent->getXAxis()->isLogAxis()) x0=xAxis->x2p(parent->getXAxis()->getMin());
double x0=xAxis->x2p(0);
if (parent->getXAxis()->isLogAxis()) x0=xAxis->x2p(parent->getXAxis()->getMin());
double y0=yAxis->x2p(0);
if (parent->getYAxis()->isLogAxis()) y0=yAxis->x2p(parent->getYAxis()->getMin());
bool first=false;
@ -804,7 +811,7 @@ void JKQTPstepVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
//double xl2=x;
//double yl2=y;
if (valuesCentered) {
if (stepType==JKQTPstepCenter) {
double d=(y-yold);
pf.lineTo(xold, yold+d/2.0);
pf.lineTo(x, yold+d/2.0);
@ -814,7 +821,14 @@ void JKQTPstepVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
pl.lineTo(x, yold+d/2.0);
pl.lineTo(x, y);
}
} else {
} else if (stepType==JKQTPstepLeft) {
pf.lineTo(x, yold);
pf.lineTo(x, y);
if (drawLine) {
pl.lineTo(x, yold);
pl.lineTo(x, y);
}
} else if (stepType==JKQTPstepRight) {
pf.lineTo(xold, y);
pf.lineTo(x, y);
if (drawLine) {
@ -826,7 +840,7 @@ void JKQTPstepVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
//std::cout<<"line ("<<xl1<<", "<<yl1<<") -- ("<<xl2<<", "<<yl2<<")"<<std::endl;
} else {
if (drawLine) pl.moveTo(x,y);
pf.moveTo(x, y0);
pf.moveTo(x0, y);
pf.lineTo(x, y);
}
xold=x;
@ -834,7 +848,7 @@ void JKQTPstepVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
first=true;
}
}
pf.lineTo(xold, y0);
pf.lineTo(x0, yold);
pf.closeSubpath();
painter.save();
if (drawLine) {

View File

@ -397,7 +397,7 @@ class LIB_EXPORT JKQTPstepHorizontalGraph: public JKQTPxyGraph {
JKQTPGET_SET_MACRO(double, lineWidth)
JKQTPGET_SET_MACRO(bool, drawLine)
JKQTPGET_SET_MACRO(bool, fillCurve)
JKQTPGET_SET_MACRO(bool, valuesCentered)
JKQTPGET_SET_MACRO(JKQTPstepType, stepType)
protected:
/** \brief color of the graph */
QColor color;
@ -413,8 +413,8 @@ class LIB_EXPORT JKQTPstepHorizontalGraph: public JKQTPxyGraph {
bool drawLine;
/** \brief indicates whether to fill the space between the curve and the x-axis */
bool fillCurve;
/** \brief The steps are centered around the \f$ x_i \f$ values, if this is true. */
bool valuesCentered;
/** \brief specifies whether the steps elongate to the left, the right, or are centered around the \f$ x_i \f$ values. */
JKQTPstepType stepType;
/** \brief which plot style to use from the parent plotter (via JKQtPlotterBase::getPlotStyle() and JKQtPlotterBase::getNextStyle() ) */
int parentPlotStyle;

View File

@ -2204,3 +2204,56 @@ std::string jkqtp_chartostr(char data){
ost<<data;
return ost.str();
}
JKQTPstepTypeComboBox::JKQTPstepTypeComboBox(QWidget *parent):
QComboBox(parent)
{
clear();
setEditable(false);
addStep(JKQTPstepType::JKQTPstepLeft, JKQTPstepType2String(JKQTPstepType::JKQTPstepLeft));
addStep(JKQTPstepType::JKQTPstepCenter, JKQTPstepType2String(JKQTPstepType::JKQTPstepCenter));
addStep(JKQTPstepType::JKQTPstepRight, JKQTPstepType2String(JKQTPstepType::JKQTPstepRight));
setCurrentIndex(0);
}
JKQTPstepType JKQTPstepTypeComboBox::getStepType() const
{
return String2JKQTPstepType(itemData(currentIndex()).toString());
}
void JKQTPstepTypeComboBox::setStepType(JKQTPstepType step)
{
int i=findData(JKQTPstepType2String(step));
if (i>=0) setCurrentIndex(i);
}
void JKQTPstepTypeComboBox::setCurrentStepType(JKQTPstepType step)
{
setStepType(step);
}
void JKQTPstepTypeComboBox::addStep(JKQTPstepType step, const QString &name, const QIcon &icon)
{
addItem(icon, name, JKQTPstepType2String(step));
}
QString JKQTPstepType2String(JKQTPstepType pos)
{
switch(pos) {
case JKQTPstepLeft: return "step_left";
case JKQTPstepCenter: return "step_center";
case JKQTPstepRight: return "step_right";
}
return "";
}
JKQTPstepType String2JKQTPstepType(QString pos)
{
QString s=pos.trimmed().toLower();
if (s=="step_left"||s=="left"||s=="l") return JKQTPstepLeft;
if (s=="step_center"||s=="center"||s=="c") return JKQTPstepCenter;
if (s=="step_right"||s=="right"||s=="r") return JKQTPstepRight;
return JKQTPstepLeft;
}

View File

@ -1346,4 +1346,44 @@ template<>
inline constexpr double jkqtp_todouble(const bool& d) {
return static_cast<double>((d)?1.0:0.0);
}
/** \brief plot styles for the error information
* \ingroup jkqtplotter
*/
enum JKQTPstepType {
JKQTPstepLeft=0, /*!< \brief datapoint is on the left edge of the hor. step line */
JKQTPstepCenter=1, /*!< \brief datapoint is centered on the hor. step line */
JKQTPstepRight=2, /*!< \brief datapoint is on the right edge of the hor. step line */
};
/*! \brief a QComboBox which shows JKQTPstepType
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPstepTypeComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPstepTypeComboBox(QWidget* parent=nullptr);
JKQTPstepType getStepType() const;
void setStepType(JKQTPstepType step);
void setCurrentStepType(JKQTPstepType step);
protected:
void addStep(JKQTPstepType step, const QString& name, const QIcon &icon=QIcon());
};
/** \brief converts a JKQTPstepType variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPstepType2String(JKQTPstepType pos);
/** \brief converts a String into a JKQTPstepType
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPstepType String2JKQTPstepType(QString pos);
#endif // JKQTPTOOLS_H_INCLUDED

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -9,6 +9,30 @@ The QMake project looks like this (see `./test/jkqtplotter_simpletest/jkqtplotte
# source code for this simple demo
SOURCES = jkqtplotter_simpletest.cpp
# configure Qt
CONFIG += qt
QT += core gui xml svg
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
# output executable name
TARGET = jkqtplotter_simpletest
# include JKQtPlotter source headers and link against library
DEPENDPATH += . ../../lib
INCLUDEPATH += ../../lib
CONFIG (debug, debug|release):LIBS += -L../../lib/debug -ljkqtplotterlib
CONFIG (release):LIBS += -L../../lib/release -ljkqtplotterlib
# here you can activate some debug options
#DEFINES += SHOW_JKQTPLOTTER_DEBUG
#DEFINES += JKQTBP_AUTOTIMER
```
Alternatively to linking agains a `libjkqtplotter`, you can also directy add the JKQtPlotter sources to the project:
```qmake
# source code for this simple demo
SOURCES = jkqtplotter_simpletest.cpp
# configure Qt
CONFIG += qt
QT += core gui svg
@ -20,7 +44,7 @@ TARGET = jkqtplotter_simpletest
# include JKQtPlotter source code
include(../../lib/jkqtplotter.pri)
```
And the soruce code of the main application is (see `./test/jkqtplotter_simpletest/jkqtplotter_simpletest.cpp`):
The soruce code of the main application is (see `./test/jkqtplotter_simpletest/jkqtplotter_simpletest.cpp`):
```c++
#include <QApplication>
#include "jkqtplotter/jkqtplotter.h"

View File

@ -9,7 +9,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
# output executable name
TARGET = jkqtplotter_simpletest
# include JKQtPlotter source code
# include JKQtPlotter source headers and link against library
DEPENDPATH += . ../../lib
INCLUDEPATH += ../../lib
CONFIG (debug, debug|release):LIBS += -L../../lib/debug -ljkqtplotterlib

View File

@ -2,8 +2,8 @@
# JKQtPlotter
## Simple RGB image plot, showing a 3-channel OpenCV cv::Mat
This project (see `./test/jkqtplotter_simpletest_rgbimageplot_qt/`) simply creates a JKQtPlotter widget (as a new window) and adds an image plot with an image taken from a QImage object.
## `QImage` as a Graph
This project (see `./test/jkqtplotter_simpletest_rgbimageplot_qt/`) simply creates a JKQtPlotter widget (as a new window) and adds an image plot with an image taken from a [QImage](http://doc.qt.io/qt-5/qimage.html) object.
The source code of the main application is (see `./test/jkqtplotter_simpletest_rgbimageplot_qt/jkqtplotter_simpletest_rgbimageplot_qt.cpp`). the main parts are:
```c++

View File

@ -0,0 +1,58 @@
[Back to JKQTPlotter main page](https://github.com/jkriege2/JKQtPlotter/)
# JKQtPlotter
## Step Line Plots in Different Styles
This project (see `./test/jkqtplotter_simpletest_stepplots/`) simply creates a JKQtPlotter widget (as a new window) and adds a single line-graph (a sine-wave). Data is initialized from two QVector<double> objects.
The source code of the main application can be found in [`jkqtplotter_simpletest_stepplots.cpp`](https://github.com/jkriege2/JKQtPlotter/blob/master/test/jkqtplotter_simpletest_stepplots/jkqtplotter_simpletest_stepplots.cpp). For the most part, several datasets of cosine-curves are generated. then thrre tuples of graphs are added: One of type `JKQTPxyLineGraph`, which simply indicates the location of the actual datapoints. the second is of type `JKQTPstepHorizontalGraph`, which adds the step-graph to the plot:
```c++
// 3 now we make several plots with different step styles, each one also contains a
// symbol plot indicating the location of the datapoints themselves
JKQTPstepHorizontalGraph* graph;
JKQTPxyLineGraph* graphL;
//-- JKQTPstepLeft ----------------------------------------------------------------------------------------
graph=new JKQTPstepHorizontalGraph(&plot);
graphL=new JKQTPxyLineGraph(&plot);
// set data for both graphs
graph->set_xColumn(columnX); graphL->set_xColumn(graph->get_xColumn());
graph->set_yColumn(columnY1); graphL->set_yColumn(graph->get_yColumn());
// set step style
graph->set_stepType(JKQTPstepLeft);
graph->set_lineWidth(1);
graph->set_fillCurve(true);
graph->set_drawLine(true);
graph->set_title("JKQTPstepLeft, filled");
```
Note that you can configure the step type (left/center/right by `graph->set_stepType(JKQTPstepLeft)`. With `graph->set_fillCurve(true)` you can draw the curve filled until the y=0-axis and with `graph->set_drawLine(true)` you can switch the line along the values on and off (e.g. to only have the filled area, but no line).
Finally the `JKQTPxyLineGraph` is configured:
```c++
// set symbol + pen style and color for the added circles, copy color
graphL->set_symbol(JKQTPgraphSymbols::JKQTPcircle);
graphL->set_drawLine(false);
graphL->set_symbolSize(9);
graphL->set_symbolWidth(1);
graphL->set_color(graph->get_color());
```
... and all graphs are added to the plot:
```c++
// add the graphs to the plot, so it is actually displayed
plot.addGraph(graph);
plot.addGraph(graphL);
```
In addition to the symbol type and line style, you can also alter the size of the symbols (`graph->set_symbolSize(14)`), the line-width used to draw them (`graph->set_symbolWidth(1.5)`) and the line width of the graph line (`graph->set_lineWidth(1)`). If you want to switch off the line altogether, use `graph->set_drawLine(false`.
The result looks like this:
![jkqtplotter_simpletest_stepplots](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_stepplots.png)
[Back to JKQTPlotter main page](https://github.com/jkriege2/JKQtPlotter/)

View File

@ -0,0 +1,126 @@
#include <QApplication>
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtplottertools/jkqtptools.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
// 1. create a plotter window and get a pointer to the internal datastore (for convenience)
JKQtPlotter plot;
JKQTPdatastore* ds=plot.getDatastore();
// 2. now we create data a vector of x-values for a simple plot and several sets of y-values for
// cosine curves stacked above each other
QVector<double> X, Y1, Y2, Y3;
const int Ndata=10; // number of plot points in each curve
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*2.0*M_PI;
X<<x;
Y1<<cos(x)+1.0*1.5;
Y2<<cos(x)+2.0*1.5;
Y3<<cos(x)+3.0*1.5;
}
// and copy it to the datastore
size_t columnX=ds->addCopiedColumn(X, "x");
size_t columnY1=ds->addCopiedColumn(Y1, "y1");
size_t columnY2=ds->addCopiedColumn(Y2, "y2");
size_t columnY3=ds->addCopiedColumn(Y3, "y3");
// 3 now we make several plots with different step styles, each one also contains a
// symbol plot indicating the location of the datapoints themselves
JKQTPstepHorizontalGraph* graph;
JKQTPxyLineGraph* graphL;
//-- JKQTPstepLeft ----------------------------------------------------------------------------------------
graph=new JKQTPstepHorizontalGraph(&plot);
graphL=new JKQTPxyLineGraph(&plot);
// set data for both graphs
graph->set_xColumn(columnX); graphL->set_xColumn(graph->get_xColumn());
graph->set_yColumn(columnY1); graphL->set_yColumn(graph->get_yColumn());
// set step style
graph->set_stepType(JKQTPstepLeft);
graph->set_lineWidth(1);
graph->set_fillCurve(true);
graph->set_drawLine(true);
graph->set_title("JKQTPstepLeft, filled");
// set symbol + pen style and color for the added circles, copy color
graphL->set_symbol(JKQTPgraphSymbols::JKQTPcircle);
graphL->set_drawLine(false);
graphL->set_symbolSize(9);
graphL->set_symbolWidth(1);
graphL->set_color(graph->get_color());
// add the graphs to the plot, so it is actually displayed
plot.addGraph(graph);
plot.addGraph(graphL);
//-- JKQTPstepCenter ----------------------------------------------------------------------------------------
graph=new JKQTPstepHorizontalGraph(&plot);
graphL=new JKQTPxyLineGraph(&plot);
// set data for both graphs
graph->set_xColumn(columnX); graphL->set_xColumn(graph->get_xColumn());
graph->set_yColumn(columnY2); graphL->set_yColumn(graph->get_yColumn());
// set step style
graph->set_stepType(JKQTPstepCenter);
graph->set_lineWidth(1);
graph->set_fillCurve(false);
graph->set_drawLine(true);
graph->set_title("JKQTPstepCenter");
// set symbol + pen style and color for the added circles, copy color
graphL->set_symbol(JKQTPgraphSymbols::JKQTPcircle);
graphL->set_drawLine(false);
graphL->set_symbolSize(9);
graphL->set_symbolWidth(1);
graphL->set_color(graph->get_color());
// add the graphs to the plot, so it is actually displayed
plot.addGraph(graph);
plot.addGraph(graphL);
//-- JKQTPstepRight ----------------------------------------------------------------------------------------
graph=new JKQTPstepHorizontalGraph(&plot);
graphL=new JKQTPxyLineGraph(&plot);
// set data for both graphs
graph->set_xColumn(columnX); graphL->set_xColumn(graph->get_xColumn());
graph->set_yColumn(columnY3); graphL->set_yColumn(graph->get_yColumn());
// set step style
graph->set_stepType(JKQTPstepRight);
graph->set_lineWidth(1);
graph->set_fillCurve(false);
graph->set_drawLine(true);
graph->set_title("JKQTPstepRight");
// set symbol + pen style and color for the added circles, copy color
graphL->set_symbol(JKQTPgraphSymbols::JKQTPcircle);
graphL->set_drawLine(false);
graphL->set_symbolSize(9);
graphL->set_symbolWidth(1);
graphL->set_color(graph->get_color());
// add the graphs to the plot, so it is actually displayed
plot.addGraph(graph);
plot.addGraph(graphL);
// 4. scale plot manually
plot.setXY(-0.5, X.last()+0.5, -0.5, 7);
// 5. show plotter and make it a decent size
plot.show();
plot.resize(800,600);
return app.exec();
}

View File

@ -0,0 +1,22 @@
# source code for this simple demo
SOURCES = jkqtplotter_simpletest_stepplots.cpp
# configure Qt
CONFIG += qt
QT += core gui xml svg
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
# output executable name
TARGET = jkqtplotter_simpletest_stepplots
# include JKQtPlotter source code
DEPENDPATH += . ../../lib
INCLUDEPATH += ../../lib
CONFIG (debug, debug|release):LIBS += -L../../lib/debug -ljkqtplotterlib
CONFIG (release):LIBS += -L../../lib/release -ljkqtplotterlib
# here you can activate some debug options
#DEFINES += SHOW_JKQTPLOTTER_DEBUG
#DEFINES += JKQTBP_AUTOTIMER

View File

@ -0,0 +1,8 @@
TEMPLATE = subdirs
SUBDIRS += jkqtplotterlib jkqtplotter_simpletest_stepplots
jkqtplotterlib.file = ../../lib/jkqtplotterlib.pro
jkqtplotter_simpletest_stepplots.file=$$PWD/jkqtplotter_simpletest_stepplots.pro
jkqtplotter_simpletest_stepplots.depends = jkqtplotterlib