summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/monitoring/components/graph/path.vue
blob: a9b7ce586ce06567e0c8676fee34befb81972cee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<script>
export default {
  props: {
    generatedLinePath: {
      type: String,
      required: true,
    },
    generatedAreaPath: {
      type: String,
      required: true,
    },
    lineStyle: {
      type: String,
      required: false,
      default: '',
    },
    lineColor: {
      type: String,
      required: true,
    },
    areaColor: {
      type: String,
      required: true,
    },
    currentCoordinates: {
      type: Object,
      required: false,
      default: () => ({ currentX: 0, currentY: 0 }),
    },
    showDot: {
      type: Boolean,
      required: true,
    },
  },
  computed: {
    strokeDashArray() {
      if (this.lineStyle === 'dashed') return '3, 1';
      if (this.lineStyle === 'dotted') return '1, 1';
      return null;
    },
  },
};
</script>
<template>
  <g transform="translate(-5, 20)">
    <circle
      v-if="showDot"
      :cx="currentCoordinates.currentX"
      :cy="currentCoordinates.currentY"
      :fill="lineColor"
      :stroke="lineColor"
      class="circle-path"
      r="3"
    />
    <path
      :d="generatedAreaPath"
      :fill="areaColor"
      class="metric-area"
    />
    <path
      :d="generatedLinePath"
      :stroke="lineColor"
      :stroke-dasharray="strokeDashArray"
      class="metric-line"
      fill="none"
      stroke-width="1"
    />
  </g>
</template>