mercredi 21 août 2019

Q3DBars with grid on vertical walls, tell me how?

This is the plot

enter image description here

And this is the code

.pro

QT       += core gui datavisualization

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TEMPLATE = app

CONFIG += c++11

SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

main.cpp

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
};

#endif // MAINWINDOW_H

mainwindow.cpp

#include "mainwindow.h"

#include <QtDataVisualization/q3dbars.h>
using namespace QtDataVisualization;

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
    resize(800,600);

    Q3DBars *graph = new Q3DBars();
    QWidget *container = QWidget::createWindowContainer(graph);
    setCentralWidget(container);

    graph->activeTheme()->setLabelBackgroundEnabled(!graph->activeTheme()->isLabelBackgroundEnabled());

    graph->scene()->activeCamera()->setCameraPosition(40,20);

    graph->valueAxis()->setSegmentCount(4);

    graph->setBarSpacing(QSizeF(1,3));

    QBar3DSeries *series = new QBar3DSeries;
    graph->addSeries(series);

    QStringList cycle{"40", "30", "20", "10", "0"};
    QStringList phase{"0", "10", "20", "30", "40"};

    QBarDataArray *dataSet = new QBarDataArray;

    graph->valueAxis()->setRange(0, 100);
    graph->rowAxis()->setRange(0, cycle.count()-1);
    graph->columnAxis()->setRange(0, phase.count()-1);

    series->dataProxy()->resetArray(dataSet, cycle, phase);
}

MainWindow::~MainWindow() {}

Now to the question:

  1. Can I have grid lines on vertical walls? I mean vertical lines in the picture, same way as in the floor.

  2. Can I have dashed grid lines, so that they differentiate from axis lines?

  3. Can I have labels for vertical axis (values axis) in just one corner, instead of two?

Aucun commentaire:

Enregistrer un commentaire