You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#include "chart.h"
|
|
|
|
Chart::Chart(QCustomPlot* customPlot)
|
|
{
|
|
this->customPlot = customPlot;
|
|
}
|
|
|
|
//绘制折线图
|
|
void Chart::plotPolyline(QVector<double> xData, QVector<double> yData)
|
|
{
|
|
QCPGraph* graph = customPlot->addGraph();
|
|
graph->setPen(QPen(Qt::blue,2));
|
|
graph->setBrush(QBrush(QColor(0,0,255,20))); //折线下面积
|
|
//graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle,QPen(Qt::blue,2),QColor(Qt::white),8));
|
|
// smoothType:折线图=-1 平滑算法1=0 平滑算法2=1
|
|
graph->setSmooth(true);
|
|
|
|
customPlot->xAxis2->setVisible(true);
|
|
customPlot->xAxis2->setTickLabels(false);
|
|
customPlot->yAxis2->setVisible(true);
|
|
customPlot->yAxis2->setTickLabels(false);
|
|
|
|
customPlot->xAxis->setAxisFormat("m");
|
|
customPlot->yAxis->setAxisFormat("m");
|
|
//设置图例
|
|
customPlot->legend->setVisible(true);
|
|
customPlot->legend->setBrush(QColor(255,255,255,0));//设置图例背景
|
|
customPlot->legend->setBorderPen(Qt::NoPen); //设置边框隐藏
|
|
customPlot->graph(0)->setName(u8"高度余量");//设置名称
|
|
|
|
|
|
|
|
|
|
graph->setData(xData,yData);
|
|
graph->rescaleAxes(true);
|
|
}
|