refactor:调整柱形图数据面板获取实时数据的逻辑
This commit is contained in:
parent
a3ddfb95b9
commit
dad06a43d9
|
|
@ -204,8 +204,34 @@ void dpBarsChart::setDateTime(const QDateTime& dateTime)
|
|||
if(m_updateData)
|
||||
{
|
||||
for(auto it = m_bars.begin(); it != m_bars.end(); ++it)
|
||||
{
|
||||
//DataManager::instance()->requestData(it.key(), this);
|
||||
|
||||
MeasurementDataPoint data = MeasurementDataManager::instance()->getLastestRealtimeData(it.key());
|
||||
if(data.timestamp == 0)
|
||||
continue;
|
||||
|
||||
static double marginFactor = 1.0;
|
||||
double dData = data.value;
|
||||
Bars bar = it.value();
|
||||
//调整所在轴的范围
|
||||
QCPRange range = bar.qBars->valueAxis()->range();
|
||||
if(dData > range.upper)
|
||||
{
|
||||
double upper = dData + marginFactor;
|
||||
bar.qBars->valueAxis()->setRangeUpper(upper);
|
||||
}
|
||||
else if(dData < range.lower)
|
||||
{
|
||||
double lower = dData - marginFactor;
|
||||
bar.qBars->valueAxis()->setRangeLower(lower);
|
||||
}
|
||||
//更新值
|
||||
QVector<double> values;
|
||||
values << dData;
|
||||
bar.qBars->setData(bar.keys, values);
|
||||
}
|
||||
|
||||
m_pCustomPlot->replot();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ void MeasurementDataManager::getSubscriptionRealtimeData()
|
|||
if(m_clientID.isEmpty())
|
||||
return;
|
||||
|
||||
QString strUrl = QString("ws:://%1:%2/%3/%4").arg(m_serviceConfig.realtimeCfg.host
|
||||
QString strUrl = QString("ws://%1:%2/%3/%4").arg(m_serviceConfig.realtimeCfg.host
|
||||
, QString::number(m_serviceConfig.realtimeCfg.port)
|
||||
, m_serviceConfig.realtimeCfg.websocketPath
|
||||
, m_clientID);
|
||||
|
|
|
|||
Loading…
Reference in New Issue