71 lines
2.3 KiB
C++
71 lines
2.3 KiB
C++
|
|
#include "dpLineChart.h"
|
||
|
|
#include "util/Chart/qcustomplot.h"
|
||
|
|
|
||
|
|
dpLineChart::dpLineChart(QWidget* parent)
|
||
|
|
:dpBaseWidget(parent)
|
||
|
|
{
|
||
|
|
setAttribute(Qt::WA_TranslucentBackground,true);
|
||
|
|
|
||
|
|
m_pCustomPlot = new QCustomPlot(this);
|
||
|
|
initQCP();
|
||
|
|
|
||
|
|
QBoxLayout* mainLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||
|
|
mainLayout->setContentsMargins(0, 1, 0, 0);
|
||
|
|
mainLayout->addWidget(m_pCustomPlot);
|
||
|
|
setLayout(mainLayout);
|
||
|
|
}
|
||
|
|
|
||
|
|
dpLineChart::~dpLineChart()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void dpLineChart::initQCP()
|
||
|
|
{
|
||
|
|
m_pCustomPlot->axisRect()->setupFullAxesBox();
|
||
|
|
m_pCustomPlot->xAxis->setSubTicks(false);
|
||
|
|
m_pCustomPlot->xAxis2->setTicks(false);
|
||
|
|
m_pCustomPlot->xAxis2->setSubTicks(false);
|
||
|
|
m_pCustomPlot->yAxis->setSubTicks(false);
|
||
|
|
m_pCustomPlot->yAxis2->setTicks(false);
|
||
|
|
m_pCustomPlot->yAxis2->setSubTicks(false);
|
||
|
|
//背景颜色
|
||
|
|
m_pCustomPlot->setBackground(QBrush(Qt::transparent));
|
||
|
|
//坐标轴颜色
|
||
|
|
QColor axisColor(100, 100, 100);
|
||
|
|
m_pCustomPlot->xAxis->setBasePen(axisColor);
|
||
|
|
m_pCustomPlot->xAxis->setTickPen(axisColor);
|
||
|
|
m_pCustomPlot->xAxis2->setBasePen(axisColor);
|
||
|
|
m_pCustomPlot->xAxis2->setTickPen(axisColor);
|
||
|
|
m_pCustomPlot->yAxis->setBasePen(axisColor);
|
||
|
|
m_pCustomPlot->yAxis->setTickPen(axisColor);
|
||
|
|
m_pCustomPlot->yAxis2->setBasePen(axisColor);
|
||
|
|
m_pCustomPlot->yAxis2->setTickPen(axisColor);
|
||
|
|
//坐标刻度颜色
|
||
|
|
QColor tickColor(100, 100, 100);
|
||
|
|
m_pCustomPlot->xAxis->setTickPen(QPen(tickColor));
|
||
|
|
m_pCustomPlot->yAxis->setTickPen(QPen(tickColor));
|
||
|
|
//坐标刻度Label颜色
|
||
|
|
QColor tickLabelColor(250, 250, 250);
|
||
|
|
m_pCustomPlot->xAxis->setTickLabelColor(tickLabelColor);
|
||
|
|
m_pCustomPlot->xAxis->setTickLabelFont(QFont(QString::fromWCharArray(L"黑体"), 10));
|
||
|
|
m_pCustomPlot->yAxis->setTickLabelColor(tickLabelColor);
|
||
|
|
m_pCustomPlot->yAxis->setTickLabelFont(QFont(QString::fromWCharArray(L"黑体"), 10));
|
||
|
|
//网格线颜色
|
||
|
|
QColor gridColor(100, 100, 100);
|
||
|
|
m_pCustomPlot->xAxis->grid()->setPen(QPen(gridColor, 1, Qt::DotLine));
|
||
|
|
m_pCustomPlot->xAxis->grid()->setZeroLinePen(QPen(gridColor, 1, Qt::DotLine));
|
||
|
|
m_pCustomPlot->yAxis->grid()->setPen(QPen(gridColor, 1, Qt::DotLine));
|
||
|
|
m_pCustomPlot->yAxis->grid()->setZeroLinePen(QPen(gridColor, 1, Qt::DotLine));
|
||
|
|
}
|
||
|
|
|
||
|
|
void dpLineChart::setTimeRange(TimeUnit unit)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void dpLineChart::viewHistoricalData(QDateTime dateTime)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|