zz-chart
Advanced tools
Comparing version 0.1.0-beta.20 to 0.1.0-beta.21
@@ -7,2 +7,3 @@ /// <reference types="react" resolution-mode="require"/> | ||
import { Legend } from '../components/legend.js'; | ||
import { Scale } from '../components/scale.js'; | ||
import { Shape, ShapeCtor } from '../components/shape/index.js'; | ||
@@ -103,3 +104,7 @@ import Interaction from '../interaction/interaction.js'; | ||
*/ | ||
scale(field: string, axisOption: ScaleOption): View; | ||
scale(field: string, axisOption: ScaleOption): Scale; | ||
setScale(field: 'x' | 'y', limits: { | ||
min?: number; | ||
max?: number; | ||
}): void; | ||
/** | ||
@@ -106,0 +111,0 @@ * 创建坐标系 |
@@ -190,4 +190,9 @@ import { isBoolean, isObject, set } from 'lodash'; | ||
} | ||
return this; | ||
const scale = this.components.get('scale'); | ||
return scale; | ||
} | ||
setScale(field, limits) { | ||
const scale = this.components.get('scale'); | ||
scale.setScale(field, limits); | ||
} | ||
/** | ||
@@ -194,0 +199,0 @@ * 创建坐标系 |
@@ -5,2 +5,3 @@ import { ScaleOption } from '../types/index.js'; | ||
name: string; | ||
private get strategy(); | ||
render(): void; | ||
@@ -29,4 +30,8 @@ update(): void; | ||
}; | ||
setScale(field: 'x' | 'y', limits: { | ||
min?: number; | ||
max?: number; | ||
}): void; | ||
private getXOptions; | ||
private getYOptions; | ||
} |
@@ -8,2 +8,5 @@ import { get, isNumber } from 'lodash'; | ||
} | ||
get strategy() { | ||
return this.ctrl.strategyManage.getStrategy('uPlot'); | ||
} | ||
render() { | ||
@@ -25,2 +28,8 @@ // .. | ||
} | ||
setScale(field, limits) { | ||
const iUPlot = this.strategy.getUPlotChart(); | ||
const scale = iUPlot.scales[field]; | ||
this.ctrl.setOption([this.name, field], limits); | ||
iUPlot.setScale(field, { min: limits.min || scale.min, max: limits.max || scale.max }); | ||
} | ||
getXOptions() { | ||
@@ -41,3 +50,5 @@ const { max, min } = (this.option.x || {}); | ||
range: (_u, dataMin, dataMax) => { | ||
const minV = min ? Math.max(dataMin, min || 0) : Math.min(dataMin, min || 0); | ||
const minV = min | ||
? Math.max(dataMin, min || 0) | ||
: Math.min(dataMin, min || 0); | ||
return [minV, Math.max(dataMax, max || 0)]; | ||
@@ -44,0 +55,0 @@ }, |
@@ -1,2 +0,1 @@ | ||
/// <reference types="web" /> | ||
import { View } from '../../chart/view.js'; | ||
@@ -3,0 +2,0 @@ import { ShapeOptions } from '../../types/index.js'; |
@@ -0,1 +1,2 @@ | ||
import UPlot from 'uplot'; | ||
import { Data, Size } from '../types/index.js'; | ||
@@ -9,3 +10,3 @@ import { ViewStrategy } from './abstract.js'; | ||
export declare class UPlotViewStrategy extends ViewStrategy { | ||
shapes: ("area" | "line" | "bar" | "point")[]; | ||
shapes: ("line" | "area" | "bar" | "point")[]; | ||
qt: Quadtree; | ||
@@ -76,2 +77,3 @@ get name(): string; | ||
}; | ||
getUPlotChart(): UPlot; | ||
private getPlugins; | ||
@@ -78,0 +80,0 @@ private getTooltipPlugin; |
@@ -224,2 +224,5 @@ import { merge, mergeWith } from 'lodash'; | ||
} | ||
getUPlotChart() { | ||
return this.uPlot; | ||
} | ||
getPlugins() { | ||
@@ -240,3 +243,3 @@ return [this.getTooltipPlugin()]; | ||
over.addEventListener('click', e => { | ||
const { left, top, } = u.cursor; | ||
const { left, top } = u.cursor; | ||
this.ctrl.emit(ChartEvent.PLOT_CLICK, { | ||
@@ -243,0 +246,0 @@ e, |
@@ -9,2 +9,2 @@ import { ValueOf } from '../index.js'; | ||
export declare type ShapeType = ValueOf<typeof ShapeType>; | ||
export declare const SHAPE_TYPES: ("area" | "line" | "bar" | "point")[]; | ||
export declare const SHAPE_TYPES: ("line" | "area" | "bar" | "point")[]; |
{ | ||
"name": "zz-chart", | ||
"version": "0.1.0-beta.20", | ||
"version": "0.1.0-beta.21", | ||
"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
487930
12806