修改曲线,通讯数据强度,速率
This commit is contained in:
@@ -5,26 +5,30 @@ int Chart::ChannelIndex = 0;
|
||||
Chart::Chart(QChart *chart, QWidget *parent)
|
||||
{
|
||||
chart->legend()->setAlignment(Qt::AlignRight);
|
||||
chart->legend()->setMarkerShape(QLegend::MarkerShapeCircle);
|
||||
chart->setTheme(QChart::ChartThemeLight);
|
||||
chart->legend()->setMarkerShape(QLegend::MarkerShapeDefault);
|
||||
chart->setTheme(QChart::ChartThemeQt);
|
||||
|
||||
//chart->setPlotArea(this->geometry());
|
||||
|
||||
|
||||
QValueAxis *axisX = new QValueAxis();
|
||||
axisX->setRange(-5, 5);
|
||||
axisX->setTickCount(11);
|
||||
axisX->setLabelFormat("%.2f");
|
||||
chart->addAxis(axisX, Qt::AlignBottom);
|
||||
|
||||
|
||||
QValueAxis *axisY = new QValueAxis();
|
||||
axisY->setRange(-3, 3);
|
||||
axisY->setTickCount(7);
|
||||
axisY->setLabelFormat("%.2f");
|
||||
//axisY->setLabelFormat("%.2f");
|
||||
chart->addAxis(axisY, Qt::AlignLeft);
|
||||
|
||||
setParent(parent);
|
||||
setChart(chart);
|
||||
|
||||
setScroll(true);
|
||||
|
||||
//默认不使用,因为使用显卡加速图形会闪
|
||||
setUseOpenGL(false);
|
||||
|
||||
@@ -33,7 +37,7 @@ Chart::Chart(QChart *chart, QWidget *parent)
|
||||
updateTimer = new QTimer(this);
|
||||
connect(updateTimer,SIGNAL(timeout()),
|
||||
this,SLOT(timeout()));
|
||||
updateTimer->start(50);//20hz刷新
|
||||
updateTimer->start(10);//10hz刷新
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,23 +46,27 @@ Chart::Chart(QWidget *parent)
|
||||
{
|
||||
setParent(parent);
|
||||
chart()->legend()->setAlignment(Qt::AlignRight);
|
||||
chart()->legend()->setMarkerShape(QLegend::MarkerShapeCircle);
|
||||
chart()->setTheme(QChart::ChartThemeLight);
|
||||
chart()->legend()->setMarkerShape(QLegend::MarkerShapeDefault);
|
||||
chart()->setTheme(QChart::ChartThemeQt);
|
||||
|
||||
//chart()->setPlotArea(this->geometry());
|
||||
|
||||
|
||||
QValueAxis *axisX = new QValueAxis();
|
||||
axisX->setRange(-5, 5);
|
||||
axisX->setTickCount(11);
|
||||
axisX->setLabelFormat("%.2f");
|
||||
//axisX->setRange(-5, 5);
|
||||
//axisX->setTickCount(11);
|
||||
//axisX->setLabelFormat("%.2f");
|
||||
chart()->addAxis(axisX, Qt::AlignBottom);
|
||||
|
||||
|
||||
QValueAxis *axisY = new QValueAxis();
|
||||
axisY->setRange(-3, 3);
|
||||
axisY->setTickCount(7);
|
||||
axisY->setLabelFormat("%.2f");
|
||||
chart()->addAxis(axisY, Qt::AlignLeft);
|
||||
|
||||
setScroll(true);
|
||||
|
||||
//默认不使用,因为使用显卡加速图形会闪
|
||||
setUseOpenGL(false);
|
||||
|
||||
@@ -67,7 +75,7 @@ Chart::Chart(QWidget *parent)
|
||||
updateTimer = new QTimer(this);
|
||||
connect(updateTimer,SIGNAL(timeout()),
|
||||
this,SLOT(timeout()));
|
||||
updateTimer->start(50);//20hz刷新
|
||||
updateTimer->start(10);//20hz刷新
|
||||
}
|
||||
|
||||
}
|
||||
@@ -223,10 +231,10 @@ void Chart::resizeEvent(QResizeEvent *e)
|
||||
|
||||
|
||||
|
||||
void Chart::timeout(void)//100Hz
|
||||
void Chart::timeout(void)//10Hz
|
||||
{
|
||||
timeseries += 0.01;
|
||||
chartUpdate();
|
||||
//timeseries += 0.1;
|
||||
//chartUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -377,6 +385,9 @@ bool Chart::addSeries(QString name = tr("new"),QColor color = QColor("#FFFFFF"))
|
||||
|
||||
void Chart::setSerieData(QString name,QVariant data)
|
||||
{
|
||||
timeseries++;
|
||||
//qDebug() << timeseries << timeseries;
|
||||
|
||||
//出新了比以前更大或者更小的值,那么就设置一下量程
|
||||
{
|
||||
QValueAxis *axis = dynamic_cast<QValueAxis*>(chart()->axisY());
|
||||
@@ -430,6 +441,8 @@ void Chart::setSerieData(QString name,QVariant data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chartUpdate();
|
||||
}
|
||||
|
||||
void Chart::removeSerie(QString name)
|
||||
|
||||
Reference in New Issue
Block a user