extract to vue folder #48

Open
glitch4347 wants to merge 4 commits from vue-folder into main
  1. 1
      build/webpack.base.conf.js
  2. 34
      src/index.ts
  3. 33
      vue/VueChartwerkLinePod.ts

1
build/webpack.base.conf.js

@ -13,6 +13,7 @@ module.exports = {
new CopyPlugin({
patterns: [
{ from: "../react", to: "react" },
{ from: "../vue", to: "vue" },
],
})
],

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 '..';
import { VueChartwerkPodMixin } from '@chartwerk/core';
// it is used with Vue.component, e.g.: Vue.component('chartwerk-line-pod', VueChartwerkLinePod)
export const ChartwerkLinePod = {
// 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