charts-core 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts-core.js +198 -128
- package/dist/charts-core.js.map +1 -1
- package/dist/charts-core.umd.cjs +67 -1
- package/dist/charts-core.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/scope-logo-dark.svg +0 -33
- package/dist/scope-logo-light.svg +0 -33
package/dist/charts-core.js
CHANGED
|
@@ -1,44 +1,114 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
const
|
|
3
|
-
const { svg: e, config:
|
|
4
|
-
if (!
|
|
5
|
-
e.append("g").attr("transform", `translate(${l - o.right},0)`).call((
|
|
6
|
-
let
|
|
7
|
-
r ? (a && (
|
|
8
|
-
const
|
|
9
|
-
return `${
|
|
10
|
-
}),
|
|
11
|
-
}).call((
|
|
12
|
-
},
|
|
13
|
-
const { svg: e, config:
|
|
1
|
+
import * as g from "d3";
|
|
2
|
+
const F = (t) => {
|
|
3
|
+
const { svg: e, config: i, y: n } = t, { width: l, margin: o, yAxis: s } = i, { customTicks: r, tickFormat: a, tickValues: d, ticks: c, isShow: f } = s;
|
|
4
|
+
if (!f) return null;
|
|
5
|
+
e.append("g").attr("transform", `translate(${l - o.right},0)`).call((p) => {
|
|
6
|
+
let C = g.axisRight(n);
|
|
7
|
+
r ? (a && (C = C.tickFormat(a)), c && (C = Array.isArray(c) ? C.ticks(...c) : C.ticks(c)), d && (C = C.tickValues(d))) : C = C.tickFormat((u) => {
|
|
8
|
+
const h = Number(u), v = h < 0 ? "-" : "", y = g.format(".0s")(Math.abs(h));
|
|
9
|
+
return `${v}${y}`;
|
|
10
|
+
}), p.call(C);
|
|
11
|
+
}).call((p) => p.select(".domain").remove()).call((p) => p.selectAll("text").attr("fill", "var(--sc-color-axis-text)")).call((p) => p.selectAll(".tick line").remove());
|
|
12
|
+
}, M = (t) => {
|
|
13
|
+
const { svg: e, config: i, x: n } = t, { height: l, margin: o, xAxis: s } = i, { isShow: r } = s;
|
|
14
14
|
if (!r) return null;
|
|
15
|
-
e.append("g").attr("transform", `translate(0,${l - o.bottom})`).call(
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
e.append("g").attr("transform", `translate(0,${l - o.bottom})`).call(g.axisBottom(n).ticks(5)).call((a) => a.select(".domain").remove()).call((a) => a.selectAll(".tick line").remove()).call((a) => a.selectAll("text").attr("fill", "var(--sc-color-axis-text)"));
|
|
16
|
+
}, G = `<svg width="406" height="50" viewBox="0 0 406 113" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
17
|
+
<path d="M192.818 23.0378C168.597 23.0378 151.856 36.6984 151.856 56.6851C151.856 76.6718 168.597 90.5572 192.818 90.5572C217.038 90.5572 233.39 76.6645 233.39 56.6561C233.39 36.6476 216.906 23.0378 192.818 23.0378ZM192.818 78.2243C176.839 78.2243 165.642 69.4316 165.642 56.5618C165.642 43.6919 176.817 35.4071 192.818 35.4071C208.818 35.4071 219.612 43.9459 219.612 56.5618C219.612 69.1777 208.4 78.2025 192.818 78.2025V78.2315V78.2243Z" fill="url(#paint0_linear_825_50654)"/>
|
|
18
|
+
<path d="M47.275 50.6822H25.511C12.6272 50.6822 9.15141 35.3893 35.9457 35.3893C47.2823 35.3893 56.1697 40.2354 60.0341 42.7746L66.993 32.3278C60.4155 26.5893 48.8295 23.02 35.821 23.02C-7.20087 23.02 -7.7215 62.783 25.643 62.783H47.5389C61.706 62.783 64.0232 78.2065 35.9457 78.2065C21.9033 78.2065 10.8233 70.8139 6.95889 68.0064L0 78.4604C6.57758 84.1916 20.4807 90.5612 36.063 90.5612C81.1455 90.5322 81.6661 50.6749 47.275 50.6749V50.6822Z" fill="url(#paint1_linear_825_50654)"/>
|
|
19
|
+
<path d="M117.971 78.1952C101.487 78.1952 90.7959 69.4026 90.7959 56.7867C90.7959 44.1708 101.355 35.3998 117.839 35.3998C127.248 35.3998 136.003 40.246 141.283 45.0848L149.173 34.2536C141.701 28.3991 130.232 23.0378 117.869 23.0378C93.1351 23.0378 77.0394 36.8072 77.0394 56.8157C77.0394 76.8241 93.3771 90.5572 118.125 90.5572C130.745 90.5572 142.214 84.9494 149.679 79.0876L141.569 68.503C136.267 73.3709 127.504 78.1952 117.971 78.1952Z" fill="url(#paint2_linear_825_50654)"/>
|
|
20
|
+
<path d="M366.96 23.0273C343.774 23.0273 327.671 36.7967 327.671 56.8051C327.671 76.8136 346.091 90.5467 371.213 90.5467C384.479 90.5467 395.537 86.2156 402.51 80.3538L394.385 69.7983C389.619 74.8983 381.897 78.591 371.074 78.591C355.998 78.591 345.255 72.3519 342.146 62.7902H406.001V56.6673C405.979 36.6588 390.14 23.02 366.953 23.02L366.96 23.0273ZM366.828 35.0048C380.101 35.0048 389.179 41.193 391.569 51.0594H341.889C344.353 41.2801 353.343 35.0048 366.828 35.0048Z" fill="url(#paint3_linear_825_50654)"/>
|
|
21
|
+
<path d="M284.304 23.0273C272.777 23.0273 263.632 27.0319 257.348 33.2056C255.72 28.1128 251.225 24.9425 245.132 24.9425H236.772V37.0506H244.494V113H258.023V80.9052C264.27 86.7597 273.143 90.5684 284.318 90.5684C305.826 90.5684 320.638 76.6757 320.638 56.6673C320.638 36.6588 305.804 23.02 284.296 23.02L284.304 23.0273ZM282.625 78.1847C267.937 78.1847 258.023 69.392 258.023 56.5222C258.023 43.6524 267.937 35.3675 282.625 35.3675C297.312 35.3675 306.845 43.9063 306.845 56.5222C306.83 69.421 296.667 78.1847 282.625 78.1847Z" fill="url(#paint4_linear_825_50654)"/>
|
|
22
|
+
<path d="M362.631 5.86774H364.279C365.579 5.86774 366.453 5.10272 366.453 3.99282C366.453 2.88292 365.674 2.18688 364.26 2.18688C362.942 2.18688 362.067 2.95817 361.991 4.13704H359.374C359.475 1.64761 361.44 0.0297852 364.387 0.0297852C367.334 0.0297852 369.141 1.46576 369.141 3.61658C369.141 5.26576 368 6.45717 366.333 6.75816V6.8146C368.361 6.98391 369.667 8.19414 369.667 10.0565C369.667 12.4707 367.455 14.076 364.317 14.076C361.18 14.076 359.241 12.408 359.107 9.9311H361.827C361.909 11.0661 362.853 11.8123 364.349 11.8123C365.845 11.8123 366.77 11.0222 366.77 9.88094C366.77 8.65189 365.839 7.90569 364.305 7.90569H362.625V5.87401L362.631 5.86774Z" fill="#141718"/>
|
|
23
|
+
<path d="M372.393 11.5986C371.638 10.4636 371.252 8.93982 371.252 7.15269C371.252 2.70055 373.438 0.0167236 376.95 0.0167236C379.542 0.0167236 381.564 1.53421 381.944 3.7352H379.149C378.877 2.8385 378.002 2.24279 376.937 2.24279C375.042 2.24279 373.895 4.04246 373.958 7.07745H374.015C374.56 5.76061 375.898 4.889 377.634 4.889C380.214 4.889 382.128 6.77018 382.128 9.32233C382.128 12.0877 379.954 14.0755 376.912 14.0755C374.96 14.0755 373.35 13.1976 372.399 11.5986H372.393ZM379.352 9.41012C379.352 8.02431 378.306 7.00847 376.886 7.00847C375.467 7.00847 374.402 8.02431 374.402 9.38504C374.402 10.7458 375.486 11.8368 376.88 11.8368C378.274 11.8368 379.358 10.7646 379.358 9.41639L379.352 9.41012Z" fill="#141718"/>
|
|
24
|
+
<path d="M383.665 7.01056C383.665 2.66502 385.763 0 389.167 0C392.57 0 394.655 2.65874 394.655 6.99802C394.655 11.3373 392.583 14.0525 389.167 14.0525C385.75 14.0525 383.665 11.3624 383.665 7.00429V7.01056ZM391.765 7.01056C391.765 3.96931 390.776 2.25743 389.167 2.25743C387.557 2.25743 386.555 3.98185 386.555 7.01056C386.555 10.0393 387.544 11.8013 389.167 11.8013C390.789 11.8013 391.765 10.0769 391.765 7.01056Z" fill="#141718"/>
|
|
25
|
+
<path d="M395.968 3.15424C395.968 1.48625 397.267 0.188232 398.959 0.188232C400.652 0.188232 401.957 1.48625 401.957 3.15424C401.957 4.82222 400.645 6.12651 398.959 6.12651C397.273 6.12651 395.968 4.82849 395.968 3.15424ZM400.322 3.15424C400.322 2.40176 399.726 1.79351 398.966 1.79351C398.205 1.79351 397.609 2.40176 397.609 3.15424C397.609 3.90671 398.23 4.52123 398.966 4.52123C399.739 4.52123 400.322 3.8879 400.322 3.15424Z" fill="#141718"/>
|
|
26
|
+
<defs>
|
|
27
|
+
<linearGradient id="paint0_linear_825_50654" x1="195.535" y1="92.2815" x2="195.535" y2="24.1985" gradientUnits="userSpaceOnUse">
|
|
28
|
+
<stop stop-color="#181C1D" stop-opacity="0.2"/>
|
|
29
|
+
<stop offset="1" stop-color="#141718"/>
|
|
30
|
+
</linearGradient>
|
|
31
|
+
<linearGradient id="paint1_linear_825_50654" x1="38.3756" y1="92.2861" x2="38.3756" y2="24.1811" gradientUnits="userSpaceOnUse">
|
|
32
|
+
<stop stop-color="#181C1D" stop-opacity="0.2"/>
|
|
33
|
+
<stop offset="1" stop-color="#141718"/>
|
|
34
|
+
</linearGradient>
|
|
35
|
+
<linearGradient id="paint2_linear_825_50654" x1="115.953" y1="92.2815" x2="115.953" y2="24.1985" gradientUnits="userSpaceOnUse">
|
|
36
|
+
<stop stop-color="#181C1D" stop-opacity="0.2"/>
|
|
37
|
+
<stop offset="1" stop-color="#141718"/>
|
|
38
|
+
</linearGradient>
|
|
39
|
+
<linearGradient id="paint3_linear_825_50654" x1="369.633" y1="92.2712" x2="369.633" y2="24.1808" gradientUnits="userSpaceOnUse">
|
|
40
|
+
<stop stop-color="#181C1D" stop-opacity="0.2"/>
|
|
41
|
+
<stop offset="1" stop-color="#141718"/>
|
|
42
|
+
</linearGradient>
|
|
43
|
+
<linearGradient id="paint4_linear_825_50654" x1="281.7" y1="115.298" x2="281.7" y2="24.5668" gradientUnits="userSpaceOnUse">
|
|
44
|
+
<stop stop-color="#181C1D" stop-opacity="0.2"/>
|
|
45
|
+
<stop offset="1" stop-color="#141718"/>
|
|
46
|
+
</linearGradient>
|
|
47
|
+
</defs>
|
|
48
|
+
</svg>
|
|
49
|
+
`, H = `<svg width="406" height="50" viewBox="0 0 406 113" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
50
|
+
<path d="M192.818 23.0378C168.597 23.0378 151.856 36.6984 151.856 56.685C151.856 76.6717 168.597 90.5572 192.818 90.5572C217.038 90.5572 233.391 76.6645 233.391 56.656C233.391 36.6476 216.906 23.0378 192.818 23.0378ZM192.818 78.2242C176.839 78.2242 165.642 69.4315 165.642 56.5617C165.642 43.6919 176.817 35.407 192.818 35.407C208.818 35.407 219.612 43.9458 219.612 56.5617C219.612 69.1776 208.4 78.2025 192.818 78.2025V78.2315V78.2242Z" fill="url(#paint0_linear_825_29332)"/>
|
|
51
|
+
<path d="M47.275 50.6821H25.511C12.6272 50.6821 9.15141 35.3892 35.9457 35.3892C47.2823 35.3892 56.1697 40.2354 60.0341 42.7745L66.993 32.3278C60.4155 26.5893 48.8295 23.02 35.821 23.02C-7.20087 23.02 -7.7215 62.783 25.643 62.783H47.5389C61.706 62.783 64.0232 78.2064 35.9457 78.2064C21.9033 78.2064 10.8233 70.8139 6.95889 68.0063L0 78.4604C6.57758 84.1916 20.4807 90.5612 36.063 90.5612C81.1455 90.5322 81.6661 50.6749 47.275 50.6749V50.6821Z" fill="url(#paint1_linear_825_29332)"/>
|
|
52
|
+
<path d="M117.971 78.1952C101.487 78.1952 90.7955 69.4025 90.7955 56.7866C90.7955 44.1707 101.355 35.3998 117.839 35.3998C127.247 35.3998 136.003 40.2459 141.282 45.0848L149.172 34.2535C141.7 28.399 130.232 23.0378 117.868 23.0378C93.1347 23.0378 77.0391 36.8072 77.0391 56.8156C77.0391 76.8241 93.3767 90.5572 118.125 90.5572C130.745 90.5572 142.214 84.9493 149.678 79.0875L141.568 68.5029C136.267 73.3708 127.504 78.1952 117.971 78.1952Z" fill="url(#paint2_linear_825_29332)"/>
|
|
53
|
+
<path d="M366.96 23.0273C343.774 23.0273 327.671 36.7967 327.671 56.8051C327.671 76.8136 346.091 90.5467 371.213 90.5467C384.479 90.5467 395.537 86.2156 402.51 80.3538L394.385 69.7983C389.619 74.8983 381.897 78.591 371.074 78.591C355.998 78.591 345.255 72.3519 342.146 62.7902H406.001V56.6673C405.979 36.6588 390.14 23.02 366.953 23.02L366.96 23.0273ZM366.828 35.0048C380.101 35.0048 389.179 41.193 391.569 51.0594H341.889C344.353 41.2801 353.343 35.0048 366.828 35.0048Z" fill="url(#paint3_linear_825_29332)"/>
|
|
54
|
+
<path d="M284.304 23.0272C272.777 23.0272 263.632 27.0318 257.348 33.2056C255.72 28.1128 251.225 24.9425 245.132 24.9425H236.772V37.0506H244.494V113H258.023V80.9052C264.27 86.7597 273.143 90.5684 284.318 90.5684C305.826 90.5684 320.638 76.6757 320.638 56.6672C320.638 36.6588 305.804 23.02 284.296 23.02L284.304 23.0272ZM282.625 78.1847C267.937 78.1847 258.023 69.392 258.023 56.5222C258.023 43.6523 267.937 35.3675 282.625 35.3675C297.312 35.3675 306.845 43.9062 306.845 56.5222C306.83 69.421 296.667 78.1847 282.625 78.1847Z" fill="url(#paint4_linear_825_29332)"/>
|
|
55
|
+
<path d="M362.631 5.86768H364.279C365.579 5.86768 366.453 5.10266 366.453 3.99276C366.453 2.88286 365.674 2.18682 364.26 2.18682C362.942 2.18682 362.067 2.95811 361.991 4.13698H359.374C359.475 1.64754 361.44 0.0297241 364.387 0.0297241C367.334 0.0297241 369.141 1.4657 369.141 3.61652C369.141 5.2657 368 6.45711 366.333 6.7581V6.81454C368.361 6.98385 369.667 8.19408 369.667 10.0565C369.667 12.4706 367.455 14.0759 364.317 14.0759C361.18 14.0759 359.241 12.4079 359.107 9.93104H361.827C361.909 11.066 362.853 11.8122 364.349 11.8122C365.845 11.8122 366.77 11.0221 366.77 9.88087C366.77 8.65183 365.839 7.90563 364.305 7.90563H362.625V5.87395L362.631 5.86768Z" fill="#F8F8F8"/>
|
|
56
|
+
<path d="M372.393 11.5985C371.638 10.4635 371.252 8.93976 371.252 7.15263C371.252 2.70049 373.438 0.0166626 376.95 0.0166626C379.542 0.0166626 381.564 1.53415 381.944 3.73514H379.149C378.877 2.83844 378.002 2.24273 376.937 2.24273C375.042 2.24273 373.895 4.0424 373.958 7.07738H374.015C374.56 5.76055 375.898 4.88894 377.634 4.88894C380.214 4.88894 382.128 6.77012 382.128 9.32227C382.128 12.0876 379.954 14.0754 376.912 14.0754C374.96 14.0754 373.35 13.1975 372.399 11.5985H372.393ZM379.352 9.41006C379.352 8.02425 378.306 7.00841 376.886 7.00841C375.467 7.00841 374.402 8.02425 374.402 9.38497C374.402 10.7457 375.486 11.8368 376.88 11.8368C378.274 11.8368 379.358 10.7645 379.358 9.41633L379.352 9.41006Z" fill="#F8F8F8"/>
|
|
57
|
+
<path d="M383.665 7.0105C383.665 2.66495 385.763 -6.10352e-05 389.167 -6.10352e-05C392.57 -6.10352e-05 394.655 2.65868 394.655 6.99796C394.655 11.3372 392.583 14.0524 389.167 14.0524C385.75 14.0524 383.665 11.3623 383.665 7.00423V7.0105ZM391.765 7.0105C391.765 3.96924 390.776 2.25736 389.167 2.25736C387.557 2.25736 386.555 3.98179 386.555 7.0105C386.555 10.0392 387.544 11.8013 389.167 11.8013C390.789 11.8013 391.765 10.0768 391.765 7.0105Z" fill="#F8F8F8"/>
|
|
58
|
+
<path d="M395.968 3.15422C395.968 1.48624 397.267 0.188217 398.959 0.188217C400.652 0.188217 401.957 1.48624 401.957 3.15422C401.957 4.82221 400.645 6.1265 398.959 6.1265C397.273 6.1265 395.968 4.82848 395.968 3.15422ZM400.322 3.15422C400.322 2.40175 399.726 1.7935 398.966 1.7935C398.205 1.7935 397.609 2.40175 397.609 3.15422C397.609 3.9067 398.23 4.52122 398.966 4.52122C399.739 4.52122 400.322 3.88788 400.322 3.15422Z" fill="#F8F8F8"/>
|
|
59
|
+
<defs>
|
|
60
|
+
<linearGradient id="paint0_linear_825_29332" x1="195.535" y1="92.2815" x2="195.535" y2="24.1985" gradientUnits="userSpaceOnUse">
|
|
61
|
+
<stop stop-color="#EDEDED" stop-opacity="0.2"/>
|
|
62
|
+
<stop offset="1" stop-color="#F8F8F8"/>
|
|
63
|
+
</linearGradient>
|
|
64
|
+
<linearGradient id="paint1_linear_825_29332" x1="38.3756" y1="92.286" x2="38.3756" y2="24.181" gradientUnits="userSpaceOnUse">
|
|
65
|
+
<stop stop-color="#EDEDED" stop-opacity="0.2"/>
|
|
66
|
+
<stop offset="1" stop-color="#F8F8F8"/>
|
|
67
|
+
</linearGradient>
|
|
68
|
+
<linearGradient id="paint2_linear_825_29332" x1="115.953" y1="92.2815" x2="115.953" y2="24.1985" gradientUnits="userSpaceOnUse">
|
|
69
|
+
<stop stop-color="#EDEDED" stop-opacity="0.2"/>
|
|
70
|
+
<stop offset="1" stop-color="#F8F8F8"/>
|
|
71
|
+
</linearGradient>
|
|
72
|
+
<linearGradient id="paint3_linear_825_29332" x1="369.633" y1="92.2712" x2="369.633" y2="24.1808" gradientUnits="userSpaceOnUse">
|
|
73
|
+
<stop stop-color="#EDEDED" stop-opacity="0.2"/>
|
|
74
|
+
<stop offset="1" stop-color="#F8F8F8"/>
|
|
75
|
+
</linearGradient>
|
|
76
|
+
<linearGradient id="paint4_linear_825_29332" x1="281.7" y1="115.298" x2="281.7" y2="24.5667" gradientUnits="userSpaceOnUse">
|
|
77
|
+
<stop stop-color="#EDEDED" stop-opacity="0.2"/>
|
|
78
|
+
<stop offset="1" stop-color="#F8F8F8"/>
|
|
79
|
+
</linearGradient>
|
|
80
|
+
</defs>
|
|
81
|
+
</svg>
|
|
82
|
+
`, N = (t) => {
|
|
83
|
+
const { svg: e, config: i, y: n } = t, { width: l, height: o, margin: s, logo: r } = i;
|
|
84
|
+
if (M(t), F(t), r) {
|
|
85
|
+
const a = i.theme === "dark" ? G : H, d = (l - s.left - s.right) / 2 - r.width / 2 + s.left, c = (o - s.top - s.bottom) / 2 - r.height / 2 + s.top;
|
|
86
|
+
e.append("g").attr("transform", `translate(${d}, ${c})`).append("g").attr("width", r.width).attr("height", r.height).html(a);
|
|
87
|
+
}
|
|
88
|
+
e.append("line").attr("x1", 0 + s.left).attr("x2", l - s.right).attr("y1", n(0)).attr("y2", n(0)).attr("stroke", "var(--sc-color-axis-zero-line)").attr("stroke-dasharray", "4 4").attr("stroke-width", 1);
|
|
89
|
+
}, Z = (t, e = {}) => {
|
|
90
|
+
let i = t.append("rect").classed("sc-charts__sc-selection", !0).style("display", e.hidden ? "none" : "block");
|
|
91
|
+
const n = "sc-charts__selection";
|
|
22
92
|
return {
|
|
23
93
|
className(l, o) {
|
|
24
|
-
l === "remove" ?
|
|
94
|
+
l === "remove" ? i.classed(`${n}${o}`, !1) : i.classed(`${n}${o}`, !0);
|
|
25
95
|
},
|
|
26
96
|
update({ width: l, x: o, y: s, height: r, fill: a, hidden: d }) {
|
|
27
|
-
l !== void 0 &&
|
|
97
|
+
l !== void 0 && i.attr("width", l), o !== void 0 && i.attr("x", o), s !== void 0 && i.attr("y", s), r !== void 0 && i.attr("height", r), a !== void 0 && i.attr("fill", a), d !== void 0 && i.style("display", d ? "none" : "block");
|
|
28
98
|
},
|
|
29
99
|
destroy() {
|
|
30
|
-
|
|
100
|
+
i.remove();
|
|
31
101
|
}
|
|
32
102
|
};
|
|
33
|
-
},
|
|
34
|
-
let
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
const e =
|
|
40
|
-
return e.empty() ?
|
|
41
|
-
},
|
|
103
|
+
}, b = (t, e, i) => {
|
|
104
|
+
let n = t.select(`#${e}`);
|
|
105
|
+
return n.empty() && (n = t.append("linearGradient").attr("gradientUnits", "userSpaceOnUse").attr("id", e)), n.attr("x1", i.x1).attr("y1", i.x2).attr("x2", i.y1).attr("y2", i.y2), i.stops.forEach(({ offset: l, stopColor: o }) => {
|
|
106
|
+
n.append("stop").attr("offset", l).attr("stop-color", o);
|
|
107
|
+
}), n;
|
|
108
|
+
}, k = (t) => {
|
|
109
|
+
const e = g.select(t).select("defs");
|
|
110
|
+
return e.empty() ? g.select(t).append("defs") : e;
|
|
111
|
+
}, x = (t, e) => ({
|
|
42
112
|
...t,
|
|
43
113
|
...e,
|
|
44
114
|
margin: {
|
|
@@ -57,8 +127,8 @@ const N = (t) => {
|
|
|
57
127
|
...t.yAxis,
|
|
58
128
|
...e == null ? void 0 : e.yAxis
|
|
59
129
|
}
|
|
60
|
-
}),
|
|
61
|
-
const
|
|
130
|
+
}), L = (t, e = {}) => {
|
|
131
|
+
const i = t.node(), n = k(i), l = (r, a) => b(n, r, {
|
|
62
132
|
x1: "0%",
|
|
63
133
|
y1: "0%",
|
|
64
134
|
x2: "0%",
|
|
@@ -76,29 +146,29 @@ const N = (t) => {
|
|
|
76
146
|
className(r, a) {
|
|
77
147
|
r === "remove" ? s.classed(`${o}${a}`, !1) : s.classed(`${o}${a}`, !0);
|
|
78
148
|
},
|
|
79
|
-
update({ x1: r, x2: a, y1: d, y2: c, hidden:
|
|
80
|
-
r !== void 0 && s.attr("x1", r), a !== void 0 && s.attr("x2", a), d !== void 0 && s.attr("y1", d), c !== void 0 && s.attr("y2", c),
|
|
149
|
+
update({ x1: r, x2: a, y1: d, y2: c, hidden: f }) {
|
|
150
|
+
r !== void 0 && s.attr("x1", r), a !== void 0 && s.attr("x2", a), d !== void 0 && s.attr("y1", d), c !== void 0 && s.attr("y2", c), f !== void 0 && s.style("display", f ? "none" : "block");
|
|
81
151
|
},
|
|
82
152
|
destroy() {
|
|
83
153
|
s.remove();
|
|
84
154
|
}
|
|
85
155
|
};
|
|
86
|
-
},
|
|
87
|
-
const
|
|
88
|
-
return
|
|
156
|
+
}, _ = (t, e = {}) => {
|
|
157
|
+
const i = t.append("circle").attr("r", e.radius || 4).style("display", e.hidden ? "none" : "block"), n = e.className || "";
|
|
158
|
+
return n && i.classed(n, !0), {
|
|
89
159
|
className(l, o) {
|
|
90
|
-
l === "remove" ?
|
|
160
|
+
l === "remove" ? i.classed(`${n}${o}`, !1) : i.classed(`${n}${o}`, !0);
|
|
91
161
|
},
|
|
92
162
|
update({ cx: l, cy: o, hidden: s, fill: r }) {
|
|
93
|
-
l !== void 0 &&
|
|
163
|
+
l !== void 0 && i.attr("cx", l), o !== void 0 && i.attr("cy", o), r !== void 0 && i.attr("fill", r), s !== void 0 && i.style("display", s ? "none" : "block");
|
|
94
164
|
},
|
|
95
165
|
destroy() {
|
|
96
|
-
|
|
166
|
+
i.remove();
|
|
97
167
|
}
|
|
98
168
|
};
|
|
99
|
-
},
|
|
100
|
-
const
|
|
101
|
-
return ((r, a) =>
|
|
169
|
+
}, D = (t, e = {}) => {
|
|
170
|
+
const i = "sc-charts__hover-line", n = t.append("line").style("display", e.hidden ? "none" : "block").classed(i, !0), l = t.node(), o = k(l);
|
|
171
|
+
return ((r, a) => b(o, r, {
|
|
102
172
|
x1: "0%",
|
|
103
173
|
y1: "0%",
|
|
104
174
|
x2: "0%",
|
|
@@ -111,17 +181,17 @@ const N = (t) => {
|
|
|
111
181
|
]
|
|
112
182
|
}))("hover-line-gradient", "var(--sc-color-hover-line)"), {
|
|
113
183
|
className(r, a) {
|
|
114
|
-
r === "remove" ?
|
|
184
|
+
r === "remove" ? n.classed(`${i}${a}`, !1) : n.classed(`${i}${a}`, !0);
|
|
115
185
|
},
|
|
116
|
-
update({ x1: r, x2: a, y1: d, y2: c, hidden:
|
|
117
|
-
r !== void 0 &&
|
|
186
|
+
update({ x1: r, x2: a, y1: d, y2: c, hidden: f }) {
|
|
187
|
+
r !== void 0 && n.attr("x1", r), a !== void 0 && n.attr("x2", a), d !== void 0 && n.attr("y1", d), c !== void 0 && n.attr("y2", c), f !== void 0 && n.style("display", f ? "none" : "block");
|
|
118
188
|
},
|
|
119
189
|
destroy() {
|
|
120
|
-
|
|
190
|
+
n.remove();
|
|
121
191
|
}
|
|
122
192
|
};
|
|
123
|
-
},
|
|
124
|
-
const l =
|
|
193
|
+
}, V = ({ svg: t, x: e, y: i }, n = {}) => {
|
|
194
|
+
const l = g.line().x((r) => e(r.date)).y((r) => i(r.value)).curve(g.curveLinear), o = n.className || "sc-charts__range-line", s = t.append("path").classed(n.className || "sc-charts__range-line", !0).style("display", n.hidden ? "none" : "block");
|
|
125
195
|
return {
|
|
126
196
|
className(r, a) {
|
|
127
197
|
r === "remove" ? s.classed(`${o}${a}`, !1) : s.classed(`${o}${a}`, !0);
|
|
@@ -133,13 +203,13 @@ const N = (t) => {
|
|
|
133
203
|
s.remove();
|
|
134
204
|
}
|
|
135
205
|
};
|
|
136
|
-
},
|
|
206
|
+
}, U = ({
|
|
137
207
|
svg: t,
|
|
138
208
|
data: e,
|
|
139
|
-
x:
|
|
140
|
-
y:
|
|
209
|
+
x: i,
|
|
210
|
+
y: n
|
|
141
211
|
}) => {
|
|
142
|
-
const l =
|
|
212
|
+
const l = g.line().x((r) => i(r.date)).y((r) => n(r.value)).curve(g.curveLinear), o = "sc-charts__main-line", s = t.append("path").classed(o, !0).datum(e).attr("d", l);
|
|
143
213
|
return {
|
|
144
214
|
className(r, a) {
|
|
145
215
|
r === "remove" ? s.classed(`${o}${a}`, !1) : s.classed(`${o}${a}`, !0);
|
|
@@ -152,26 +222,26 @@ const N = (t) => {
|
|
|
152
222
|
}
|
|
153
223
|
};
|
|
154
224
|
}, S = (t) => {
|
|
155
|
-
const e = "sc-charts__range-label",
|
|
225
|
+
const e = "sc-charts__range-label", i = t.svg.append("foreignObject").classed(e, !0).style("display", "none"), n = i.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${e}-container`), l = n.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${e}-sum`), o = n.append("xhtml:div").attr("xmlns", "http://www.w3.org/1999/xhtml").attr("class", `${e}-time`), s = g.timeFormat("%b %e, %I:%M %p");
|
|
156
226
|
return {
|
|
157
227
|
className(r, a) {
|
|
158
|
-
r === "remove" ?
|
|
228
|
+
r === "remove" ? i.classed(`${e}${a}`, !1) : i.classed(`${e}${a}`, !0);
|
|
159
229
|
},
|
|
160
|
-
update({ leftPoint: r, rightPoint: a, x: d, y: c, hidden:
|
|
161
|
-
if (d !== void 0 &&
|
|
162
|
-
const
|
|
163
|
-
l.text(
|
|
164
|
-
const
|
|
165
|
-
|
|
230
|
+
update({ leftPoint: r, rightPoint: a, x: d, y: c, hidden: f }) {
|
|
231
|
+
if (d !== void 0 && i.attr("x", d), c !== void 0 && i.attr("y", c), r && a) {
|
|
232
|
+
const p = a.value - r.value, C = (p / r.value * 100).toFixed(2), u = `${p < 0 ? "-" : ""}$${Math.abs(p).toFixed(2)} (${C}%)`, h = `${s(r.date)} to ${s(a.date)}`;
|
|
233
|
+
l.text(u), o.text(h);
|
|
234
|
+
const v = t.x(t.data[t.data.length - 1].date), y = t.x(t.data[0].date), m = n.node().getBoundingClientRect();
|
|
235
|
+
m.x < y && i.attr("x", y + m.width / 2), m.x > v - m.width && i.attr("x", v - m.width / 2);
|
|
166
236
|
}
|
|
167
|
-
|
|
237
|
+
f !== void 0 && i.style("display", f ? "none" : "block");
|
|
168
238
|
},
|
|
169
239
|
destroy() {
|
|
170
|
-
|
|
240
|
+
i.remove();
|
|
171
241
|
}
|
|
172
242
|
};
|
|
173
|
-
},
|
|
174
|
-
const l =
|
|
243
|
+
}, A = ({ svg: t, x: e, y: i }, n = {}) => {
|
|
244
|
+
const l = g.line().x((r) => e(r.date)).y((r) => i(r.value)).curve(g.curveLinear), o = n.className || "sc-charts__highlight-line", s = t.append("path").classed(o, !0).style("display", n.hidden ? "none" : "block");
|
|
175
245
|
return {
|
|
176
246
|
className(r, a) {
|
|
177
247
|
r === "remove" ? s.classed(`${o}${a}`, !1) : s.classed(`${o}${a}`, !0);
|
|
@@ -183,20 +253,20 @@ const N = (t) => {
|
|
|
183
253
|
s.remove();
|
|
184
254
|
}
|
|
185
255
|
};
|
|
186
|
-
},
|
|
187
|
-
const e =
|
|
256
|
+
}, w = (t) => {
|
|
257
|
+
const e = U(t), i = Z(t.svg), n = D(t.svg), l = A(t), o = _(t.svg, {
|
|
188
258
|
className: "sc-charts__hover-circle",
|
|
189
259
|
hidden: !0
|
|
190
|
-
}), s =
|
|
260
|
+
}), s = L(t.svg), r = L(t.svg), a = V(t), d = _(t.svg, {
|
|
191
261
|
className: "sc-charts__range-circle-left",
|
|
192
262
|
hidden: !0
|
|
193
|
-
}), c =
|
|
263
|
+
}), c = _(t.svg, {
|
|
194
264
|
className: "sc-charts__range-circle-right",
|
|
195
265
|
hidden: !0
|
|
196
|
-
}),
|
|
266
|
+
}), f = S(t);
|
|
197
267
|
return {
|
|
198
|
-
selection:
|
|
199
|
-
hoverLine:
|
|
268
|
+
selection: i,
|
|
269
|
+
hoverLine: n,
|
|
200
270
|
hoverCircle: o,
|
|
201
271
|
rangeBorderLeft: s,
|
|
202
272
|
rangeBorderRight: r,
|
|
@@ -204,35 +274,35 @@ const N = (t) => {
|
|
|
204
274
|
rangeCircleLeft: d,
|
|
205
275
|
rangeCircleRight: c,
|
|
206
276
|
mainLine: e,
|
|
207
|
-
rangeLabel:
|
|
277
|
+
rangeLabel: f,
|
|
208
278
|
highlightLine: l
|
|
209
279
|
};
|
|
210
|
-
},
|
|
280
|
+
}, E = (t, e) => {
|
|
211
281
|
const {
|
|
212
|
-
x:
|
|
213
|
-
y:
|
|
282
|
+
x: i,
|
|
283
|
+
y: n,
|
|
214
284
|
data: l,
|
|
215
285
|
elements: o,
|
|
216
286
|
config: { margin: s, height: r }
|
|
217
287
|
} = t;
|
|
218
288
|
o.hoverLine.update({
|
|
219
|
-
x1:
|
|
220
|
-
x2:
|
|
289
|
+
x1: i(e.date),
|
|
290
|
+
x2: i(e.date),
|
|
221
291
|
y1: s.top,
|
|
222
292
|
y2: r - s.bottom,
|
|
223
293
|
hidden: !1
|
|
224
294
|
}), o.hoverCircle.update({
|
|
225
|
-
cx:
|
|
226
|
-
cy:
|
|
295
|
+
cx: i(e.date),
|
|
296
|
+
cy: n(e.value),
|
|
227
297
|
hidden: !1
|
|
228
298
|
}), o.highlightLine.update({
|
|
229
299
|
data: l.filter((a) => a.date.getFullYear() === e.date.getFullYear() && a.date.getMonth() === e.date.getMonth()),
|
|
230
300
|
hidden: !1
|
|
231
301
|
}), o.mainLine.className("add", "_muted");
|
|
232
|
-
},
|
|
302
|
+
}, $ = (t) => {
|
|
233
303
|
const { elements: e } = t;
|
|
234
304
|
e.hoverLine.update({ hidden: !0 }), e.hoverCircle.update({ hidden: !0 }), e.highlightLine.update({ hidden: !0 }), e.mainLine.className("remove", "_muted");
|
|
235
|
-
},
|
|
305
|
+
}, B = (t, e) => {
|
|
236
306
|
[
|
|
237
307
|
"rangeBorderLeft",
|
|
238
308
|
"rangeBorderRight",
|
|
@@ -240,67 +310,67 @@ const N = (t) => {
|
|
|
240
310
|
"rangeCircleRight",
|
|
241
311
|
"rangeLine",
|
|
242
312
|
"rangeLabel"
|
|
243
|
-
].forEach((
|
|
244
|
-
e ? (t[
|
|
313
|
+
].forEach((n) => {
|
|
314
|
+
e ? (t[n].className("remove", "_down"), t[n].className("add", "_up")) : (t[n].className("remove", "_up"), t[n].className("add", "_down"));
|
|
245
315
|
});
|
|
246
|
-
},
|
|
316
|
+
}, R = (t, e, i) => {
|
|
247
317
|
const {
|
|
248
|
-
x:
|
|
318
|
+
x: n,
|
|
249
319
|
y: l,
|
|
250
320
|
data: o,
|
|
251
321
|
config: { margin: s, height: r },
|
|
252
322
|
elements: a
|
|
253
|
-
} = t, d =
|
|
323
|
+
} = t, d = n(e.date) < n(i.date) ? e : i, c = n(e.date) >= n(i.date) ? e : i, f = c.value - d.value >= 0, p = n(d.date), C = n(c.date), u = C - p, h = o.findIndex((m) => m.date.getTime() === d.date.getTime()), v = o.findIndex((m) => m.date.getTime() === c.date.getTime()), y = o.slice(h, v + 1);
|
|
254
324
|
a.rangeBorderLeft.update({
|
|
255
|
-
x1:
|
|
256
|
-
x2:
|
|
325
|
+
x1: p,
|
|
326
|
+
x2: p,
|
|
257
327
|
y1: s.top,
|
|
258
328
|
y2: r - s.bottom,
|
|
259
329
|
hidden: !1
|
|
260
330
|
}), a.rangeBorderRight.update({
|
|
261
|
-
x1:
|
|
262
|
-
x2:
|
|
331
|
+
x1: C,
|
|
332
|
+
x2: C,
|
|
263
333
|
y1: s.top,
|
|
264
334
|
y2: r - s.bottom,
|
|
265
335
|
hidden: !1
|
|
266
336
|
}), a.rangeCircleLeft.update({
|
|
267
|
-
cx:
|
|
337
|
+
cx: p,
|
|
268
338
|
cy: l(d.value),
|
|
269
339
|
hidden: !1
|
|
270
340
|
}), a.rangeCircleRight.update({
|
|
271
|
-
cx:
|
|
341
|
+
cx: C,
|
|
272
342
|
cy: l(c.value),
|
|
273
343
|
hidden: !1
|
|
274
344
|
}), a.rangeLine.update({
|
|
275
|
-
data:
|
|
345
|
+
data: y,
|
|
276
346
|
hidden: !1
|
|
277
347
|
}), a.rangeLabel.update({
|
|
278
348
|
rightPoint: c,
|
|
279
349
|
leftPoint: d,
|
|
280
|
-
x:
|
|
350
|
+
x: p + u / 2,
|
|
281
351
|
y: s.top,
|
|
282
352
|
hidden: !1
|
|
283
|
-
}),
|
|
284
|
-
},
|
|
353
|
+
}), B(a, f), a.mainLine.className("add", "_selected-muted");
|
|
354
|
+
}, O = (t) => {
|
|
285
355
|
const { elements: e } = t;
|
|
286
356
|
e.selection.update({ hidden: !0 }), e.rangeLine.update({ hidden: !0 }), e.rangeBorderLeft.update({ hidden: !0 }), e.rangeBorderRight.update({ hidden: !0 }), e.rangeCircleLeft.update({ hidden: !0 }), e.rangeCircleRight.update({ hidden: !0 }), e.rangeLabel.update({ hidden: !0 }), e.mainLine.className("remove", "_selected-muted");
|
|
287
|
-
},
|
|
288
|
-
const { svg: e, data:
|
|
357
|
+
}, T = (t) => {
|
|
358
|
+
const { svg: e, data: i, x: n, config: l } = t, { height: o, margin: s, width: r } = l;
|
|
289
359
|
let a = null, d = !1;
|
|
290
|
-
const c = (
|
|
291
|
-
e.append("rect").attr("width", r - s.left - s.right).attr("height", o - s.top - s.bottom).attr("x", s.left).attr("y", s.top).attr("fill", "transparent").on("mousemove", function(
|
|
292
|
-
const [
|
|
293
|
-
d ?
|
|
360
|
+
const c = (p) => i.reduce((C, u) => Math.abs(n(C.date) - p) < Math.abs(n(u.date) - p) ? C : u);
|
|
361
|
+
e.append("rect").attr("width", r - s.left - s.right).attr("height", o - s.top - s.bottom).attr("x", s.left).attr("y", s.top).attr("fill", "transparent").on("mousemove", function(p) {
|
|
362
|
+
const [C] = g.pointer(p, this), u = c(C);
|
|
363
|
+
d ? $(t) : E(t, u), a && R(t, a, u);
|
|
294
364
|
}).on("mouseleave", () => {
|
|
295
|
-
|
|
296
|
-
}).on("mousedown", function(
|
|
365
|
+
$(t);
|
|
366
|
+
}).on("mousedown", function(p) {
|
|
297
367
|
d = !0;
|
|
298
|
-
const [
|
|
299
|
-
a = c(
|
|
368
|
+
const [C] = g.pointer(p, this);
|
|
369
|
+
a = c(C);
|
|
300
370
|
}).on("mouseup", () => {
|
|
301
|
-
d = !1, a = null,
|
|
371
|
+
d = !1, a = null, O(t);
|
|
302
372
|
});
|
|
303
|
-
},
|
|
373
|
+
}, I = {
|
|
304
374
|
width: 800,
|
|
305
375
|
height: 300,
|
|
306
376
|
margin: { top: 10, right: 30, bottom: 20, left: 0 },
|
|
@@ -323,32 +393,32 @@ const N = (t) => {
|
|
|
323
393
|
tickValues: null,
|
|
324
394
|
isShow: !0
|
|
325
395
|
}
|
|
326
|
-
},
|
|
327
|
-
const
|
|
328
|
-
if (
|
|
396
|
+
}, X = (t, e) => {
|
|
397
|
+
const i = g.select(t);
|
|
398
|
+
if (i.empty())
|
|
329
399
|
return console.error(`Element with selector ${t} not found!`), null;
|
|
330
|
-
const
|
|
331
|
-
let l =
|
|
400
|
+
const n = i.append("svg");
|
|
401
|
+
let l = x(I, e.config);
|
|
332
402
|
const o = (s, r = !1) => {
|
|
333
|
-
r && s.config && (l =
|
|
334
|
-
const { width: a, height: d, margin: c } = l,
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
svg:
|
|
338
|
-
data:
|
|
339
|
-
x:
|
|
340
|
-
y:
|
|
403
|
+
r && s.config && (l = x(l, s.config));
|
|
404
|
+
const { width: a, height: d, margin: c } = l, f = s.data.map((h) => ({ date: new Date(h.date), value: h.value })), p = g.scaleTime().domain(g.extent(f, (h) => h.date)).range([c.left, a - c.right]), C = g.scaleLinear().domain(g.extent(f, (h) => h.value)).range([d - c.bottom, c.top]);
|
|
405
|
+
n.attr("width", a).attr("height", d).attr("class", `sc-charts sc-charts__${l.theme}`).selectAll("*").remove();
|
|
406
|
+
const u = {
|
|
407
|
+
svg: n,
|
|
408
|
+
data: f,
|
|
409
|
+
x: p,
|
|
410
|
+
y: C,
|
|
341
411
|
config: l,
|
|
342
|
-
elements:
|
|
412
|
+
elements: w({ svg: n, data: f, x: p, y: C, config: l })
|
|
343
413
|
};
|
|
344
|
-
|
|
414
|
+
N(u), u.elements = w(u), T(u);
|
|
345
415
|
};
|
|
346
416
|
return o(e), {
|
|
347
417
|
update: (s) => o(s, !0),
|
|
348
|
-
destroy: () =>
|
|
418
|
+
destroy: () => n.remove()
|
|
349
419
|
};
|
|
350
420
|
};
|
|
351
421
|
export {
|
|
352
|
-
|
|
422
|
+
X as createLineChart
|
|
353
423
|
};
|
|
354
424
|
//# sourceMappingURL=charts-core.js.map
|