8000 Fix/gauge angle by skie1997 · Pull Request #3083 · VisActor/VChart · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix/gauge angle #3083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": " git push --set-upstream origin fix/gauge-angle",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
12 changes: 9 additions & 3 deletions packages/vchart/src/series/gauge/gauge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { Datum } from '@visactor/vgrammar-core';
import type { IStateAnimateSpec } from '../../animation/spec';
import { animationConfig, userAnimationConfig } from '../../animation/utils';
import { gaugeSeriesMark } from './constant';
import { degreeToRadian, isValid } from '@visactor/vutils';
import { clamper, degreeToRadian, isValid } from '@visactor/vutils';
import { Factory } from '../../core/factory';
import { registerProgressLikeAnimation } from '../polar/progress-like';
import type { IMark } from '../../mark/interface';
Expand Down Expand Up @@ -133,13 +133,19 @@ export class GaugeSeries<T extends IGaugeSeriesSpec = IGaugeSeriesSpec> extends
protected _getAngleValueStartWithoutMask(datum: Datum) {
const startAngle = this._getAngleValueStartWithoutPadAngle(datum);
const endAngle = this._getAngleValueEndWithoutPadAngle(datum);
return Math.min(startAngle + this._padAngle / 2, (startAngle + endAngle) / 2);
return clamper(
startAngle,
(startAngle + endAngle) / 2
)(startAngle + (endAngle > startAngle ? 1 : -1) * Math.abs(this._padAngle / 2));
}

protected _getAngleValueEndWithoutMask(datum: Datum) {
const startAngle = this._getAngleValueStartWithoutPadAngle(datum);
const endAngle = this._getAngleValueEndWithoutPadAngle(datum);
return Math.max(endAngle - this._padAngle / 2, (startAngle + endAngle) / 2);
return clamper(
endAngle,
(startAngle + endAngle) / 2
)(endAngle - (endAngle > startAngle ? 1 : -1) * Math.abs(this._padAngle / 2));
}

protected _getAngleValueStartWithoutPadAngle(datum: Datum) {
Expand Down
Loading
0