11<template >
2- <p class =" description" >{{ t('intervalChartChart.description') }}</p >
2+ <div >
3+ <p class =" description d-inline-block" >{{ t('intervalsChart.message') }}</p >
4+ <div class =" d-inline-block mr-10 ml-10" >
5+ <select class =" option" v-model =" minValue" @change =" refreshChart()" >
6+ <option :value =" MinValue.Seconds_10" >10 {{ t('sec.message') }}</option >
7+ <option :value =" MinValue.Min_1" >1 {{ t('min.message') }}</option >
8+ <option :value =" MinValue.Min_5" >5 {{ t('2min.message') }}</option >
9+ <option :value =" MinValue.Min_10" >10 {{ t('mins.message') }}</option >
10+ </select >
11+ </div >
12+ <p class =" description d-inline-block" >{{ t('intervalsChart.description') }}</p >
13+ </div >
314 <div ref =" chart" id =" timeIntervalChartD3" ></div >
415</template >
516
@@ -19,34 +30,56 @@ import { useI18n } from 'vue-i18n';
1930import * as d3 from ' d3' ;
2031import { convertStringTimeIntervalToSeconds } from ' ../utils/converter' ;
2132
33+ enum MinValue {
34+ Seconds_10 = 10 ,
35+ Min_1 = 60 ,
36+ Min_5 = 300 ,
37+ Min_10 = 600 ,
38+ }
39+
2240const { t } = useI18n ();
2341const storage = injecStorage ();
2442
2543const chart = ref <any >();
44+ const minValue = ref <number >();
45+ const todayIntervals = ref <TimeInterval []>();
2646
2747type DataForChart = {
2848 domain: string ;
2949 interval: string ;
3050};
3151
3252onMounted (async () => {
53+ minValue .value = MinValue .Seconds_10 ;
3354 const timeIntervalList = (await storage .getDeserializeList (
3455 StorageDeserializeParam .TIMEINTERVAL_LIST ,
3556 )) as TimeInterval [];
3657
37- const todayIntervals = timeIntervalList ?.filter (x => x .day == todayLocalDate ());
58+ todayIntervals .value = timeIntervalList ?.filter (x => x .day == todayLocalDate ());
59+ renderChart ();
60+ });
61+
62+ function renderChart() {
3863 const dataForChart: DataForChart [] = [];
39- todayIntervals .forEach (interval => {
64+ todayIntervals .value ?. forEach (interval => {
4065 interval .intervals .forEach (int => {
4166 const from = int .split (' -' )[0 ];
4267 const to = int .split (' -' )[1 ];
43- if (convertStringTimeIntervalToSeconds (to ) - convertStringTimeIntervalToSeconds (from ) > 5 ) {
68+ if (
69+ convertStringTimeIntervalToSeconds (to ) - convertStringTimeIntervalToSeconds (from ) >
70+ minValue .value !
71+ ) {
4472 dataForChart .push ({ domain: interval .domain , interval: convertInterval (int ) });
4573 }
4674 });
4775 });
4876 drawIntervalChart (dataForChart );
49- });
77+ }
78+
79+ function refreshChart() {
80+ chart .value .innerHTML = ' ' ;
81+ renderChart ();
82+ }
5083
5184function convertInterval(interval : string ): string {
5285 function convert(item : string []) {
0 commit comments