#include "chart.h" Chart::Chart(QCustomPlot* customPlot) { this->customPlot = customPlot; } //绘制折线图 void Chart::plotPolyline(QVector xData, QVector 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); }