Skip to content

Commit

Permalink
Changed view property to show as line plot, fixed an issue with toolt…
Browse files Browse the repository at this point in the history
…ips and showing variants
  • Loading branch information
cohansen committed Dec 5, 2023
1 parent 82dc9ae commit 3132520
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/components/timeline/LayerLine.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
export let mouseout: MouseEvent | undefined;
export let pointRadius: number = 2;
export let resources: Resource[] = [];
export let showStateLineChart: boolean = false;
export let showAsLinePlot: boolean = false;
export let viewTimeRange: TimeRange = { end: 0, start: 0 };
export let xScaleView: ScaleTime<number, number> | null = null;
export let yAxes: Axis[] = [];
Expand Down Expand Up @@ -52,7 +52,7 @@
typeof lineWidth === 'number' &&
typeof pointRadius === 'number' &&
mounted &&
showStateLineChart !== undefined &&
showAsLinePlot !== undefined &&
points &&
viewTimeRange &&
xScaleView &&
Expand Down Expand Up @@ -96,7 +96,7 @@
ctx.lineWidth = lineWidth;
ctx.strokeStyle = fill;
if (showStateLineChart) {
if (showAsLinePlot) {
const domain = Array.from(scaleDomain);
const yScale = scalePoint()
.domain(domain.filter(filterEmpty))
Expand All @@ -119,6 +119,7 @@
const x = (xScaleView as ScaleTime<number, number, never>)(point.x);
const y = yScale(point.y.toString()) as number;
quadtree.add({ id, x, y });
visiblePointsById[id] = point;
const circle = new Path2D();
circle.arc(x, y, radius, 0, 2 * Math.PI);
Expand Down Expand Up @@ -216,7 +217,7 @@
y,
});
}
} else if (schema.type === 'string') {
} else if (schema.type === 'string' || schema.type === 'variant') {
for (let i = 0; i < values.length; ++i) {
const value = values[i];
const { x } = value;
Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline/Row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
/>
{/if}
{#if isXRangeLayer(layer)}
{#if layer.showStateLineChart === true}
{#if layer.showAsLinePlot === true}
<LayerLine
{...layer}
{contextmenu}
Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline/RowYAxes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* The correct way to do this would be generating a Y axes when the user toggles the line chart,
* but for now we're just setting the Y axes dynamically based on the data.
*/
if (layer.showStateLineChart && resources && resources.length > 0) {
if (layer.showAsLinePlot && resources && resources.length > 0) {
let domain: string[] = [];
// Get all the unique ordinal values of the chart.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@
/>
</Input>
<Input layout="inline">
<label for="showStateLineChart">Show State Changes</label>
<label for="showAsLinePlot">Show As Line Plot</label>
<input
style:width="max-content"
checked={layerAsXRange.showStateLineChart}
id="showStateLineChart"
name="showStateLineChart"
checked={layerAsXRange.showAsLinePlot}
id="showAsLinePlot"
name="showAsLinePlot"
on:change={onInput}
type="checkbox"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/ui-view-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@
"opacity": {
"type": "number"
},
"showStateLineChart": {
"showAsLinePlot": {
"type": "boolean"
},
"yAxisId": {
Expand Down
2 changes: 1 addition & 1 deletion src/types/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export type XRangeLayerColorScheme =
export interface XRangeLayer extends Layer {
colorScheme: XRangeLayerColorScheme;
opacity: number;
showStateLineChart: boolean;
showAsLinePlot: boolean;
}

export interface XRangePoint extends Point {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ export function createTimelineXRangeLayer(
id,
name: '',
opacity: 0.8,
showStateLineChart: false,
showAsLinePlot: false,
yAxisId,
...args,
};
Expand Down

0 comments on commit 3132520

Please sign in to comment.