Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ci_cd_analytics_area_chart.vue « ci_cd_analytics « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b4751d51fcb293bc89fd03580a925b62ffc1f51a (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
<script>
import { v4 as uuidv4 } from 'uuid';
import { GlAreaChart } from '@gitlab/ui/dist/charts';
import { CHART_CONTAINER_HEIGHT } from './constants';

export default {
  name: 'CiCdAnalyticsAreaChart',
  components: {
    GlAreaChart,
  },
  props: {
    chartData: {
      type: Array,
      required: true,
    },
    areaChartOptions: {
      type: Object,
      required: true,
    },
  },
  data: () => ({
    chartKey: uuidv4(),
  }),
  watch: {
    chartData() {
      // Re-render area chart when the data changes
      this.chartKey = uuidv4();
    },
  },
  chartContainerHeight: CHART_CONTAINER_HEIGHT,
};
</script>
<template>
  <div class="gl-mt-3">
    <p>
      <slot></slot>
    </p>
    <gl-area-chart
      v-bind="$attrs"
      :key="chartKey"
      responsive
      width="auto"
      :height="$options.chartContainerHeight"
      :data="chartData"
      :include-legend-avg-max="false"
      :option="areaChartOptions"
    >
      <template #tooltip-title>
        <slot name="tooltip-title"></slot>
      </template>
      <template #tooltip-content>
        <slot name="tooltip-content"></slot>
      </template>
    </gl-area-chart>
  </div>
</template>