PointLables on series hide under screen near axis

82 Views Asked by At

I am trying to make this chart with the help of QtCharts but the pointlabels on the series hide under screen close to the axis. The problematic portion is highlighted in the picture. enter image description here

The Code for the graph function is here

#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include<QSplineSeries>
#include<QTimer>
#include<QPieSlice>

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);

QSplineSeries *series = new QSplineSeries();
series->append(0,0);
series->append(2,5);
series->append(4,6);
series->append(6,2);
series->append(8,9);
series->append(10,5);
QChart *chart = new QChart();
chart->legend()->hide();
chart->addSeries(series);

chart->setTitle("Data");
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);

series->setPointLabelsVisible(true);
series->setPointLabelsFormat("@yPoint");

//QCategoryAxis *axisX = new QCategoryAxis;
QValueAxis *axisX = new QValueAxis();

axisX->setRange(0,10);
axisX->setTitleText("title x");




chart->addAxis(axisX, Qt::AlignBottom);

QValueAxis *axisY = new QValueAxis();

axisY->setRange(0,9);
axisY->setTitleText("title y");
chart->addAxis(axisY,Qt::AlignLeft);
series->attachAxis(axisY);
series->attachAxis(axisX);


chartView->setFixedHeight(300);
chartView->setFixedWidth(300);
chartView->setParent(ui->chartlayout);

}
MainWindow::~MainWindow()
{
delete ui;
}
0

There are 0 best solutions below