zz-chart
Advanced tools
Comparing version 0.1.0-beta.14 to 0.1.0-beta.15
@@ -250,2 +250,5 @@ import { isBoolean, isObject, set } from 'lodash'; | ||
// ... | ||
this.chartContainer.remove(); | ||
[...this.components.values()].forEach(c => c.destroy()); | ||
this.strategyManage.getStrategy('uPlot')?.destroy(); | ||
this.unbindThemeListener(); | ||
@@ -252,0 +255,0 @@ } |
@@ -14,3 +14,2 @@ import { get, isFunction } from 'lodash'; | ||
this.option = get(opt, this.name, {}); | ||
console.log(opt); | ||
} | ||
@@ -17,0 +16,0 @@ update() { |
@@ -17,2 +17,4 @@ import { TooltipOption } from '../types/index.js'; | ||
handleTemplateString(text: string | number, formatter: string | Function): string | number; | ||
showTooltip: () => void; | ||
hideTooltip: () => void; | ||
/** | ||
@@ -19,0 +21,0 @@ * 添加事件监听 |
@@ -49,2 +49,11 @@ import { StyleSheet, css } from 'aphrodite/no-important.js'; | ||
export class Tooltip extends BaseComponent { | ||
constructor() { | ||
super(...arguments); | ||
this.showTooltip = () => { | ||
this.container.style.visibility = 'visible'; | ||
}; | ||
this.hideTooltip = () => { | ||
this.container.style.visibility = 'hidden'; | ||
}; | ||
} | ||
get name() { | ||
@@ -66,3 +75,3 @@ return 'tooltip'; | ||
overlay.className = `${generateName('tooltip')} ${css(styles.overlay)}`; | ||
document.body.append(overlay); | ||
this.ctrl.chartContainer.append(overlay); | ||
this.container = overlay; | ||
@@ -69,0 +78,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { Tooltip } from '../../components/index.js'; | ||
import { Action } from './action.js'; | ||
@@ -8,3 +9,3 @@ /** | ||
get name(): string; | ||
get component(): import("../../components/base.js").BaseComponent<unknown>; | ||
get component(): Tooltip; | ||
/** | ||
@@ -11,0 +12,0 @@ * 显示 Tooltip |
@@ -17,3 +17,3 @@ import { Action } from './action.js'; | ||
show() { | ||
this.component.container.style.visibility = 'visible'; | ||
// this.component.showTooltip() | ||
} | ||
@@ -24,5 +24,5 @@ /** | ||
hide() { | ||
this.component.container.style.visibility = 'hidden'; | ||
// this.component.hideTooltip(); | ||
} | ||
} | ||
//# sourceMappingURL=tooltip.js.map |
@@ -1,2 +0,1 @@ | ||
import UPlot from 'uplot'; | ||
import { Data, Size } from '../types/index.js'; | ||
@@ -76,16 +75,5 @@ import { ViewStrategy } from './abstract.js'; | ||
}; | ||
getPlugins(): { | ||
hooks: { | ||
init: (u: UPlot) => void; | ||
setSize: () => void; | ||
setCursor: (u: UPlot) => void; | ||
}; | ||
}[]; | ||
getTooltipPlugin(): { | ||
hooks: { | ||
init: (u: UPlot) => void; | ||
setSize: () => void; | ||
setCursor: (u: uPlot) => void; | ||
}; | ||
}; | ||
private getPlugins; | ||
private getTooltipPlugin; | ||
destroy(): void; | ||
} |
@@ -50,2 +50,7 @@ import { merge, mergeWith } from 'lodash'; | ||
], | ||
destroy: [ | ||
() => { | ||
this.ctrl.destroy(); | ||
}, | ||
], | ||
}, | ||
@@ -115,3 +120,3 @@ series, | ||
const data = option.data?.length ? option.data : this.getData(); | ||
console.log('option', option); | ||
// console.log('option', option); | ||
if (!this.uPlot) { | ||
@@ -129,3 +134,3 @@ this.uPlot = new UPlot(option, data, this.ctrl.container); | ||
.clientHeight || 0; | ||
console.log(headerH, size); | ||
// console.log(headerH, size) | ||
this.uPlot.setSize({ ...size, height: size.height - headerH }); | ||
@@ -227,2 +232,3 @@ // if (this.ctrl.getData().length) { | ||
this.ctrl.emit(ChartEvent.PLOT_MOUSEMOVE); | ||
this.ctrl.components.get('tooltip').showTooltip(); | ||
} | ||
@@ -232,2 +238,3 @@ }); | ||
this.ctrl.emit(ChartEvent.PLOT_MOUSELEAVE); | ||
this.ctrl.components.get('tooltip').hideTooltip(); | ||
}); | ||
@@ -296,3 +303,7 @@ }, | ||
} | ||
destroy() { | ||
this.components = []; | ||
this.uPlot?.destroy(); | ||
} | ||
} | ||
//# sourceMappingURL=uplot-strategy.js.map |
{ | ||
"name": "zz-chart", | ||
"version": "0.1.0-beta.14", | ||
"version": "0.1.0-beta.15", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "author": "Alauda", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
452699
11993