tidy up some examples

pull/2179/head
Richard Harris 7 years ago
parent 53653c1c7c
commit ccbd22d936

@ -9,9 +9,6 @@
let width = 500;
let height = 200;
let barWidth;
let xScale;
let yScale;
function formatMobile(tick) {
return "'" + tick % 100;
@ -25,10 +22,8 @@
.domain([0, Math.max.apply(null, yTicks)])
.range([height - padding.bottom, padding.top]);
$: {
const innerWidth = width - (padding.left + padding.right);
barWidth = innerWidth / xTicks.length;
}
$: innerWidth = width - (padding.left + padding.right);
$: barWidth = innerWidth / xTicks.length;
</script>
<style>

@ -2,8 +2,7 @@
let paused = true;
let t = 0;
let d;
let icon, bg;
let bg;
$: icon = `https://icon.now.sh/${paused ? 'play' : 'pause'}_circle_filled`;

@ -11,13 +11,6 @@
let width = 500;
let height = 200;
let xScale;
let yScale;
let minX;
let maxX;
let path;
let area;
$: xScale = scaleLinear()
.domain([minX, maxX])
.range([padding.left, width - padding.right]);

@ -4,31 +4,30 @@
export let points;
let svg;
let width = 500;
let height = 200;
const padding = { top: 20, right: 40, bottom: 40, left: 25 };
let xScale;
$: xScale = scaleLinear()
.domain([0, 20])
.range([padding.left, width - padding.right]);
let yScale;
$: yScale = scaleLinear()
.domain([0, 12])
.range([height - padding.bottom, padding.top]);
let width = 500;
let height = 200;
let xTicks;
$: xTicks = width > 180 ?
[0, 4, 8, 12, 16, 20] :
[0, 10, 20];
let yTicks;
$: yTicks = height > 180 ?
[0, 2, 4, 6, 8, 10, 12] :
[0, 4, 8, 12];
onMount(resize);
let svg;
function resize() {
({ width, height } = svg.getBoundingClientRect());
}

@ -2,15 +2,12 @@
import { onMount } from 'svelte';
let time = new Date();
let hours, minutes, seconds;
$: {
// this block runs reactively, whenever
// `time` changes
hours = time.getHours();
minutes = time.getMinutes();
seconds = time.getSeconds();
}
// these automatically update when `time`
// changes, because of the `$:` prefix
$: hours = time.getHours();
$: minutes = time.getMinutes();
$: seconds = time.getSeconds();
onMount(() => {
const interval = setInterval(() => {

Loading…
Cancel
Save