Browse Source

analyticTypes client begin

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
cfee2ff02f
  1. 74
      client/src/components/ScatterPlot.vue
  2. 11
      client/src/store/index.ts
  3. 4
      client/src/store/types.ts
  4. 21
      client/src/views/Home.vue

74
client/src/components/ScatterPlot.vue

@ -7,17 +7,85 @@
<script lang="ts">
import { defineComponent } from 'vue';
import ChartwerkScatterPod from "@chartwerk/scatter-pod";
import { ChartwerkScatterPod } from "@chartwerk/scatter-pod";
import _ from "lodash";
export default defineComponent({
name: 'ScatterPlot',
props: {},
mounted() {
// var pod = new ChartwerkScatterPod(
// document.getElementById('chart'),
// [
// {
// target: 'test1',
// datapoints: [
// [100, -50, 0],
// [200, 150, 0],
// [100, 160, 1],
// [150, 170, 1],
// [150, 180, 0],
// [150, 250, 1]
// ] as [number, number][],
// color: 'red',
// lineType: 'dashed',
// pointType: 'circle'
// },
// {
// target: 'test2',
// datapoints: [
// [200, 50, 1],
// [175, 60, 0],
// [150, 70, 1]
// ],
// color: 'purple',
// pointType: 'rectangle',
// pointSize: 5,
// yOrientation: 'right',
// }
// ],
// {
// axis: {
// x: {
// format: 'numeric',
// range: [-100, 300]
// },
// y: {
// invert: true,
// range: [-100, 250]
// },
// y1: {
// isActive: true,
// range: [0, 250]
// }
// },
// zoomEvents: {
// mouse: {
// pan: { isActive: false, orientation: 'both', keyEvent: 'main' },
// zoom: { isActive: true, keyEvent: 'shift' },
// },
// scroll: {
// pan: { isActive: false },
// zoom: { isActive: true, keyEvent: 'main' }
// }
// },
// crosshair: {
// orientation: 'both',
// color: 'gray'
// },
// labelFormat: {
// yAxis: 'y',
// xAxis: 'x'
// },
// eventsCallbacks: {
// zoomOut: () => { pod.render() }
// },
// margin: { top: 30, right: 30, bottom: 40, left: 30 },
// circleView: true,
// }
// );
},
methods: {

11
client/src/store/index.ts

@ -1,28 +1,35 @@
import { auth } from "./auth.module";
import { createStore } from 'vuex'
import { getStatusGenerator } from "@/services/analytics.service";
import { AnalyticType } from './types'
// import { notify } from "@kyvg/vue3-notification";
const SET_ANALYTICS_STATUS = 'SET_ANALYTICS_STATUS';
const SET_ANALYTICS_TYPE = 'SET_ANALYTICS_TYPE';
const _SET_STATUS_GENERATOR = '_SET_STATUS_GENERATOR';
type State = {
analyticStatus: string,
analyticType?: AnalyticType,
_statusGenerator: AsyncIterableIterator<string>
}
const store = createStore<State>({
state: {
analyticStatus: 'loading...',
analyticType: null,
_statusGenerator: null
},
mutations: {
[SET_ANALYTICS_STATUS](state, status: string) {
state.analyticStatus = status;
},
[SET_ANALYTICS_TYPE](state, atype: AnalyticType) {
state.analyticType = atype;
},
[_SET_STATUS_GENERATOR](state, generator: AsyncIterableIterator<string>) {
this._statusGenerator = generator;
}

4
client/src/store/types.ts

@ -0,0 +1,4 @@
export enum AnalyticType {
PATTERN_DETECTOR = 'pattern detector',
ANOMALY_DETECTOR = 'anomaly detector',
}

21
client/src/views/Home.vue

@ -3,15 +3,15 @@
<img alt="Vue logo" src="../assets/logo.png">
<graph ref="graph" />
<analytic-status />
<div id="controls">
<div>
<div v-if="analyticType == analyticTypes[0]">
Hold <pre>S</pre> to label patterns <br/>
Hold <pre>A</pre> to label anti patterns <br/>
Holde key <pre>D</pre> to delete patterns
<br/>
<button @click="clearAllLabeling"> clear all labeling </button>
</div>
<analytic-status />
<button @click="clearAllLabeling"> clear all labeling </button>
</div>
</div>
@ -21,11 +21,12 @@
import { defineComponent } from 'vue';
import Graph from '@/components/Graph.vue';
import AnalyticStatus from '@/components/AnlyticsStatus.vue';
import { AnalyticType } from '@/store/types';
export default defineComponent({
name: 'Home',
components: {
components: {
Graph,
AnalyticStatus
},
@ -33,6 +34,16 @@ export default defineComponent({
clearAllLabeling() {
this.$refs.graph.deleteAllSegments();
}
},
data: function () {
return {
analyticTypes: [AnalyticType.PATTERN_DETECTOR, AnalyticType.ANOMALY_DETECTOR],
}
},
computed: {
analyticType() {
return this.$store.state.analyticType;
}
}
});
</script>

Loading…
Cancel
Save