Skip to content

ACV Line Chart

Displays values in a line

Basic usage

Data is loading...
Source code
vue
<script>
  import networkOneData from '../__data__/data.mock.network.one.json';
  import AcvLineChart from '@/widgets/line-chart/lineChart.vue';

  export default {
    components: { AcvLineChart },
    data() {
      return {
        networkOneData
      };
    },
    methods: {
      onTimelineClick(date, event) {
        console.log('timeline clicked');
        console.log(date);
        console.log(event);
      },
      onLegendClick(index, event) {
        console.log('legend clicked');
        console.log(index);
        console.log(event);
      }
    }
  };
</script>

<template>
  <div class="qa-line-chart-basic">
    <AcvLineChart
      :data="networkOneData"
      tooltip-time-format="dd MMM yyy, HH:MM"
      @timeline-click="onTimelineClick"
      @legend-click="onLegendClick"
    />
  </div>
</template>

Anomalies

CPU historical data
Data is loading...
Source code
vue
<script>
  import anomaliesData from '../__data__/data.mock.anomalies.json';
  import AcvButton from '@/components/button/button.vue';
  import AcvDropdown from '@/components/dropdown/dropdown.vue';
  import AcvDropdownItem from '@/components/dropdown/dropdownItem.vue';
  import AcvDropdownMenu from '@/components/dropdown/dropdownMenu.vue';
  import AcvLineChart from '@/widgets/line-chart/lineChart.vue';
  import AcvWidgetWrapper from '@/widgets/widget-wrapper/widgetWrapper.vue';

  export default {
    components: {
      AcvWidgetWrapper,
      AcvButton,
      AcvDropdown,
      AcvDropdownMenu,
      AcvDropdownItem,
      AcvLineChart
    },
    data() {
      return {
        selectedTimeUnit: 'day',
        timeUnitOptions: [
          {
            value: 'hour',
            label: 'per hour'
          },
          {
            value: 'day',
            label: 'per day'
          },
          {
            value: 'month',
            label: 'per month'
          },
          {
            value: 'year',
            label: 'per year'
          }
        ],
        data: {
          data: [
            {
              name: 'CPU',
              points: anomaliesData.points.map(point => ({
                ...point,
                x: new Date(point.x)
              }))
            }
          ]
        }
      };
    },
    methods: {
      handleChangeData() {
        if (!this.isChangedData) {
          this.dataTwo.sets[0].points = this.alterPoints;
        }
        else {
          this.dataTwo.sets[0].points = this.origPoints;
        }
        console.log(this.dataTwo.sets[0].points);
        this.isChangedData = !this.isChangedData;
      },
      handleDropdownChange(_, instance) {
        const index = instance.$parent.$children.findIndex(
          $children => $children._uid === instance._uid
        );
        this.selectedTimeUnit = this.timeUnitOptions[index].value;
      },
      onClose() {
        console.log('Alert is closed');
      }
    }
  };
</script>

<template>
  <AcvWidgetWrapper
    title="CPU historical data"
    :style="{ width: '700px' }"
  >
    <template #header-aside>
      <AcvDropdown
        placement="bottom-start"
        @command="handleDropdownChange"
      >
        <AcvButton
          type="ghost"
          right-icon
          icon="i-chevron-down--16"
        >
          {{ selectedTimeUnitLabel }}
        </AcvButton>
        <template #dropdown>
          <AcvDropdownMenu>
            <AcvDropdownItem
              v-for="option in timeUnitOptions"
              :key="option.value"
            >
              {{ option.label }}
            </AcvDropdownItem>
          </AcvDropdownMenu>
        </template>
      </AcvDropdown>
    </template>
    <AcvLineChart
      :data="data"
      :time-unit="selectedTimeUnit"
      variable-threshold
    />
  </AcvWidgetWrapper>
</template>

Corner Cases

Chart update data

Data is loading...
with percent scale

Float values

Props

Prop nameDescriptionTypeValuesDefault
colorsarray-
dataobject-null
dataPointOnHoverboolean-false
heightstring-'200px'
legendboolean-true
precisionnumber-0
steppedboolean-false
timeUnitstringsecond, minute, hour, day, month, year'hour'
tooltipboolean-true
tooltipTimeFormatstring-'dd MMM yyyy hh:mm:ss'
variableThresholdboolean-false
widthstring-''
xAxisboolean-true
xGridboolean-true
yAxisboolean-true
yAxisTicksUpperLimitnumber-5
yGridboolean-true
yPercentboolean-false
showDataTypeUnitboolean-false

Events

Event namePropertiesDescription
timelineClick<anonymous1> undefined - undefined

Slots

NameDescriptionBindings
legend
tooltipbody

MIT Licensed