Skip to content

Commit ed6baff

Browse files
authored
Some more layout tweaks (#137)
* Implement basic zoom; TODO: fix angle in skewT * Add logarithmic zoom for skew-T diagram; TODO: T calculations should use real axis extent rather than fixes base/top pressure * Fix skew-T lines responding to original extent instead of actual; now they don't tilt anymore * Add panning effect, but it is stroboscopic and doesn't work for skewT yet * combine side-effects for both axes in a single callback * Remove animationframe * Use produce to update both scales in a single call * Don't update panstart; this fixes the jittering * Also work in log space * Make consistent for x-direction * zoom towards cursor * Add reset plot button * Thinner lines * Higher resolution plot * Round time to steps of 10 minutes * format fix
1 parent cea0f0c commit ed6baff

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

apps/class-solid/src/components/Analysis.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function TimeSeriesPlot({ analysis }: { analysis: TimeseriesAnalysis }) {
128128
e.output ? e.output[analysis.yVariable] : [],
129129
);
130130

131-
const xLim = () => getNiceAxisLimits(allX());
131+
const xLim = () => getNiceAxisLimits(allX(), 0, 600);
132132
const yLim = () => getNiceAxisLimits(allY());
133133

134134
const chartData = () =>
@@ -418,8 +418,9 @@ async function takeScreenshot(event: MouseEvent, analyse: Analysis) {
418418
return;
419419
}
420420

421-
// TODO Make screenshot bigger than the original?
422-
const scale = 1;
421+
// Make screenshot bigger than the original
422+
const scale = 10;
423+
423424
// Can not use toSvg as legend is written in HTML
424425
// generated svg document contains foreignObject with html tag
425426
// which can only be rendered using web browser, not Inkscape or PowerPoint

apps/class-solid/src/components/plots/Axes.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const AxisLeft = (props: AxisProps) => {
7979
export function getNiceAxisLimits(
8080
data: number[],
8181
extraMargin = 0,
82+
roundTo?: number, // Optional rounding step, e.g. 600 for 10 minutes
8283
): [number, number] {
8384
const max = Math.max(...data);
8485
const min = Math.min(...data);
@@ -87,7 +88,7 @@ export function getNiceAxisLimits(
8788
// Avoid NaNs on axis for constant values
8889
if (range === 0) return [min - 1, max + 1];
8990

90-
const step = 10 ** Math.floor(Math.log10(range));
91+
const step = roundTo ?? 10 ** Math.floor(Math.log10(range));
9192

9293
const niceMin = Math.floor(min / step) * step - extraMargin * step;
9394
const niceMax = Math.ceil(max / step) * step + extraMargin * step;

apps/class-solid/src/components/plots/Line.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function Line(d: ChartData<Point>) {
2727
fill="none"
2828
stroke={stroke()}
2929
stroke-dasharray={d.linestyle}
30-
stroke-width="3"
30+
stroke-width="2"
3131
d={l(d.data) || ""}
3232
class="cursor-pointer"
3333
>

apps/class-solid/src/components/plots/skewTlogP.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function Sounding(data: ChartData<SoundingRecord>) {
122122
clip-path="url(#clipper)"
123123
stroke={stroke()}
124124
stroke-dasharray={data.linestyle}
125-
stroke-width={3}
125+
stroke-width={2}
126126
fill="none"
127127
class="cursor-pointer"
128128
>
@@ -133,7 +133,7 @@ function Sounding(data: ChartData<SoundingRecord>) {
133133
clip-path="url(#clipper)"
134134
stroke={stroke()}
135135
stroke-dasharray="5,5"
136-
stroke-width={3}
136+
stroke-width={2}
137137
fill="none"
138138
class="cursor-pointer"
139139
>

0 commit comments

Comments
 (0)