Closed ntting closed 6 years ago
In my case, I write the SQL to return 3 fields: 'Time', 'Metric', 'Value' in correct column order. And then I sort the result by Time and Metric to make it draw correctly.
Here is an example:
SELECT 'Time' = DATEADD(HOUR, -@server_zone, d.CounterTime)
, 'Metric' = CASE LEFT(c.MachineName, 2) WHEN '\\' THEN SUBSTRING(c.MachineName, 3, LEN(c.MachineName)) ELSE c.MachineName END
, 'Value' = SUM(d.CounterValue)
FROM #CounterDetails AS c WITH (NOLOCK)
CROSS APPLY (
SELECT _d.CounterTime, _d.CounterValue
FROM dbo.CounterData AS _d WITH (NOLOCK)
WHERE _d.CounterID = c.CounterID
AND _d.CounterTime BETWEEN @timefrom AND @timeto
) AS d
GROUP BY d.CounterTime, c.MachineName
ORDER BY 'Time', 'Metric';
Hope this help.
@ntting , Please follow @bily-gates suggestion and add the alias 'Time', 'Metric' and 'Value' to your columns. The plugin tries to automagically identify who is who ... but obviously is not doing so well :( I'll take a look at that asap.
Thanks @bily-gates
@bily-gates @gbrian Thanks very much, I test it, the result is correct according the reply of bily-gates
@ntting Cool. Glad that helped. 😄
Hi @gbrian Thanks very much for your worker, i have a problem, I want to show the y axis is F_Value_1, the x axis is time.
The query sql is: SELECT F_Value_1 , F_BeginTime FROM dbo.T_InverterData_Min WHERE F_StationID=1 AND F_GridConnectedPointID=1 AND F_InverterID=1 AND F_BeginTime >= '$from' AND F_BeginTime <= '$to' ORDER BY F_BeginTime ASC But the the panel is not show correct line. the targets in response is error, one target become the many number. the number is the number of F_Value_1 different value. How to write the correct sql, please help me.
the sql server database is:
panel:
response: