Skip to content

Commit

Permalink
fix: circular flipped bar
Browse files Browse the repository at this point in the history
  • Loading branch information
etowahadams committed Feb 20, 2024
1 parent 1301cbb commit 072e6e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/core/mark/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export function drawBar(track: any, tile: Tile, model: GoslingTrackModel) {
(isFlippedY && y - rowHeight >= 0) ||
(!isFlippedY && y <= 0)
) {
console.warn('inside', model.specOriginal.id);
return;
}

Expand All @@ -108,11 +107,14 @@ export function drawBar(track: any, tile: Tile, model: GoslingTrackModel) {
);

let polygonForMouseEvents: number[] = [];

const barHeight = isFlippedY ? rowHeight - y : y;

if (circular) {
const farR = trackOuterRadius - ((rowHeight - prevYEnd) / trackHeight) * trackRingSize;
const nearR = trackOuterRadius - ((rowHeight - y - prevYEnd) / trackHeight) * trackRingSize;
const ys = isFlippedY ? prevYEnd : rowHeight - prevYEnd;
const farR = trackOuterRadius - (ys / trackHeight) * trackRingSize;
const ye = isFlippedY ? barHeight + prevYEnd : rowHeight - y - prevYEnd;
const nearR = trackOuterRadius - (ye / trackHeight) * trackRingSize;

const sPos = cartesianToPolar(xs, trackWidth, nearR, cx, cy, startAngle, endAngle);
const startRad = valueToRadian(xs, trackWidth, startAngle, endAngle);
Expand All @@ -134,7 +136,6 @@ export function drawBar(track: any, tile: Tile, model: GoslingTrackModel) {

/* Mouse Events */
model.getMouseEventModel().addPolygonBasedEvent(d, polygonForMouseEvents);

prevYEnd += barHeight;
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/gosling-track/gosling-track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ const factory: PluginTrackFactory<Tile, GoslingTrackOptions> = (HGC, context, op

// Replace width and height information with the actual values for responsive encoding
const [trackWidth, trackHeight] = this.dimensions; // actual size of a track
const axisSize = IsXAxis(resolvedSpec) ? HIGLASS_AXIS_SIZE : 0; // Why the axis size must be added here?
const axisSize = IsXAxis(resolvedSpec) && this.options.spec.layout === 'linear' ? HIGLASS_AXIS_SIZE : 0; // Why the axis size must be added here?
const [w, h] = [trackWidth, trackHeight + axisSize];
const circularFactor = Math.min(w, h) / Math.min(resolvedSpec.width!, resolvedSpec.height!);
if (resolvedSpec.innerRadius) {
Expand Down

0 comments on commit 072e6e6

Please sign in to comment.