diff --git a/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html b/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html index e37a26f..f095bea 100644 --- a/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html +++ b/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html @@ -1262,6 +1262,8 @@ callbacks: { label: function(context) { var label = context.dataset.label || ''; + let h_field = context.parsed.y + let q_field = context.parsed.x // get toggle state of toggle_detailed_tooltip var toggle_detailed_tooltip = document.getElementById("toggle_detailed_tooltip").checked @@ -1270,7 +1272,7 @@ label = []; if (toggle_detailed_tooltip == true) { for (var idx in fielddatacsv.stage) { - if (fielddatacsv.stage[idx] == context.parsed.y && fielddatacsv.discharge[idx] == context.parsed.x) { + if (fielddatacsv.stage[idx] == h_field && fielddatacsv.discharge[idx] == q_field) { // find discharge from rating curve for this stage let q_model = null @@ -1281,18 +1283,18 @@ for (var j in residualData[seg].data){ if (residualData[seg].data[j][0] == fielddatacsv.stage[idx]){ q_model = residualData[seg].data[j][1] - h_model = calc_h_model(context.parsed.x, rcParam[seg - 1].const, rcParam[seg - 1].exp, rcParam[seg - 1].offset) - r_percent = calc_residual_percent(context.parsed.y, context.parsed.x, rcParam[seg - 1].const, rcParam[seg - 1].exp, rcParam[seg - 1].offset) - r_volumetric = r_percent/100 * context.parsed.x + h_model = calc_h_model(q_field, rcParam[seg - 1].const, rcParam[seg - 1].exp, rcParam[seg - 1].offset) + r_percent = calc_residual_percent(h_field, q_field, rcParam[seg - 1].const, rcParam[seg - 1].exp, rcParam[seg - 1].offset) + r_volumetric = r_percent/100 * q_field } } } - label.push(['H: ' + context.parsed.y.toFixed(2) + ' m']); - label.push(['Q: ' + context.parsed.x.toFixed(2) + ' m³/s']); + label.push(['H: ' + h_field.toFixed(2) + ' m']); + label.push(['Q: ' + q_field.toFixed(2) + ' m³/s']); label.push(['date: ' + fielddatacsv.datetime[idx]]); if (h_model !== null) { - label.push(['H shift: ' + (h_model - context.parsed.y).toFixed(2) + ' m']) - label.push(['H shift: ' + (h_model - context.parsed.y).toFixed(2) + ' m']) + label.push(['H shift: ' + (h_model - h_field).toFixed(2) + ' m']) + label.push(['H shift: ' + (h_model - h_field).toFixed(2) + ' m']) } //if (q_model !== null){ // label.push(['Q model: ' + q_model.toFixed(2) + ' m³/s']); @@ -1310,8 +1312,8 @@ } } } else { - if (context.parsed.y !== null) { - label.push(['stage: ' + context.parsed.y.toFixed(2) + ' m, discharge: ' + context.parsed.x.toFixed(2) + ' m³/s']); + if (h_field !== null) { + label.push(['stage: ' + h_field.toFixed(2) + ' m, discharge: ' + q_field.toFixed(2) + ' m³/s']); } } } @@ -1506,11 +1508,11 @@ for (var idx in fielddatacsv.stage) { if (fielddatacsv.stage[idx] == h_field && fielddatacsv.discharge[idx] == q_field_rounded) { - label.push(['H: ' + context.parsed.y.toFixed(2) + ' m']); - label.push(['Q: ' + context.parsed.x.toFixed(2) + ' m³/s']); + label.push(['H: ' + h_field.toFixed(2) + ' m']); + label.push(['Q: ' + q_field.toFixed(2) + ' m³/s']); label.push(['date: ' + fielddatacsv.datetime[idx]]); if (h_model !== null) { - label.push(['H shift: ' + (h_model - context.parsed.y).toFixed(2) + ' m']) + label.push(['H shift: ' + (h_model - h_field).toFixed(2) + ' m']) } //if (q_model !== null){ // label.push(['Q model: ' + q_model.toFixed(2) + ' m³/s']);