-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Draw y axis lines * Add view option for rendering horizontal y axis lines
- Loading branch information
1 parent
099ddfc
commit 996abbd
Showing
9 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
height: 24px; | ||
padding: 0px 8px 0px 4px; | ||
position: relative; | ||
z-index: 3; | ||
} | ||
.row-header-title { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<svelte:options immutable={true} /> | ||
|
||
<script lang="ts"> | ||
import { axisLeft as d3AxisLeft } from 'd3-axis'; | ||
import type { Axis } from '../../types/timeline'; | ||
import { getYScale } from '../../utilities/timeline'; | ||
export let drawHeight: number = 0; | ||
export let drawWidth: number = 0; | ||
export let yAxes: Axis[] = []; | ||
let ticks: number[] = []; | ||
$: if (drawHeight && drawWidth) { | ||
ticks = []; | ||
yAxes.forEach(axis => { | ||
if ( | ||
axis.renderTickLines && | ||
axis.scaleDomain && | ||
axis.scaleDomain.length === 2 && | ||
typeof axis.scaleDomain[0] === 'number' && | ||
typeof axis.scaleDomain[1] === 'number' | ||
) { | ||
const scale = getYScale(axis.scaleDomain, drawHeight); | ||
const axisLeft = d3AxisLeft(scale).ticks(5); | ||
// D3 typings do not correctly reflect the presence of the "ticks()" function | ||
const tickValues = (axisLeft.scale() as any).ticks() as number[]; | ||
const tickValues2 = tickValues.map(tick => scale(tick)); | ||
ticks.push(...tickValues2); | ||
} | ||
}); | ||
} | ||
</script> | ||
|
||
<g class="row-y-axis-ticks"> | ||
{#each ticks as tick} | ||
<g class="tick" opacity="1" transform="translate(0 {tick})"> | ||
<line stroke="rgba(241, 242, 243, 1)" x2={drawWidth} /> | ||
</g> | ||
{/each} | ||
</g> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,7 @@ | |
pointer-events: none; | ||
position: absolute; | ||
width: 100%; | ||
z-index: 2; | ||
} | ||
.timeline-cursor-header { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters