@@ -47,7 +47,9 @@ class TimeseriesHandler {
4747
4848 // Dependent unit
4949 var tableUnit = tableUnits [ j ] ;
50- tableName += " [" + tableUnit + "]" ;
50+ if ( tableUnit != null && tableUnit !== "null" ) {
51+ tableName += " [" + tableUnit + "]" ;
52+ }
5153
5254 // Get timestamps
5355 var tableTimes = entry [ "time" ] ;
@@ -56,16 +58,15 @@ class TimeseriesHandler {
5658 var timeClass = null
5759 var firstTime = tableTimes [ 0 ] ;
5860
59- // Regex tokens to test before and after conversion to Moment format
60- var regexBeforeMoment = String ( firstTime ) . match ( / ^ \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } ( : \d { 2 } ) { 1 , 2 } Z / ) ;
61- var regexAfterMoment = String ( firstTime ) . match ( / ^ \d { 4 } - \d { 2 } - \d { 2 } \s \d { 2 } ( : \d { 2 } ) { 1 , 2 } / ) ;
62-
63- if ( regexBeforeMoment || regexAfterMoment ) {
64- timeClass = "dateTime"
65- } else if ( String ( firstTime ) . includes ( ":" ) ) {
66- timeClass = "offsetTime"
61+ // Attempt to determine if time values are dates, times, or numbers
62+ if ( isNaN ( Date . parse ( firstTime ) ) && isNaN ( Date . parse ( firstTime . replaceAll ( "-" , "/" ) ) ) ) {
63+ if ( firstTime . includes ( ":" ) ) {
64+ timeClass = "offsetTime"
65+ } else {
66+ timeClass = "number" ;
67+ }
6768 } else {
68- timeClass = "number " ;
69+ timeClass = "dateTime " ;
6970 }
7071
7172 // Align time series formats
@@ -74,7 +75,7 @@ class TimeseriesHandler {
7475 // All times are local times!!
7576 for ( var t = 0 ; t < tableTimes . length ; t ++ ) {
7677 // dateTime/Instant format
77- if ( timeClass === "dateTime" ) {
78+ if ( timeClass === "dateTime" || entry [ "timeClass" ] === "Instant" ) {
7879 // @ts -ignore
7980 tableTimes [ t ] = moment ( tableTimes [ t ] , "YYYY-MM-DDTHH:mm:ss" ) . format ( "YYYY-MM-DD HH:mm:ss" ) ;
8081 }
@@ -149,8 +150,26 @@ class TimeseriesHandler {
149150 * @param {Integer } setID timeseries ID
150151 */
151152 public update ( setID ) {
153+ // Find the correct data entry
154+ var data = null ;
155+ this . _selectedData . forEach ( entry => {
156+ if ( data === null && entry [ "id" ] === + setID ) {
157+ data = entry ;
158+ }
159+ } ) ;
160+ if ( data == null ) return ;
161+
162+ // Update table
152163 this . updateTable ( setID ) ;
153- this . updateChart ( setID ) ;
164+
165+ // Update chart if values list is not String
166+ let chartContainer = document . getElementById ( "time-series-chart-container" ) ;
167+ if ( data [ "valuesClass" ] !== "String" ) {
168+ this . updateChart ( setID ) ;
169+ chartContainer . style . display = "block" ;
170+ } else {
171+ chartContainer . style . display = "none" ;
172+ }
154173 }
155174
156175 /**
@@ -217,7 +236,8 @@ class TimeseriesHandler {
217236 var dependents = [ ] ;
218237
219238 for ( var i = 0 ; i < independents . length ; i ++ ) {
220- if ( data [ "timeClass" ] === "dateTime" ) {
239+
240+ if ( data [ "timeClass" ] === "dateTime" || data [ "timeClass" ] === "Instant" ) {
221241 // @ts -ignore
222242 independents [ i ] = moment ( independents [ i ] , "YYYY-MM-DD HH:mm:ss" ) ;
223243
@@ -273,7 +293,7 @@ class TimeseriesHandler {
273293 } ,
274294 title : {
275295 display : true ,
276- text : "Time" ,
296+ text : "Date/ Time" ,
277297 font : {
278298 weight : 700 ,
279299 size : 12
0 commit comments