Skip to content

Commit

Permalink
fix: liquid position
Browse files Browse the repository at this point in the history
  • Loading branch information
paleface001 committed Mar 27, 2020
1 parent d7c606e commit 8781ba9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
11 changes: 2 additions & 9 deletions src/plots/density-heatmap/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ import { HeatmapLegendConfig } from './components/legend';
import { HeatmapBackgroundConfig } from './components/background';
import { getPlotComponents } from './components';
import * as EventParser from './event';

interface PointStyle {
lineDash?: number[];
lineWidth?: number;
opacity?: string;
fillStyle?: string;
strokeStyle?: string;
}
import { GraphicStyle } from '../../interface/config';

export interface DensityHeatmapViewConfig extends ViewConfig {
colorField: string;
Expand All @@ -28,7 +21,7 @@ export interface DensityHeatmapViewConfig extends ViewConfig {
shape?: string;
size?: number;
color?: string;
style?: PointStyle;
style?: GraphicStyle;
};
legend?: HeatmapLegendConfig;
background?: HeatmapBackgroundConfig;
Expand Down
13 changes: 11 additions & 2 deletions src/plots/gauge/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,28 @@ interface GaugeStyle {
pointerColor?: string;
}

interface GaugeStatistic {
visible?: boolean;
position?: [string, string];
size?: number;
text?: string;
color?: string;
}

export interface GaugeViewConfig extends ViewConfig {
startAngle?: number;
endAngle?: number;
min?: number;
max?: number;
value?: number;
showValue?: boolean;
/** @ignore */
format?: (...args: any[]) => string;
/** @ignore */
gaugeStyle?: GaugeStyle;
range?: number[];
/** @ignore */
styleMix?: any;
statistic?: any;
statistic?: GaugeStatistic;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/plots/liquid/geometry/shape/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ registerShape('interval', 'liquid-fill-gauge', {
}
sumX += p.x;
});
const cx = sumX / cfg.points.length;
//const cx = sumX / cfg.points.length;
const cx = 0.5;
const cp = this.parsePoint({ x: cx, y: cy });
const minP = this.parsePoint({ x: minX, y: 0.5 });
const xWidth = cp.x - minP.x;
Expand Down
12 changes: 4 additions & 8 deletions src/plots/liquid/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface LiquidLayerConfig extends LiquidViewConfig, LayerConfig {
export default class LiquidLayer<T extends LiquidLayerConfig = LiquidLayerConfig> extends ViewLayer<T> {
public static getDefaultOptions(): Partial<LiquidViewConfig> {
const cfg: Partial<LiquidViewConfig> = {
padding: [0, 0, 0, 0],
animation: {
factor: 0.4,
easing: 'easeExpOut',
Expand Down Expand Up @@ -176,16 +177,10 @@ export default class LiquidLayer<T extends LiquidLayerConfig = LiquidLayerConfig
let fontSize;
let shadowBlur;
if (content) {
let contentWidth;
if (props.width < props.height) {
contentWidth = props.width * 0.8;
} else {
contentWidth = props.height;
}
fontSize = (0.8 * contentWidth) / content.length;
const contentWidth = Math.min(this.width, this.height);
fontSize = (contentWidth / content.length) * 0.5;
shadowBlur = Math.max(1, Math.ceil(0.025 * fontSize));
}

let opacity;
if (statistic.visible === false) {
opacity = 0;
Expand All @@ -212,6 +207,7 @@ export default class LiquidLayer<T extends LiquidLayerConfig = LiquidLayerConfig
},
}
);
console.log(statisticConfig);

delete statisticConfig.visible;
delete statisticConfig.formatter;
Expand Down

0 comments on commit 8781ba9

Please # to comment.