Browse Source

extract to vue folder

vue-folder
glitch4347 2 months ago
parent
commit
5bea7eebd4
  1. 34
      src/index.ts
  2. 33
      vue/VueChartwerkLinePod.ts

34
src/index.ts

@ -1,4 +1,4 @@
import { ChartwerkPod, VueChartwerkPodMixin, TimeFormat, CrosshairOrientation, BrushOrientation, yAxisOrientation } from '@chartwerk/core';
import { ChartwerkPod, TimeFormat, CrosshairOrientation, BrushOrientation, yAxisOrientation } from '@chartwerk/core';
import { LineTimeSerie, LineOptions, MouseObj } from './types';
import { Markers } from './components/markers';
import { Segments } from './components/segments';
@ -447,36 +447,4 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> {
}
}
// TODO: it should be moved to VUE folder
// it is used with Vue.component, e.g.: Vue.component('chartwerk-line-pod', VueChartwerkLinePod)
export const VueChartwerkLinePod = {
// alternative to `template: '<div class="chartwerk-line-pod" :id="id" />'`
render(createElement) {
return createElement(
'div',
{
class: { 'chartwerk-line-pod': true },
attrs: { id: this.id }
}
);
},
mixins: [VueChartwerkPodMixin],
methods: {
render() {
if(this.pod === undefined) {
this.pod = new LinePod(document.getElementById(this.id), this.series, this.options);
this.pod.render();
} else {
this.pod.updateData(this.series, this.options);
}
},
renderSharedCrosshair(values) {
this.pod.renderSharedCrosshair(values);
},
hideSharedCrosshair() {
this.pod.hideSharedCrosshair();
}
}
};
export { LineTimeSerie, LineOptions, TimeFormat, LinePod };

33
vue/VueChartwerkLinePod.ts

@ -0,0 +1,33 @@
import { LinePod } from '@chartwerk/line-pod';
import { VueChartwerkPodMixin } from '@chartwerk/core';
// it is used with Vue.component, e.g.: Vue.component('chartwerk-line-pod', VueChartwerkLinePod)
export const VueChartwerkLinePod = {
// alternative to `template: '<div class="chartwerk-line-pod" :id="id" />'`
render(createElement) {
return createElement(
'div',
{
class: { 'chartwerk-line-pod': true },
attrs: { id: this.id }
}
);
},
mixins: [VueChartwerkPodMixin],
methods: {
render() {
if(this.pod === undefined) {
this.pod = new LinePod(document.getElementById(this.id), this.series, this.options);
this.pod.render();
} else {
this.pod.updateData(this.series, this.options);
}
},
renderSharedCrosshair(values) {
this.pod.renderSharedCrosshair(values);
},
hideSharedCrosshair() {
this.pod.hideSharedCrosshair();
}
}
};
Loading…
Cancel
Save