diff --git a/src/components/widgets/Plotter.vue b/src/components/widgets/Plotter.vue index 9b6164be5..10348728c 100644 --- a/src/components/widgets/Plotter.vue +++ b/src/components/widgets/Plotter.vue @@ -84,8 +84,19 @@ -
Data Points
+
Data Points
+ { // Set initial widget options if they don't exist - if (Object.keys(widget.value.options).length === 0) { - widget.value.options = { - backgroundColor: 'rgba(0, 0, 0, 0.7)', - lineColor: 'rgba(255, 0, 0, 1.0)', - dataLakeVariableId: undefined, - maxSamples: 1000, - limitSamples: true, - lineThickness: 1, - } + const defaultOptions = { + backgroundColor: 'rgba(0, 0, 0, 0.7)', + lineColor: 'rgba(255, 0, 0, 1.0)', + dataLakeVariableId: undefined, + maxSamples: 1000, + limitSamples: true, + lineThickness: 1, + decimalPlaces: 2, } + widget.value.options = { ...defaultOptions, ...widget.value.options } }) onMounted(() => { @@ -289,9 +300,10 @@ const renderCanvas = (): void => { ctx.textBaseline = 'bottom' // Draw the values - drawText(ctx, `Current: ${Number(currentValue).toFixed(2)}`, 10, canvasHeight - 10) - drawText(ctx, `Min: ${Number(minValue).toFixed(2)}`, 10, canvasHeight - 30) - drawText(ctx, `Max: ${Number(maxValue).toFixed(2)}`, 10, canvasHeight - 50) + const decimalPlaces = widget.value.options.decimalPlaces + drawText(ctx, `Current: ${Number(currentValue).toFixed(decimalPlaces)}`, 10, canvasHeight - 10) + drawText(ctx, `Min: ${Number(minValue).toFixed(decimalPlaces)}`, 10, canvasHeight - 30) + drawText(ctx, `Max: ${Number(maxValue).toFixed(decimalPlaces)}`, 10, canvasHeight - 50) } catch (error) { console.error('Error drawing graph:', error) }