diff --git a/components/SvgLine.svelte b/components/SvgLine.svelte index 4173317..3efdcba 100644 --- a/components/SvgLine.svelte +++ b/components/SvgLine.svelte @@ -7,10 +7,30 @@ export let data; export let x = default_x; export let y = default_y; + export let plotGaps = false - $: d = 'M' + data - .map((d, i) => `${$x_scale(x(d, i))},${$y_scale(y(d, i))}`) - .join('L'); + let d + + $: if (plotGaps) { + d = 'M' + data + .filter((d, i) => y(d, i) != null) + .map((d, i) => `${$x_scale(x(d, i))},${$y_scale(y(d, i))}`) + .join('L') + } + else { + d = data + .map((d, i) => { + let motion = 'L' + if (y(d) == null) { + return + } + if (i == 0 || y(data[i - 1]) == null) { + motion = 'M' + } + return `${motion}${$x_scale(x(d, i))},${$y_scale(y(d, i))}` + }) + .join('') + } - \ No newline at end of file + diff --git a/package.json b/package.json index fd40b54..d4f4fc7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { - "name": "@sveltejs/pancake", - "version": "0.0.14", + "name": "pancake-with-nulls", + "version": "0.0.15", "description": "Experimental charting library for Svelte", + "private": false, "module": "index.mjs", "svelte": "index.mjs", "files": [ @@ -13,9 +14,12 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, + "publishConfig": { + "registry": "https://registry.npmjs.com/" + }, "repository": { "type": "git", - "url": "git+ssh://git@github.com/Rich-Harris/pancake.git" + "url": "git+git@github.com:briancray/pancake.git" }, "keywords": [ "svelte", @@ -30,6 +34,6 @@ }, "homepage": "https://github.com/Rich-Harris/pancake#readme", "dependencies": { - "yootils": "0.0.16" + "yootils": "0.0.17" } }