From 6a8e076ee78a6979c6bc279e00efe0cff4168486 Mon Sep 17 00:00:00 2001 From: Sergey Savelyev Date: Wed, 1 Jan 2025 14:28:05 -0500 Subject: [PATCH] improve numeric labeling --- frontend/src/components/GraphAxis.vue | 35 +++++++------ frontend/src/components/NumericText.vue | 65 +++++++++++++++++++++++++ frontend/src/components/SvgGraph.vue | 45 +++++++++-------- frontend/src/components/ValueLabel.vue | 12 +++-- frontend/src/graph/axis.ts | 6 --- frontend/src/graph/graph.ts | 8 ++- frontend/src/views/HomeView.vue | 10 +--- 7 files changed, 124 insertions(+), 57 deletions(-) create mode 100644 frontend/src/components/NumericText.vue diff --git a/frontend/src/components/GraphAxis.vue b/frontend/src/components/GraphAxis.vue index e9e9472..b2f6739 100644 --- a/frontend/src/components/GraphAxis.vue +++ b/frontend/src/components/GraphAxis.vue @@ -1,18 +1,19 @@ - diff --git a/frontend/src/components/NumericText.vue b/frontend/src/components/NumericText.vue new file mode 100644 index 0000000..69b92aa --- /dev/null +++ b/frontend/src/components/NumericText.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/SvgGraph.vue b/frontend/src/components/SvgGraph.vue index ab67068..f365a6e 100644 --- a/frontend/src/components/SvgGraph.vue +++ b/frontend/src/components/SvgGraph.vue @@ -8,9 +8,11 @@ const props = defineProps<{ width: number; height: number; duration?: number; - border_left_right?: number; - border_top_bottom?: number; utc?: boolean; + left_axis?: boolean; + right_axis?: boolean; + hide_time_labels?: boolean; + hide_time_ticks?: boolean; }>(); const width = computed(() => { @@ -60,8 +62,10 @@ const time_lines = [ time_lines.reverse(); const text_offset = computed(() => 5); -const border_left_right = computed(() => props.border_left_right || 0); -const border_top_bottom = computed(() => props.border_top_bottom || 0); +const border_left = computed(() => props.left_axis ? 96 : 0); +const border_right = computed(() => props.right_axis ? 80 : 0); +const border_top = computed(() => 6); +const border_bottom = computed(() => props.hide_time_labels ? 6 : 24); const max_x = now; const min_x = computed(() => max_x.value - window_duration.value); @@ -69,20 +73,20 @@ const min_x = computed(() => max_x.value - window_duration.value); const x_map = (x: number) => { const diff_x = max_x.value - min_x.value; return ( - ((width.value - 2 * border_left_right.value) * (x - min_x.value)) / + ((width.value - border_left.value - border_right.value) * (x - min_x.value)) / diff_x + - border_left_right.value + border_left.value ); }; const telemetry_lines = ref([]); provide(GRAPH_DATA, { - border_top_bottom: border_top_bottom, + border_top: border_top, min_x: min_x, max_x: now, - width: () => width.value - 2 * border_left_right.value, - height: () => height.value - 2 * border_top_bottom.value, + width: () => width.value - border_left.value - border_right.value, + height: () => height.value - border_top.value - border_bottom.value, x_map: x_map, lines: telemetry_lines, max_update_rate: 1000 / 10, @@ -112,25 +116,25 @@ const lines = computed(() => { @@ -138,12 +142,14 @@ const lines = computed(() => {