@krizaka/charts 0.0.0-stage → 0.2.0
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/LICENSE +202 -0
- package/README.md +59 -2
- package/dist/bar.d.ts +17 -0
- package/dist/bar.js +17 -0
- package/dist/bar.js.map +1 -0
- package/dist/candlestick-IG626XL4.js +13 -0
- package/dist/candlestick-IG626XL4.js.map +1 -0
- package/dist/candlestick.d.ts +42 -0
- package/dist/candlestick.js +13 -0
- package/dist/candlestick.js.map +1 -0
- package/dist/canvas-4MSYDVFO.js +14 -0
- package/dist/canvas-4MSYDVFO.js.map +1 -0
- package/dist/cartesian-BRhNQ3ib.d.ts +34 -0
- package/dist/chart.d.ts +58 -0
- package/dist/chart.js +11 -0
- package/dist/chart.js.map +1 -0
- package/dist/chunk-3CJHBJXA.js +186 -0
- package/dist/chunk-3CJHBJXA.js.map +1 -0
- package/dist/chunk-4LBXEAGC.js +133 -0
- package/dist/chunk-4LBXEAGC.js.map +1 -0
- package/dist/chunk-6FINSUOS.js +49 -0
- package/dist/chunk-6FINSUOS.js.map +1 -0
- package/dist/chunk-AA5EWWYV.js +38 -0
- package/dist/chunk-AA5EWWYV.js.map +1 -0
- package/dist/chunk-ANUCSRUN.js +43 -0
- package/dist/chunk-ANUCSRUN.js.map +1 -0
- package/dist/chunk-ARARFMNE.js +88 -0
- package/dist/chunk-ARARFMNE.js.map +1 -0
- package/dist/chunk-BISL7DYW.js +66 -0
- package/dist/chunk-BISL7DYW.js.map +1 -0
- package/dist/chunk-BV4DBGN7.js +178 -0
- package/dist/chunk-BV4DBGN7.js.map +1 -0
- package/dist/chunk-C4MFZLJM.js +19 -0
- package/dist/chunk-C4MFZLJM.js.map +1 -0
- package/dist/chunk-CSSZLFLO.js +116 -0
- package/dist/chunk-CSSZLFLO.js.map +1 -0
- package/dist/chunk-CVWSMUUB.js +378 -0
- package/dist/chunk-CVWSMUUB.js.map +1 -0
- package/dist/chunk-E5DKBSWX.js +2 -0
- package/dist/chunk-E5DKBSWX.js.map +1 -0
- package/dist/chunk-EEP7PS2L.js +54 -0
- package/dist/chunk-EEP7PS2L.js.map +1 -0
- package/dist/chunk-EQLC2QVN.js +73 -0
- package/dist/chunk-EQLC2QVN.js.map +1 -0
- package/dist/chunk-FINOPIDN.js +2 -0
- package/dist/chunk-FINOPIDN.js.map +1 -0
- package/dist/chunk-G2KF2WL4.js +2 -0
- package/dist/chunk-G2KF2WL4.js.map +1 -0
- package/dist/chunk-I3D7KUGN.js +205 -0
- package/dist/chunk-I3D7KUGN.js.map +1 -0
- package/dist/chunk-IKQV3NSL.js +76 -0
- package/dist/chunk-IKQV3NSL.js.map +1 -0
- package/dist/chunk-JTKR7ZWP.js +468 -0
- package/dist/chunk-JTKR7ZWP.js.map +1 -0
- package/dist/chunk-KNDHO67X.js +78 -0
- package/dist/chunk-KNDHO67X.js.map +1 -0
- package/dist/chunk-L2EKYWVI.js +94 -0
- package/dist/chunk-L2EKYWVI.js.map +1 -0
- package/dist/chunk-MXLITIGU.js +92 -0
- package/dist/chunk-MXLITIGU.js.map +1 -0
- package/dist/chunk-NCIQMRV3.js +155 -0
- package/dist/chunk-NCIQMRV3.js.map +1 -0
- package/dist/chunk-OB5EFDDH.js +118 -0
- package/dist/chunk-OB5EFDDH.js.map +1 -0
- package/dist/chunk-OIRHLJBC.js +83 -0
- package/dist/chunk-OIRHLJBC.js.map +1 -0
- package/dist/chunk-PBQV3B6O.js +145 -0
- package/dist/chunk-PBQV3B6O.js.map +1 -0
- package/dist/chunk-POQIHFAZ.js +2 -0
- package/dist/chunk-POQIHFAZ.js.map +1 -0
- package/dist/chunk-PWMMXRMC.js +234 -0
- package/dist/chunk-PWMMXRMC.js.map +1 -0
- package/dist/chunk-SLEJDQ3A.js +81 -0
- package/dist/chunk-SLEJDQ3A.js.map +1 -0
- package/dist/chunk-TPJDOB7R.js +15 -0
- package/dist/chunk-TPJDOB7R.js.map +1 -0
- package/dist/chunk-VKZZY2QD.js +103 -0
- package/dist/chunk-VKZZY2QD.js.map +1 -0
- package/dist/chunk-W5FX4TU3.js +102 -0
- package/dist/chunk-W5FX4TU3.js.map +1 -0
- package/dist/chunk-W5ILLSPK.js +107 -0
- package/dist/chunk-W5ILLSPK.js.map +1 -0
- package/dist/chunk-WBHFVBSK.js +25 -0
- package/dist/chunk-WBHFVBSK.js.map +1 -0
- package/dist/chunk-WNUFGMS7.js +113 -0
- package/dist/chunk-WNUFGMS7.js.map +1 -0
- package/dist/chunk-WVTIKOII.js +15 -0
- package/dist/chunk-WVTIKOII.js.map +1 -0
- package/dist/chunk-XDDALY4C.js +166 -0
- package/dist/chunk-XDDALY4C.js.map +1 -0
- package/dist/chunk-XLLYNNC6.js +89 -0
- package/dist/chunk-XLLYNNC6.js.map +1 -0
- package/dist/context-BgYUymEO.d.ts +163 -0
- package/dist/credits.d.ts +42 -0
- package/dist/credits.js +21 -0
- package/dist/credits.js.map +1 -0
- package/dist/earnings.d.ts +29 -0
- package/dist/earnings.js +22 -0
- package/dist/earnings.js.map +1 -0
- package/dist/frame-I7_xYGy5.d.ts +45 -0
- package/dist/full-S2MBPEEP.js +11 -0
- package/dist/full-S2MBPEEP.js.map +1 -0
- package/dist/funnel-QU5ZPC52.js +13 -0
- package/dist/funnel-QU5ZPC52.js.map +1 -0
- package/dist/funnel.d.ts +26 -0
- package/dist/funnel.js +13 -0
- package/dist/funnel.js.map +1 -0
- package/dist/gauge.d.ts +38 -0
- package/dist/gauge.js +13 -0
- package/dist/gauge.js.map +1 -0
- package/dist/geo.d.ts +37 -0
- package/dist/geo.js +13 -0
- package/dist/geo.js.map +1 -0
- package/dist/globe.d.ts +36 -0
- package/dist/globe.js +12 -0
- package/dist/globe.js.map +1 -0
- package/dist/goal.d.ts +26 -0
- package/dist/goal.js +17 -0
- package/dist/goal.js.map +1 -0
- package/dist/heatmap-JWQOKUGM.js +13 -0
- package/dist/heatmap-JWQOKUGM.js.map +1 -0
- package/dist/heatmap.d.ts +47 -0
- package/dist/heatmap.js +15 -0
- package/dist/heatmap.js.map +1 -0
- package/dist/host-_F8RgiIz.d.ts +15 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -0
- package/dist/labels-DE_743fQ.d.ts +72 -0
- package/dist/latency.d.ts +33 -0
- package/dist/latency.js +24 -0
- package/dist/latency.js.map +1 -0
- package/dist/line.d.ts +25 -0
- package/dist/line.js +19 -0
- package/dist/line.js.map +1 -0
- package/dist/native.d.ts +494 -0
- package/dist/native.js +1244 -0
- package/dist/native.js.map +1 -0
- package/dist/pie.d.ts +37 -0
- package/dist/pie.js +16 -0
- package/dist/pie.js.map +1 -0
- package/dist/provider.d.ts +73 -0
- package/dist/provider.js +24 -0
- package/dist/provider.js.map +1 -0
- package/dist/radar-75GRJ2IK.js +13 -0
- package/dist/radar-75GRJ2IK.js.map +1 -0
- package/dist/radar.d.ts +22 -0
- package/dist/radar.js +13 -0
- package/dist/radar.js.map +1 -0
- package/dist/sankey-XQTX2EG6.js +13 -0
- package/dist/sankey-XQTX2EG6.js.map +1 -0
- package/dist/sankey.d.ts +28 -0
- package/dist/sankey.js +13 -0
- package/dist/sankey.js.map +1 -0
- package/dist/scatter-XSNG4OKD.js +13 -0
- package/dist/scatter-XSNG4OKD.js.map +1 -0
- package/dist/scatter.d.ts +41 -0
- package/dist/scatter.js +15 -0
- package/dist/scatter.js.map +1 -0
- package/dist/sparkline.d.ts +26 -0
- package/dist/sparkline.js +16 -0
- package/dist/sparkline.js.map +1 -0
- package/dist/svg-BJUHYX3B.js +14 -0
- package/dist/svg-BJUHYX3B.js.map +1 -0
- package/dist/throughput.d.ts +37 -0
- package/dist/throughput.js +24 -0
- package/dist/throughput.js.map +1 -0
- package/dist/ticker.d.ts +38 -0
- package/dist/ticker.js +22 -0
- package/dist/ticker.js.map +1 -0
- package/dist/treemap-OMGGGB5U.js +13 -0
- package/dist/treemap-OMGGGB5U.js.map +1 -0
- package/dist/treemap.d.ts +24 -0
- package/dist/treemap.js +14 -0
- package/dist/treemap.js.map +1 -0
- package/dist/world-110m-DVFWXS42.js +18 -0
- package/dist/world-110m-DVFWXS42.js.map +1 -0
- package/package.json +614 -3
- package/registry/area-chart.json +785 -0
- package/registry/bar-chart.json +784 -0
- package/registry/calendar-heatmap.json +460 -0
- package/registry/candlestick.json +553 -0
- package/registry/chart.json +441 -0
- package/registry/charts-provider.json +191 -0
- package/registry/credit-usage.json +473 -0
- package/registry/earnings-chart.json +703 -0
- package/registry/examples/area-chart/credits-usage.d.ts +4 -0
- package/registry/examples/area-chart/credits-usage.js +38 -0
- package/registry/examples/area-chart/credits-usage.tsx +32 -0
- package/registry/examples/area-chart/native/credits-usage.d.ts +4 -0
- package/registry/examples/area-chart/native/credits-usage.dark.png +0 -0
- package/registry/examples/area-chart/native/credits-usage.js +33 -0
- package/registry/examples/area-chart/native/credits-usage.light.png +0 -0
- package/registry/examples/area-chart/native/credits-usage.tsx +27 -0
- package/registry/examples/area-chart/storage.d.ts +4 -0
- package/registry/examples/area-chart/storage.js +27 -0
- package/registry/examples/area-chart/storage.tsx +21 -0
- package/registry/examples/bar-chart/jobs-by-status.d.ts +4 -0
- package/registry/examples/bar-chart/jobs-by-status.js +37 -0
- package/registry/examples/bar-chart/jobs-by-status.tsx +31 -0
- package/registry/examples/bar-chart/native/jobs-by-status.d.ts +4 -0
- package/registry/examples/bar-chart/native/jobs-by-status.dark.png +0 -0
- package/registry/examples/bar-chart/native/jobs-by-status.js +32 -0
- package/registry/examples/bar-chart/native/jobs-by-status.light.png +0 -0
- package/registry/examples/bar-chart/native/jobs-by-status.tsx +26 -0
- package/registry/examples/bar-chart/plans-by-quarter.d.ts +4 -0
- package/registry/examples/bar-chart/plans-by-quarter.js +31 -0
- package/registry/examples/bar-chart/plans-by-quarter.tsx +26 -0
- package/registry/examples/bar-chart/top-supporters.d.ts +4 -0
- package/registry/examples/bar-chart/top-supporters.js +32 -0
- package/registry/examples/bar-chart/top-supporters.tsx +27 -0
- package/registry/examples/calendar-heatmap/publishing.d.ts +4 -0
- package/registry/examples/calendar-heatmap/publishing.js +28 -0
- package/registry/examples/calendar-heatmap/publishing.tsx +23 -0
- package/registry/examples/candlestick/auction-bids.d.ts +4 -0
- package/registry/examples/candlestick/auction-bids.js +37 -0
- package/registry/examples/candlestick/auction-bids.tsx +32 -0
- package/registry/examples/chart/polar-uploads.d.ts +4 -0
- package/registry/examples/chart/polar-uploads.js +34 -0
- package/registry/examples/chart/polar-uploads.tsx +30 -0
- package/registry/examples/charts-provider/french-orazaka.d.ts +4 -0
- package/registry/examples/charts-provider/french-orazaka.js +26 -0
- package/registry/examples/charts-provider/french-orazaka.tsx +22 -0
- package/registry/examples/charts-provider/native/french-orazaka.d.ts +4 -0
- package/registry/examples/charts-provider/native/french-orazaka.dark.png +0 -0
- package/registry/examples/charts-provider/native/french-orazaka.js +17 -0
- package/registry/examples/charts-provider/native/french-orazaka.light.png +0 -0
- package/registry/examples/charts-provider/native/french-orazaka.tsx +17 -0
- package/registry/examples/credit-usage/monthly-credits.d.ts +4 -0
- package/registry/examples/credit-usage/monthly-credits.js +24 -0
- package/registry/examples/credit-usage/monthly-credits.tsx +19 -0
- package/registry/examples/credit-usage/native/monthly-credits.d.ts +4 -0
- package/registry/examples/credit-usage/native/monthly-credits.dark.png +0 -0
- package/registry/examples/credit-usage/native/monthly-credits.js +23 -0
- package/registry/examples/credit-usage/native/monthly-credits.light.png +0 -0
- package/registry/examples/credit-usage/native/monthly-credits.tsx +18 -0
- package/registry/examples/credit-usage/storage-plan.d.ts +4 -0
- package/registry/examples/credit-usage/storage-plan.js +21 -0
- package/registry/examples/credit-usage/storage-plan.tsx +15 -0
- package/registry/examples/earnings-chart/creator-month.d.ts +4 -0
- package/registry/examples/earnings-chart/creator-month.js +29 -0
- package/registry/examples/earnings-chart/creator-month.tsx +24 -0
- package/registry/examples/earnings-chart/gross-and-net.d.ts +4 -0
- package/registry/examples/earnings-chart/gross-and-net.js +29 -0
- package/registry/examples/earnings-chart/gross-and-net.tsx +24 -0
- package/registry/examples/earnings-chart/native/creator-month.d.ts +4 -0
- package/registry/examples/earnings-chart/native/creator-month.dark.png +0 -0
- package/registry/examples/earnings-chart/native/creator-month.js +29 -0
- package/registry/examples/earnings-chart/native/creator-month.light.png +0 -0
- package/registry/examples/earnings-chart/native/creator-month.tsx +24 -0
- package/registry/examples/funnel/signup.d.ts +4 -0
- package/registry/examples/funnel/signup.js +30 -0
- package/registry/examples/funnel/signup.tsx +24 -0
- package/registry/examples/gauge/challenge-goal.d.ts +4 -0
- package/registry/examples/gauge/challenge-goal.js +24 -0
- package/registry/examples/gauge/challenge-goal.tsx +18 -0
- package/registry/examples/gauge/credits-quota.d.ts +4 -0
- package/registry/examples/gauge/credits-quota.js +26 -0
- package/registry/examples/gauge/credits-quota.tsx +19 -0
- package/registry/examples/gauge/native/credits-quota.d.ts +4 -0
- package/registry/examples/gauge/native/credits-quota.dark.png +0 -0
- package/registry/examples/gauge/native/credits-quota.js +25 -0
- package/registry/examples/gauge/native/credits-quota.light.png +0 -0
- package/registry/examples/gauge/native/credits-quota.tsx +18 -0
- package/registry/examples/geo-map/viewers.d.ts +4 -0
- package/registry/examples/geo-map/viewers.js +43 -0
- package/registry/examples/geo-map/viewers.tsx +29 -0
- package/registry/examples/globe/deployment-regions.d.ts +4 -0
- package/registry/examples/globe/deployment-regions.js +36 -0
- package/registry/examples/globe/deployment-regions.tsx +30 -0
- package/registry/examples/goal-progress/challenge-pot.d.ts +4 -0
- package/registry/examples/goal-progress/challenge-pot.js +22 -0
- package/registry/examples/goal-progress/challenge-pot.tsx +16 -0
- package/registry/examples/goal-progress/goal-reached.d.ts +4 -0
- package/registry/examples/goal-progress/goal-reached.js +11 -0
- package/registry/examples/goal-progress/goal-reached.tsx +6 -0
- package/registry/examples/goal-progress/native/challenge-pot.d.ts +4 -0
- package/registry/examples/goal-progress/native/challenge-pot.dark.png +0 -0
- package/registry/examples/goal-progress/native/challenge-pot.js +11 -0
- package/registry/examples/goal-progress/native/challenge-pot.light.png +0 -0
- package/registry/examples/goal-progress/native/challenge-pot.tsx +6 -0
- package/registry/examples/heatmap/upload-activity.d.ts +4 -0
- package/registry/examples/heatmap/upload-activity.js +30 -0
- package/registry/examples/heatmap/upload-activity.tsx +25 -0
- package/registry/examples/job-throughput/live-hours.d.ts +4 -0
- package/registry/examples/job-throughput/live-hours.js +33 -0
- package/registry/examples/job-throughput/live-hours.tsx +28 -0
- package/registry/examples/job-throughput/native/week-of-jobs.d.ts +4 -0
- package/registry/examples/job-throughput/native/week-of-jobs.dark.png +0 -0
- package/registry/examples/job-throughput/native/week-of-jobs.js +20 -0
- package/registry/examples/job-throughput/native/week-of-jobs.light.png +0 -0
- package/registry/examples/job-throughput/native/week-of-jobs.tsx +16 -0
- package/registry/examples/job-throughput/week-of-jobs.d.ts +4 -0
- package/registry/examples/job-throughput/week-of-jobs.js +20 -0
- package/registry/examples/job-throughput/week-of-jobs.tsx +16 -0
- package/registry/examples/latency-chart/by-capability.d.ts +4 -0
- package/registry/examples/latency-chart/by-capability.js +26 -0
- package/registry/examples/latency-chart/by-capability.tsx +21 -0
- package/registry/examples/latency-chart/native/by-capability.d.ts +4 -0
- package/registry/examples/latency-chart/native/by-capability.dark.png +0 -0
- package/registry/examples/latency-chart/native/by-capability.js +17 -0
- package/registry/examples/latency-chart/native/by-capability.light.png +0 -0
- package/registry/examples/latency-chart/native/by-capability.tsx +13 -0
- package/registry/examples/latency-chart/time-to-result.d.ts +4 -0
- package/registry/examples/latency-chart/time-to-result.js +27 -0
- package/registry/examples/latency-chart/time-to-result.tsx +22 -0
- package/registry/examples/line-chart/creator-earnings.d.ts +4 -0
- package/registry/examples/line-chart/creator-earnings.js +35 -0
- package/registry/examples/line-chart/creator-earnings.tsx +30 -0
- package/registry/examples/line-chart/forecast.d.ts +4 -0
- package/registry/examples/line-chart/forecast.js +36 -0
- package/registry/examples/line-chart/forecast.tsx +30 -0
- package/registry/examples/line-chart/live-jobs.d.ts +4 -0
- package/registry/examples/line-chart/live-jobs.js +21 -0
- package/registry/examples/line-chart/live-jobs.tsx +23 -0
- package/registry/examples/line-chart/native/creator-earnings.d.ts +4 -0
- package/registry/examples/line-chart/native/creator-earnings.dark.png +0 -0
- package/registry/examples/line-chart/native/creator-earnings.js +32 -0
- package/registry/examples/line-chart/native/creator-earnings.light.png +0 -0
- package/registry/examples/line-chart/native/creator-earnings.tsx +26 -0
- package/registry/examples/line-chart/states.d.ts +4 -0
- package/registry/examples/line-chart/states.js +16 -0
- package/registry/examples/line-chart/states.tsx +13 -0
- package/registry/examples/pie-chart/credit-spend.d.ts +4 -0
- package/registry/examples/pie-chart/credit-spend.js +30 -0
- package/registry/examples/pie-chart/credit-spend.tsx +24 -0
- package/registry/examples/pie-chart/native/credit-spend.d.ts +4 -0
- package/registry/examples/pie-chart/native/credit-spend.dark.png +0 -0
- package/registry/examples/pie-chart/native/credit-spend.js +17 -0
- package/registry/examples/pie-chart/native/credit-spend.light.png +0 -0
- package/registry/examples/pie-chart/native/credit-spend.tsx +12 -0
- package/registry/examples/pie-chart/storage-by-kind.d.ts +4 -0
- package/registry/examples/pie-chart/storage-by-kind.js +31 -0
- package/registry/examples/pie-chart/storage-by-kind.tsx +26 -0
- package/registry/examples/price-ticker/auction-room.d.ts +4 -0
- package/registry/examples/price-ticker/auction-room.js +21 -0
- package/registry/examples/price-ticker/auction-room.tsx +17 -0
- package/registry/examples/price-ticker/native/auction-room.d.ts +4 -0
- package/registry/examples/price-ticker/native/auction-room.dark.png +0 -0
- package/registry/examples/price-ticker/native/auction-room.js +19 -0
- package/registry/examples/price-ticker/native/auction-room.light.png +0 -0
- package/registry/examples/price-ticker/native/auction-room.tsx +15 -0
- package/registry/examples/price-ticker/no-bid-yet.d.ts +4 -0
- package/registry/examples/price-ticker/no-bid-yet.js +11 -0
- package/registry/examples/price-ticker/no-bid-yet.tsx +6 -0
- package/registry/examples/radar-chart/model-comparison.d.ts +4 -0
- package/registry/examples/radar-chart/model-comparison.js +33 -0
- package/registry/examples/radar-chart/model-comparison.tsx +28 -0
- package/registry/examples/sankey/credit-flow.d.ts +4 -0
- package/registry/examples/sankey/credit-flow.js +37 -0
- package/registry/examples/sankey/credit-flow.tsx +32 -0
- package/registry/examples/scatter-chart/watch-time.d.ts +4 -0
- package/registry/examples/scatter-chart/watch-time.js +36 -0
- package/registry/examples/scatter-chart/watch-time.tsx +31 -0
- package/registry/examples/sparkline/bars.d.ts +4 -0
- package/registry/examples/sparkline/bars.js +12 -0
- package/registry/examples/sparkline/bars.tsx +7 -0
- package/registry/examples/sparkline/native/stat-trend.d.ts +4 -0
- package/registry/examples/sparkline/native/stat-trend.dark.png +0 -0
- package/registry/examples/sparkline/native/stat-trend.js +12 -0
- package/registry/examples/sparkline/native/stat-trend.light.png +0 -0
- package/registry/examples/sparkline/native/stat-trend.tsx +7 -0
- package/registry/examples/sparkline/stat-trend.d.ts +4 -0
- package/registry/examples/sparkline/stat-trend.js +18 -0
- package/registry/examples/sparkline/stat-trend.tsx +15 -0
- package/registry/examples/sparkline/table-rows.d.ts +4 -0
- package/registry/examples/sparkline/table-rows.js +23 -0
- package/registry/examples/sparkline/table-rows.tsx +26 -0
- package/registry/examples/treemap/storage.d.ts +4 -0
- package/registry/examples/treemap/storage.js +17 -0
- package/registry/examples/treemap/storage.tsx +13 -0
- package/registry/funnel.json +487 -0
- package/registry/gauge.json +600 -0
- package/registry/geo-map.json +484 -0
- package/registry/globe.json +469 -0
- package/registry/goal-progress.json +520 -0
- package/registry/heatmap.json +531 -0
- package/registry/index.json +582 -0
- package/registry/job-throughput.json +654 -0
- package/registry/latency-chart.json +671 -0
- package/registry/line-chart.json +793 -0
- package/registry/pie-chart.json +1288 -0
- package/registry/price-ticker.json +684 -0
- package/registry/radar-chart.json +459 -0
- package/registry/sankey.json +503 -0
- package/registry/scatter-chart.json +559 -0
- package/registry/sparkline.json +563 -0
- package/registry/treemap.json +432 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
LineChart
|
|
4
|
+
} from "./chunk-C4MFZLJM.js";
|
|
5
|
+
import {
|
|
6
|
+
Kpi,
|
|
7
|
+
toneOf
|
|
8
|
+
} from "./chunk-WBHFVBSK.js";
|
|
9
|
+
import {
|
|
10
|
+
TICKER_LABELS,
|
|
11
|
+
direction,
|
|
12
|
+
fillIn,
|
|
13
|
+
signedPercent
|
|
14
|
+
} from "./chunk-WNUFGMS7.js";
|
|
15
|
+
import {
|
|
16
|
+
valueFormatter
|
|
17
|
+
} from "./chunk-XLLYNNC6.js";
|
|
18
|
+
import {
|
|
19
|
+
useSettings
|
|
20
|
+
} from "./chunk-JTKR7ZWP.js";
|
|
21
|
+
|
|
22
|
+
// src/needs/ticker.ts
|
|
23
|
+
function tickerModel(bids, opening, openedAt) {
|
|
24
|
+
const sorted = [...bids].sort((a, b) => new Date(a.at).getTime() - new Date(b.at).getTime());
|
|
25
|
+
const points = [...openedAt ? [{ at: openedAt, amount: opening }] : [], ...sorted];
|
|
26
|
+
const current = sorted.length > 0 ? sorted[sorted.length - 1].amount : opening;
|
|
27
|
+
return { points, current, change: current - opening, ratio: opening > 0 ? current / opening - 1 : null, count: sorted.length };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/ticker/price-ticker.tsx
|
|
31
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
32
|
+
function PriceTicker({ bids, opening, openedAt, currency, reserve, timeFormat = "time", labels: given, description, live = true, ...props }) {
|
|
33
|
+
const words = { ...TICKER_LABELS, ...given };
|
|
34
|
+
const { locale } = useSettings(props);
|
|
35
|
+
const format = { style: "money", currency };
|
|
36
|
+
const write = valueFormatter(format, locale);
|
|
37
|
+
const model = tickerModel(bids, opening, openedAt);
|
|
38
|
+
const way = model.count > 0 ? direction(model.ratio) : null;
|
|
39
|
+
const signed = `${model.change > 0 ? "+" : ""}${write(model.change)}`;
|
|
40
|
+
const thresholds = reserve != null && model.current < reserve ? [{ value: reserve, label: words.reserve, tone: "warning" }] : [];
|
|
41
|
+
const kpi = /* @__PURE__ */ jsx(
|
|
42
|
+
Kpi,
|
|
43
|
+
{
|
|
44
|
+
value: write(model.current),
|
|
45
|
+
label: model.count > 0 ? words.current : words.opening,
|
|
46
|
+
delta: model.count > 0 ? fillIn(words.change, { change: model.ratio == null ? signed : `${signed} (${signedPercent(model.ratio, locale)})`, count: model.count }) : null,
|
|
47
|
+
direction: way,
|
|
48
|
+
tone: toneOf(way, "up")
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
LineChart,
|
|
53
|
+
{
|
|
54
|
+
...props,
|
|
55
|
+
live,
|
|
56
|
+
data: model.points,
|
|
57
|
+
x: "at",
|
|
58
|
+
y: "amount",
|
|
59
|
+
yLabel: words.price,
|
|
60
|
+
xFormat: timeFormat,
|
|
61
|
+
format,
|
|
62
|
+
curve: "step",
|
|
63
|
+
dots: true,
|
|
64
|
+
zero: false,
|
|
65
|
+
thresholds,
|
|
66
|
+
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
+
description,
|
|
68
|
+
description ? /* @__PURE__ */ jsx("br", {}) : null,
|
|
69
|
+
kpi
|
|
70
|
+
] })
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
PriceTicker
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=chunk-KNDHO67X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/needs/ticker.ts","../src/ticker/price-ticker.tsx"],"sourcesContent":["// The price of a live auction, shared by the web and React Native: the points to draw (the opening, then each bid)\n// and what the headline says (the current price, the change since the opening, the number of bids).\n\n/** A bid: when (an ISO date-time or a `Date`) and how much, in money minor units. */\nexport interface Bid {\n readonly at: string | Date;\n readonly amount: number;\n}\n\nexport interface TickerModel {\n readonly points: readonly { readonly at: string | Date; readonly amount: number }[];\n readonly current: number;\n readonly change: number;\n readonly ratio: number | null;\n readonly count: number;\n}\n\n/** The opening point (when `openedAt` is known), then the bids in time order. */\nexport function tickerModel(bids: readonly Bid[], opening: number, openedAt?: string | Date): TickerModel {\n const sorted = [...bids].sort((a, b) => new Date(a.at).getTime() - new Date(b.at).getTime());\n const points = [...(openedAt ? [{ at: openedAt, amount: opening }] : []), ...sorted];\n const current = sorted.length > 0 ? sorted[sorted.length - 1].amount : opening;\n return { points, current, change: current - opening, ratio: opening > 0 ? current / opening - 1 : null, count: sorted.length };\n}\n","\"use client\";\n// The price of a live auction (Orochia's auction room, web and mobile): the current bid in large, what it gained since\n// the opening and how many bids, the price as steps over time (a bid holds until the next), the reserve as a line.\n// `live` by default: new bids redraw without an entrance and without announcing every point.\nimport { valueFormatter } from \"../core/format\";\nimport type { CategoryFormat, Threshold } from \"../core/types\";\nimport { LineChart, type LineChartProps } from \"../line/line-chart\";\nimport { Kpi, toneOf } from \"../needs/kpi\";\nimport { TICKER_LABELS, type TickerLabels } from \"../needs/labels\";\nimport { direction, fillIn, signedPercent } from \"../needs/model\";\nimport { type Bid, tickerModel } from \"../needs/ticker\";\nimport { useSettings } from \"../web/frame\";\n\ntype Point = { at: string | Date; amount: number };\n\nexport interface PriceTickerProps\n extends Omit<LineChartProps<Point>, \"data\" | \"x\" | \"y\" | \"yLabel\" | \"series\" | \"format\" | \"xFormat\" | \"thresholds\" | \"curve\" | \"labels\"> {\n /** The bids, in any order: when and how much (minor units). */\n bids: readonly Bid[];\n /** The opening price, in minor units. */\n opening: number;\n /** When the auction opened: the first point of the line. */\n openedAt?: string | Date;\n /** The ISO 4217 currency. */\n currency: string;\n /** The reserve price, drawn as a line until it is met. */\n reserve?: number;\n /** How the times are written. Default `\"time\"` (`14:30`); `\"datetime\"` for auctions over several days. */\n timeFormat?: CategoryFormat;\n /** The words, passed translated; English by default. */\n labels?: Partial<TickerLabels>;\n}\n\n/** A live auction's price: the current bid, the change since the opening, the steps of the bids, the reserve. */\nexport function PriceTicker({ bids, opening, openedAt, currency, reserve, timeFormat = \"time\", labels: given, description, live = true, ...props }: PriceTickerProps) {\n const words = { ...TICKER_LABELS, ...given };\n const { locale } = useSettings(props);\n const format = { style: \"money\", currency } as const;\n const write = valueFormatter(format, locale);\n const model = tickerModel(bids, opening, openedAt);\n const way = model.count > 0 ? direction(model.ratio) : null;\n const signed = `${model.change > 0 ? \"+\" : \"\"}${write(model.change)}`;\n const thresholds: Threshold[] = reserve != null && model.current < reserve ? [{ value: reserve, label: words.reserve, tone: \"warning\" }] : [];\n const kpi = (\n <Kpi\n value={write(model.current)}\n label={model.count > 0 ? words.current : words.opening}\n delta={\n model.count > 0\n ? fillIn(words.change, { change: model.ratio == null ? signed : `${signed} (${signedPercent(model.ratio, locale)})`, count: model.count })\n : null\n }\n direction={way}\n tone={toneOf(way, \"up\")}\n />\n );\n return (\n <LineChart\n {...props}\n live={live}\n data={model.points as Point[]}\n x=\"at\"\n y=\"amount\"\n yLabel={words.price}\n xFormat={timeFormat}\n format={format}\n curve=\"step\"\n dots\n zero={false}\n thresholds={thresholds}\n description={\n <>\n {description}\n {description ? <br /> : null}\n {kpi}\n </>\n }\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,YAAY,MAAsB,SAAiB,UAAuC;AACxG,QAAM,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,EAAE,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,EAAE,EAAE,QAAQ,CAAC;AAC3F,QAAM,SAAS,CAAC,GAAI,WAAW,CAAC,EAAE,IAAI,UAAU,QAAQ,QAAQ,CAAC,IAAI,CAAC,GAAI,GAAG,MAAM;AACnF,QAAM,UAAU,OAAO,SAAS,IAAI,OAAO,OAAO,SAAS,CAAC,EAAE,SAAS;AACvE,SAAO,EAAE,QAAQ,SAAS,QAAQ,UAAU,SAAS,OAAO,UA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,SAAS;AAAA,MACT;AAAA,MACA,OAAM;AAAA,MACN,MAAI;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,MACA,aACE,iCACG;AAAA;AAAA,QACA,cAAc,oBAAC,QAAG,IAAK;AAAA,QACvB;AAAA,SACH;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Sparkline
|
|
4
|
+
} from "./chunk-ARARFMNE.js";
|
|
5
|
+
import {
|
|
6
|
+
Kpi
|
|
7
|
+
} from "./chunk-WBHFVBSK.js";
|
|
8
|
+
import {
|
|
9
|
+
CREDIT_LABELS,
|
|
10
|
+
addDays,
|
|
11
|
+
daysLeft,
|
|
12
|
+
fillIn,
|
|
13
|
+
quotaLevel
|
|
14
|
+
} from "./chunk-WNUFGMS7.js";
|
|
15
|
+
import {
|
|
16
|
+
categoryFormatter,
|
|
17
|
+
valueFormatter
|
|
18
|
+
} from "./chunk-XLLYNNC6.js";
|
|
19
|
+
import {
|
|
20
|
+
ChartStyles,
|
|
21
|
+
cx,
|
|
22
|
+
useSettings
|
|
23
|
+
} from "./chunk-JTKR7ZWP.js";
|
|
24
|
+
|
|
25
|
+
// src/credits/credit-usage.tsx
|
|
26
|
+
import { useId } from "react";
|
|
27
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
|
+
function CreditUsage({
|
|
29
|
+
title,
|
|
30
|
+
description,
|
|
31
|
+
hideTitle,
|
|
32
|
+
used,
|
|
33
|
+
limit,
|
|
34
|
+
format = "integer",
|
|
35
|
+
daily,
|
|
36
|
+
days,
|
|
37
|
+
renewsAt,
|
|
38
|
+
now,
|
|
39
|
+
levels = [0.8, 0.95],
|
|
40
|
+
loading,
|
|
41
|
+
labels: given,
|
|
42
|
+
className,
|
|
43
|
+
style,
|
|
44
|
+
...settings
|
|
45
|
+
}) {
|
|
46
|
+
const words = { ...CREDIT_LABELS, ...given };
|
|
47
|
+
const { locale, brand } = useSettings({ title, ...settings });
|
|
48
|
+
const uid = useId();
|
|
49
|
+
const write = valueFormatter(format, locale);
|
|
50
|
+
const date = categoryFormatter("date", locale);
|
|
51
|
+
const ratio = limit > 0 ? Math.min(1, Math.max(0, used / limit)) : 0;
|
|
52
|
+
const level = quotaLevel(ratio, levels[0], levels[1]);
|
|
53
|
+
const remaining = Math.max(0, limit - used);
|
|
54
|
+
const percent = valueFormatter("percent", locale)(ratio);
|
|
55
|
+
const usedText = fillIn(words.used, { used: write(used), percent });
|
|
56
|
+
const left = daily ? daysLeft(remaining, daily) : null;
|
|
57
|
+
const today = now ?? /* @__PURE__ */ new Date();
|
|
58
|
+
const runOut = left == null ? null : addDays(today, left);
|
|
59
|
+
const renews = renewsAt ? new Date(renewsAt) : null;
|
|
60
|
+
const projection = daily ? runOut && (!renews || runOut < renews) ? fillIn(words.runsOut, { date: date(runOut) }) : left == null ? words.steady : null : null;
|
|
61
|
+
return /* @__PURE__ */ jsxs("figure", { className: cx("kzc", className), style, "data-kzc": "", "data-brand": brand, "data-kind": "credits", "aria-labelledby": `${uid}-t`, "aria-busy": loading || void 0, children: [
|
|
62
|
+
/* @__PURE__ */ jsx(ChartStyles, {}),
|
|
63
|
+
/* @__PURE__ */ jsxs("div", { className: "kzc-heading", children: [
|
|
64
|
+
/* @__PURE__ */ jsx("p", { id: `${uid}-t`, className: hideTitle ? "kzc-sr" : "kzc-title", children: title }),
|
|
65
|
+
description ? /* @__PURE__ */ jsx("p", { className: "kzc-desc", children: description }) : null
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsx("p", { className: "kzc-desc", children: /* @__PURE__ */ jsx(Kpi, { value: loading ? "\u2014" : write(remaining), label: fillIn(words.remaining, { limit: write(limit) }) }) }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
role: "meter",
|
|
72
|
+
"aria-labelledby": `${uid}-t`,
|
|
73
|
+
"aria-valuemin": 0,
|
|
74
|
+
"aria-valuemax": limit,
|
|
75
|
+
"aria-valuenow": Math.min(limit, Math.max(0, used)),
|
|
76
|
+
"aria-valuetext": usedText,
|
|
77
|
+
className: "kzc-meter",
|
|
78
|
+
"data-tone": level === "ok" ? void 0 : level,
|
|
79
|
+
children: /* @__PURE__ */ jsx("i", { style: { width: loading ? 0 : `${ratio * 100}%` } })
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ jsxs("p", { className: "kzc-row", children: [
|
|
83
|
+
/* @__PURE__ */ jsx("span", { children: usedText }),
|
|
84
|
+
renews ? /* @__PURE__ */ jsx("span", { children: fillIn(words.renews, { date: date(renews) }) }) : null
|
|
85
|
+
] }),
|
|
86
|
+
daily && daily.length > 1 ? /* @__PURE__ */ jsx(Sparkline, { title: words.daily, data: daily, categories: days, variant: "bar", format, height: 36, loading }) : null,
|
|
87
|
+
projection && !loading ? /* @__PURE__ */ jsx("p", { className: "kzc-row", children: /* @__PURE__ */ jsx("b", { children: projection }) }) : null
|
|
88
|
+
] });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
CreditUsage
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-L2EKYWVI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/credits/credit-usage.tsx"],"sourcesContent":["\"use client\";\n// What is left of a credit allowance (Orazaka's billing meter, the console's quotas, Orochia's storage plan): the\n// remaining amount in large, a meter that turns to warning then danger, the use per day as a sparkline, and the day it\n// runs out at the current pace. A `meter` for assistive technology, its value said in words.\nimport { type CSSProperties, type ReactNode, useId } from \"react\";\n\nimport { categoryFormatter, valueFormatter } from \"../core/format\";\nimport type { ValueFormat } from \"../core/types\";\nimport { Kpi } from \"../needs/kpi\";\nimport { CREDIT_LABELS, type CreditLabels } from \"../needs/labels\";\nimport { addDays, daysLeft, fillIn, quotaLevel } from \"../needs/model\";\nimport { Sparkline } from \"../sparkline/sparkline\";\nimport type { ChartsSettings } from \"../web/context\";\nimport { useSettings } from \"../web/frame\";\nimport { cx } from \"../web/parts\";\nimport { ChartStyles } from \"../web/styles\";\n\nexport interface CreditUsageProps extends Omit<ChartsSettings, \"labels\"> {\n /** What the allowance is (“Credits this month”): the heading and the meter's name. */\n title: string;\n /** A line under the title: the plan, the period. */\n description?: ReactNode;\n /** Visually hide the title (it stays the accessible name). */\n hideTitle?: boolean;\n /** How much is used. */\n used: number;\n /** The allowance. */\n limit: number;\n /** How the amounts are written. Default `\"integer\"`; a `{ style: \"unit\", unit: \"gigabyte\" }` for storage. */\n format?: ValueFormat;\n /** The use of each recent day, oldest first: the sparkline and the projection. */\n daily?: readonly (number | null)[];\n /** The days of `daily` (ISO dates), for the sparkline's summary. */\n days?: readonly unknown[];\n /** When the allowance renews (an ISO date or a `Date`). */\n renewsAt?: string | Date;\n /** Today, for the projection (pass it from the server to render the same date on both sides). Default: now. */\n now?: Date;\n /** The share where the meter turns to warning, then danger. Default `[0.8, 0.95]`. */\n levels?: readonly [number, number];\n /** The data is on its way. */\n loading?: boolean;\n /** The words, passed translated; English by default. */\n labels?: Partial<CreditLabels>;\n /** A class on the figure (layout). */\n className?: string;\n /** Inline style on the figure (layout only). */\n style?: CSSProperties;\n}\n\n/** What is left of an allowance: the remaining amount, a meter in tones, the use per day and the run-out date. */\nexport function CreditUsage({\n title,\n description,\n hideTitle,\n used,\n limit,\n format = \"integer\",\n daily,\n days,\n renewsAt,\n now,\n levels = [0.8, 0.95],\n loading,\n labels: given,\n className,\n style,\n ...settings\n}: CreditUsageProps) {\n const words = { ...CREDIT_LABELS, ...given };\n const { locale, brand } = useSettings({ title, ...settings });\n const uid = useId();\n const write = valueFormatter(format, locale);\n const date = categoryFormatter(\"date\", locale);\n const ratio = limit > 0 ? Math.min(1, Math.max(0, used / limit)) : 0;\n const level = quotaLevel(ratio, levels[0], levels[1]);\n const remaining = Math.max(0, limit - used);\n const percent = valueFormatter(\"percent\", locale)(ratio);\n const usedText = fillIn(words.used, { used: write(used), percent });\n const left = daily ? daysLeft(remaining, daily) : null;\n const today = now ?? new Date();\n const runOut = left == null ? null : addDays(today, left);\n const renews = renewsAt ? new Date(renewsAt) : null;\n // The run-out date only matters when it comes before the renewal.\n const projection = daily ? (runOut && (!renews || runOut < renews) ? fillIn(words.runsOut, { date: date(runOut) }) : left == null ? words.steady : null) : null;\n return (\n <figure className={cx(\"kzc\", className)} style={style} data-kzc=\"\" data-brand={brand} data-kind=\"credits\" aria-labelledby={`${uid}-t`} aria-busy={loading || undefined}>\n <ChartStyles />\n <div className=\"kzc-heading\">\n <p id={`${uid}-t`} className={hideTitle ? \"kzc-sr\" : \"kzc-title\"}>\n {title}\n </p>\n {description ? <p className=\"kzc-desc\">{description}</p> : null}\n </div>\n <p className=\"kzc-desc\">\n <Kpi value={loading ? \"—\" : write(remaining)} label={fillIn(words.remaining, { limit: write(limit) })} />\n </p>\n <div\n role=\"meter\"\n aria-labelledby={`${uid}-t`}\n aria-valuemin={0}\n aria-valuemax={limit}\n aria-valuenow={Math.min(limit, Math.max(0, used))}\n aria-valuetext={usedText}\n className=\"kzc-meter\"\n data-tone={level === \"ok\" ? undefined : level}\n >\n <i style={{ width: loading ? 0 : `${ratio * 100}%` }} />\n </div>\n <p className=\"kzc-row\">\n <span>{usedText}</span>\n {renews ? <span>{fillIn(words.renews, { date: date(renews) })}</span> : null}\n </p>\n {daily && daily.length > 1 ? (\n <Sparkline title={words.daily} data={daily} categories={days} variant=\"bar\" format={format} height={36} loading={loading} />\n ) : null}\n {projection && !loading ? (\n <p className=\"kzc-row\">\n <b>{projection}</b>\n </p>\n ) : null}\n </figure>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAA6C,aAAa;AAmFpD,cACA,YADA;AApCC,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAA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from "./chunk-PWMMXRMC.js";
|
|
7
|
+
import {
|
|
8
|
+
read
|
|
9
|
+
} from "./chunk-W5FX4TU3.js";
|
|
10
|
+
import {
|
|
11
|
+
shareFormatter,
|
|
12
|
+
valueFormatter
|
|
13
|
+
} from "./chunk-XLLYNNC6.js";
|
|
14
|
+
import {
|
|
15
|
+
useSettings
|
|
16
|
+
} from "./chunk-JTKR7ZWP.js";
|
|
17
|
+
import {
|
|
18
|
+
capitalize,
|
|
19
|
+
fill
|
|
20
|
+
} from "./chunk-3CJHBJXA.js";
|
|
21
|
+
|
|
22
|
+
// src/sankey/sankey.tsx
|
|
23
|
+
import { useCallback, useMemo } from "react";
|
|
24
|
+
import { jsx } from "react/jsx-runtime";
|
|
25
|
+
var engine = () => import("./sankey-XQTX2EG6.js");
|
|
26
|
+
function Sankey(props) {
|
|
27
|
+
const { data, source, target, value, format, vertical, sourceLabel, targetLabel, valueLabel } = props;
|
|
28
|
+
const { locale, labels } = useSettings(props);
|
|
29
|
+
const fmt = useMemo(() => ({ value: valueFormatter(format, locale, labels.noValue), share: shareFormatter(locale) }), [format, locale, labels.noValue]);
|
|
30
|
+
const model = useMemo(() => {
|
|
31
|
+
const links = data.map((d, i) => ({ source: String(read(source, d, i)), target: String(read(target, d, i)), value: Number(read(value, d, i)) })).filter((l) => Number.isFinite(l.value) && l.value > 0);
|
|
32
|
+
const nodes = [...new Set(links.flatMap((l) => [l.source, l.target]))];
|
|
33
|
+
return { links, nodes };
|
|
34
|
+
}, [data, source, target, value]);
|
|
35
|
+
const isEmpty = model.links.length === 0;
|
|
36
|
+
const total = model.links.filter((l) => !model.links.some((o) => o.target === l.source)).reduce((sum, l) => sum + l.value, 0);
|
|
37
|
+
const top = [...model.links].sort((a, b) => b.value - a.value).slice(0, 3);
|
|
38
|
+
const summary = isEmpty ? labels.empty : `${fill(labels.summaryIntro, { kind: labels.kinds.sankey, count: `${model.nodes.length} \xB7 ${model.links.length}` })} ${top.map((l) => fill(labels.summaryShare, { label: `${l.source} \u2192 ${l.target}`, value: fmt.value(l.value), share: fmt.share(total ? l.value / total : 0) })).join(", ")}. ${capitalize(fill(labels.summaryTotal, { total: fmt.value(total) }))}.`;
|
|
39
|
+
const items = model.links.map((l, i) => ({ seriesIndex: 0, dataIndex: i, dataType: "edge", text: `${l.source} \u2192 ${l.target}: ${fmt.value(l.value)}` }));
|
|
40
|
+
const build = useCallback(
|
|
41
|
+
(theme) => {
|
|
42
|
+
const base = baseOption(theme, true);
|
|
43
|
+
const colorOf = (name) => theme.palette[model.nodes.indexOf(name) % 8];
|
|
44
|
+
return {
|
|
45
|
+
...base,
|
|
46
|
+
tooltip: {
|
|
47
|
+
...base.tooltip,
|
|
48
|
+
trigger: "item",
|
|
49
|
+
formatter: (p) => p.dataType === "edge" ? tooltipHtml(`${p.data.source} \u2192 ${p.data.target}`, [{ label: valueLabel ?? labels.value, value: fmt.value(p.data.value), color: colorOf(p.data.source) }]) : tooltipHtml(p.name, [{ label: valueLabel ?? labels.value, value: fmt.value(p.value), color: colorOf(p.name) }])
|
|
50
|
+
},
|
|
51
|
+
series: [
|
|
52
|
+
{
|
|
53
|
+
type: "sankey",
|
|
54
|
+
orient: vertical ? "vertical" : "horizontal",
|
|
55
|
+
left: 8,
|
|
56
|
+
right: vertical ? 8 : 120,
|
|
57
|
+
top: 8,
|
|
58
|
+
bottom: vertical ? 40 : 8,
|
|
59
|
+
nodeWidth: 12,
|
|
60
|
+
nodeGap: 10,
|
|
61
|
+
draggable: false,
|
|
62
|
+
emphasis: { focus: "adjacency" },
|
|
63
|
+
data: model.nodes.map((name) => ({ name, itemStyle: { color: colorOf(name), borderColor: theme.surface, borderWidth: 1 } })),
|
|
64
|
+
links: model.links.map((l) => ({ ...l, lineStyle: { color: colorOf(l.source), opacity: 0.28 } })),
|
|
65
|
+
label: { color: theme.text, fontSize: 11, fontFamily: theme.font },
|
|
66
|
+
lineStyle: { curveness: 0.5 }
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
[model, fmt, vertical, valueLabel, labels.value]
|
|
72
|
+
);
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
EChartHost,
|
|
75
|
+
{
|
|
76
|
+
kind: "sankey",
|
|
77
|
+
frame: props,
|
|
78
|
+
defaultHeight: 320,
|
|
79
|
+
table: { columns: [sourceLabel ?? labels.category, targetLabel ?? labels.value, valueLabel ?? labels.value], rows: model.links.map((l) => [l.source, l.target, fmt.value(l.value)]) },
|
|
80
|
+
summary,
|
|
81
|
+
isEmpty,
|
|
82
|
+
engine,
|
|
83
|
+
build,
|
|
84
|
+
items
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
Sankey
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=chunk-MXLITIGU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sankey/sankey.tsx"],"sourcesContent":["\"use client\";\n// Flows between stages — credits from plans to models to outcomes, viewers from sources to purchases — on ECharts\n// (loaded when the chart nears the screen). Each node keeps its palette slot in order of appearance; links take\n// their source's colour, softened.\nimport { useCallback, useMemo } from \"react\";\n\nimport { read } from \"../core/data\";\nimport { shareFormatter, valueFormatter } from \"../core/format\";\nimport { capitalize, fill } from \"../core/labels\";\nimport type { Accessor, Datum, ValueFormat } from \"../core/types\";\nimport { EChartHost, type EngineProps, type WalkItem } from \"../echarts/host\";\nimport { baseOption, type ResolvedTheme, tooltipHtml } from \"../echarts/theme\";\nimport type { ChartFrameProps } from \"../web/frame\";\nimport { useSettings } from \"../web/frame\";\n\nconst engine = () => import(\"../echarts/engines/sankey\");\n\nexport interface SankeyProps<T extends Datum> extends ChartFrameProps, EngineProps {\n /** One row per flow. */\n data: readonly T[];\n /** The fields (or functions) naming where the flow comes from and where it goes. */\n source: Accessor<T, string>;\n/** The field (or function) naming where the flow goes. */\n target: Accessor<T, string>;\n /** The field of its amount. */\n value: Accessor<T, number>;\n /** How the amounts are written. */\n format?: ValueFormat;\n /** Lay the stages out top to bottom (narrow screens). Default: left to right. */\n vertical?: boolean;\n /** The headers of the data table. */\n sourceLabel?: string;\n/** The header of the targets. */\n targetLabel?: string;\n/** The header of the amounts. */\n valueLabel?: string;\n}\n\nexport function Sankey<T extends Datum>(props: SankeyProps<T>) {\n const { data, source, target, value, format, vertical, sourceLabel, targetLabel, valueLabel } = props;\n const { locale, labels } = useSettings(props);\n const fmt = useMemo(() => ({ value: valueFormatter(format, locale, labels.noValue), share: shareFormatter(locale) }), [format, locale, labels.noValue]);\n const model = useMemo(() => {\n const links = data.map((d, i) => ({ source: String(read(source, d, i)), target: String(read(target, d, i)), value: Number(read(value, d, i)) })).filter((l) => Number.isFinite(l.value) && l.value > 0);\n const nodes = [...new Set(links.flatMap((l) => [l.source, l.target]))];\n return { links, nodes };\n }, [data, source, target, value]);\n const isEmpty = model.links.length === 0;\n const total = model.links.filter((l) => !model.links.some((o) => o.target === l.source)).reduce((sum, l) => sum + l.value, 0);\n const top = [...model.links].sort((a, b) => b.value - a.value).slice(0, 3);\n const summary = isEmpty\n ? labels.empty\n : `${fill(labels.summaryIntro, { kind: labels.kinds.sankey, count: `${model.nodes.length} · ${model.links.length}` })} ${top.map((l) => fill(labels.summaryShare, { label: `${l.source} → ${l.target}`, value: fmt.value(l.value), share: fmt.share(total ? l.value / total : 0) })).join(\", \")}. ${capitalize(fill(labels.summaryTotal, { total: fmt.value(total) }))}.`;\n const items: WalkItem[] = model.links.map((l, i) => ({ seriesIndex: 0, dataIndex: i, dataType: \"edge\", text: `${l.source} → ${l.target}: ${fmt.value(l.value)}` }));\n\n const build = useCallback(\n (theme: ResolvedTheme) => {\n const base = baseOption(theme, true);\n const colorOf = (name: string) => theme.palette[model.nodes.indexOf(name) % 8]!;\n return {\n ...base,\n tooltip: {\n ...(base.tooltip as object),\n trigger: \"item\",\n formatter: (p: { dataType: string; data: { source?: string; target?: string; value?: number; name?: string }; value: number; name: string }) =>\n p.dataType === \"edge\"\n ? tooltipHtml(`${p.data.source} → ${p.data.target}`, [{ label: valueLabel ?? labels.value, value: fmt.value(p.data.value), color: colorOf(p.data.source!) }])\n : tooltipHtml(p.name, [{ label: valueLabel ?? labels.value, value: fmt.value(p.value), color: colorOf(p.name) }]),\n },\n series: [\n {\n type: \"sankey\",\n orient: vertical ? \"vertical\" : \"horizontal\",\n left: 8,\n right: vertical ? 8 : 120,\n top: 8,\n bottom: vertical ? 40 : 8,\n nodeWidth: 12,\n nodeGap: 10,\n draggable: false,\n emphasis: { focus: \"adjacency\" },\n data: model.nodes.map((name) => ({ name, itemStyle: { color: colorOf(name), borderColor: theme.surface, borderWidth: 1 } })),\n links: model.links.map((l) => ({ ...l, lineStyle: { color: colorOf(l.source), opacity: 0.28 } })),\n label: { color: theme.text, fontSize: 11, fontFamily: theme.font },\n lineStyle: { curveness: 0.5 },\n },\n ],\n };\n },\n [model, fmt, vertical, valueLabel, labels.value],\n );\n\n return (\n <EChartHost\n kind=\"sankey\"\n frame={props}\n defaultHeight={320}\n table={{ columns: [sourceLabel ?? labels.category, targetLabel ?? labels.value, valueLabel ?? labels.value], rows: model.links.map((l) => [l.source, l.target, fmt.value(l.value)]) }}\n summary={summary}\n isEmpty={isEmpty}\n engine={engine}\n build={build}\n items={items}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,aAAa,eAAe;AAyFjC;AA9EJ,IAAM,SAAS,MAAM,OAAO,sBAA2B;AAuBhD,SAAS,OAAwB,OAAuB;AAC7D,QAAM,EAAE,MAAM,QAAQ,QAAQ,OAAO,QAAQ,UAAU,aAAa,aAAa,WAAW,IAAI;AAChG,QAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,KAAK;AAC5C,QAAM,MAAM,QAAQ,OAAO,EAAE,OAAO,eAAe,QAAQ,QAAQ,OAAO,OAAO,GAAG,OAAO,eAAe,MAAM,EAAE,IAAI,CAAC,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AAM,MAAM,IAAI,CAAC,UAAU,EAAE,MAAM,WAAW,EAAE,OAAO,QAAQ,IAAI,GAAG,aAAa,MAAM,SAAS,aAAa,EAAE,EAAE,EAAE;AAAA,YAC3H,OAAO,MAAM,MAAM,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,EAAE,OAAO,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,EAAE,EAAE;AAAA,YAChG,OAAO,EAAE,OAAO,MAAM,MAAM,UAAU,IAAI,YAAY,MAAM,KAAK;AAAA,YACjE,WAAW,EAAE,WAAW,IAAI;AAAA,UAC9B;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,OAAO,KAAK,UAAU,YAAY,OAAO,KAAK;AAAA,EACjD;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,OAAO;AAAA,MACP,eAAe;AAAA,MACf,OAAO,EAAE,SAAS,CAAC,eAAe,OAAO,UAAU,eAAe,OAAO,OAAO,cAAc,OAAO,KAAK,GAAG,MAAM,MAAM,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,IAAI,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE;AAAA,MACpL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
EChartHost,
|
|
4
|
+
baseOption,
|
|
5
|
+
categoryAxis,
|
|
6
|
+
tooltipHtml,
|
|
7
|
+
valueAxis
|
|
8
|
+
} from "./chunk-PWMMXRMC.js";
|
|
9
|
+
import {
|
|
10
|
+
read
|
|
11
|
+
} from "./chunk-W5FX4TU3.js";
|
|
12
|
+
import {
|
|
13
|
+
categoryFormatter,
|
|
14
|
+
shareFormatter,
|
|
15
|
+
valueFormatter
|
|
16
|
+
} from "./chunk-XLLYNNC6.js";
|
|
17
|
+
import {
|
|
18
|
+
useSettings
|
|
19
|
+
} from "./chunk-JTKR7ZWP.js";
|
|
20
|
+
import {
|
|
21
|
+
capitalize,
|
|
22
|
+
fill
|
|
23
|
+
} from "./chunk-3CJHBJXA.js";
|
|
24
|
+
|
|
25
|
+
// src/candlestick/candlestick.tsx
|
|
26
|
+
import { useCallback, useMemo } from "react";
|
|
27
|
+
import { jsx } from "react/jsx-runtime";
|
|
28
|
+
var engine = () => import("./candlestick-IG626XL4.js");
|
|
29
|
+
var DEFAULT_COLUMNS = { open: "Open", high: "High", low: "Low", close: "Close", volume: "Volume" };
|
|
30
|
+
function Candlestick(props) {
|
|
31
|
+
const { data, x, open, high, low, close, volume, format, volumeFormat = "compact", xFormat, thresholds = [], zoom, columnLabels = DEFAULT_COLUMNS } = props;
|
|
32
|
+
const { locale, labels } = useSettings(props);
|
|
33
|
+
const fmt = useMemo(
|
|
34
|
+
() => ({
|
|
35
|
+
value: valueFormatter(format, locale, labels.noValue),
|
|
36
|
+
axis: valueFormatter(format, locale, labels.noValue, true),
|
|
37
|
+
volume: valueFormatter(volumeFormat, locale, labels.noValue),
|
|
38
|
+
category: categoryFormatter(xFormat, locale),
|
|
39
|
+
share: shareFormatter(locale)
|
|
40
|
+
}),
|
|
41
|
+
[format, volumeFormat, xFormat, locale, labels.noValue]
|
|
42
|
+
);
|
|
43
|
+
const rows = useMemo(
|
|
44
|
+
() => data.map((d, i) => ({
|
|
45
|
+
x: fmt.category(read(x, d, i)),
|
|
46
|
+
o: Number(read(open, d, i)),
|
|
47
|
+
h: Number(read(high, d, i)),
|
|
48
|
+
l: Number(read(low, d, i)),
|
|
49
|
+
c: Number(read(close, d, i)),
|
|
50
|
+
v: volume ? Number(read(volume, d, i)) : null
|
|
51
|
+
})),
|
|
52
|
+
[data, x, open, high, low, close, volume, fmt]
|
|
53
|
+
);
|
|
54
|
+
const isEmpty = rows.length === 0;
|
|
55
|
+
const first = rows[0];
|
|
56
|
+
const last = rows[rows.length - 1];
|
|
57
|
+
const hi = Math.max(...rows.map((r) => r.h));
|
|
58
|
+
const lo = Math.min(...rows.map((r) => r.l));
|
|
59
|
+
const change = first && last && first.o ? last.c / first.o - 1 : null;
|
|
60
|
+
const summary = isEmpty ? labels.empty : [
|
|
61
|
+
fill(labels.summaryIntro, { kind: labels.kinds.candlestick, count: `${rows.length} (${first.x} \u2013 ${last.x})` }),
|
|
62
|
+
`${capitalize(fill(labels.summaryOhlc, { open: fmt.value(first.o), close: fmt.value(last.c), low: fmt.value(lo), high: fmt.value(hi) }))}${change === null ? "" : `, ${fill(change >= 0 ? labels.summaryTrendUp : labels.summaryTrendDown, { change: fmt.share(Math.abs(change)) })}`}.`
|
|
63
|
+
].join(" ");
|
|
64
|
+
const items = rows.map((r, i) => ({ seriesIndex: 0, dataIndex: i, text: `${r.x}: ${columnLabels.open} ${fmt.value(r.o)}, ${columnLabels.high} ${fmt.value(r.h)}, ${columnLabels.low} ${fmt.value(r.l)}, ${columnLabels.close} ${fmt.value(r.c)}` }));
|
|
65
|
+
const zoomOn = zoom ?? rows.length >= 40;
|
|
66
|
+
const build = useCallback(
|
|
67
|
+
(theme) => {
|
|
68
|
+
const base = baseOption(theme, true);
|
|
69
|
+
const withVolume = rows.some((r) => r.v != null);
|
|
70
|
+
const xs = rows.map((r) => r.x);
|
|
71
|
+
const grids = withVolume ? [
|
|
72
|
+
{ left: 8, right: 12, top: 12, bottom: "30%", containLabel: true },
|
|
73
|
+
{ left: 8, right: 12, top: "76%", bottom: 8, containLabel: true }
|
|
74
|
+
] : [{ left: 8, right: 12, top: 12, bottom: 8, containLabel: true }];
|
|
75
|
+
return {
|
|
76
|
+
...base,
|
|
77
|
+
tooltip: {
|
|
78
|
+
...base.tooltip,
|
|
79
|
+
trigger: "axis",
|
|
80
|
+
axisPointer: { type: "line", lineStyle: { color: theme.axis } },
|
|
81
|
+
formatter: (params) => {
|
|
82
|
+
const r = rows[params[0].dataIndex];
|
|
83
|
+
const up = r.c >= r.o;
|
|
84
|
+
return tooltipHtml(
|
|
85
|
+
r.x,
|
|
86
|
+
[
|
|
87
|
+
{ label: columnLabels.open, value: fmt.value(r.o) },
|
|
88
|
+
{ label: columnLabels.high, value: fmt.value(r.h) },
|
|
89
|
+
{ label: columnLabels.low, value: fmt.value(r.l) },
|
|
90
|
+
{ label: columnLabels.close, value: fmt.value(r.c), color: up ? theme.success : theme.danger },
|
|
91
|
+
...r.v != null ? [{ label: columnLabels.volume, value: fmt.volume(r.v) }] : []
|
|
92
|
+
]
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
grid: grids,
|
|
97
|
+
xAxis: grids.map((_, i) => ({ ...categoryAxis(theme, xs), gridIndex: i, axisLabel: { color: theme.text2, hideOverlap: true, show: i === grids.length - 1 } })),
|
|
98
|
+
yAxis: [
|
|
99
|
+
{ ...valueAxis(theme, (v) => fmt.axis(v)), scale: true, gridIndex: 0 },
|
|
100
|
+
...withVolume ? [{ ...valueAxis(theme, (v) => fmt.volume(v)), gridIndex: 1, splitNumber: 2 }] : []
|
|
101
|
+
],
|
|
102
|
+
dataZoom: zoomOn ? [{ type: "inside", xAxisIndex: grids.map((_, i) => i), start: Math.max(0, 100 - 40 / rows.length * 100), end: 100 }] : [],
|
|
103
|
+
series: [
|
|
104
|
+
{
|
|
105
|
+
type: "candlestick",
|
|
106
|
+
data: rows.map((r) => [r.o, r.c, r.l, r.h]),
|
|
107
|
+
barMaxWidth: 14,
|
|
108
|
+
itemStyle: { color: theme.surface, color0: theme.danger, borderColor: theme.success, borderColor0: theme.danger, borderWidth: 1.5 },
|
|
109
|
+
markLine: thresholds.length ? {
|
|
110
|
+
symbol: "none",
|
|
111
|
+
silent: true,
|
|
112
|
+
data: thresholds.map((t) => ({
|
|
113
|
+
yAxis: t.value,
|
|
114
|
+
label: { formatter: fill(labels.summaryThreshold, { label: t.label, value: fmt.value(t.value) }), color: theme.text, position: "insideEndTop", fontWeight: 600 },
|
|
115
|
+
lineStyle: { color: t.tone && t.tone !== "neutral" ? theme[t.tone === "accent" ? "accent" : t.tone] : theme.text2, type: [6, 4], width: 1.5 }
|
|
116
|
+
}))
|
|
117
|
+
} : void 0
|
|
118
|
+
},
|
|
119
|
+
...withVolume ? [
|
|
120
|
+
{
|
|
121
|
+
type: "bar",
|
|
122
|
+
xAxisIndex: 1,
|
|
123
|
+
yAxisIndex: 1,
|
|
124
|
+
barMaxWidth: 14,
|
|
125
|
+
data: rows.map((r) => ({ value: r.v, itemStyle: { color: r.c >= r.o ? theme.success : theme.danger, opacity: 0.45, borderRadius: [2, 2, 0, 0] } }))
|
|
126
|
+
}
|
|
127
|
+
] : []
|
|
128
|
+
]
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
[rows, fmt, thresholds, zoomOn, columnLabels, labels.summaryThreshold]
|
|
132
|
+
);
|
|
133
|
+
return /* @__PURE__ */ jsx(
|
|
134
|
+
EChartHost,
|
|
135
|
+
{
|
|
136
|
+
kind: "candlestick",
|
|
137
|
+
frame: props,
|
|
138
|
+
defaultHeight: 340,
|
|
139
|
+
table: {
|
|
140
|
+
columns: [labels.category, columnLabels.open, columnLabels.high, columnLabels.low, columnLabels.close, ...volume ? [columnLabels.volume] : []],
|
|
141
|
+
rows: rows.map((r) => [r.x, fmt.value(r.o), fmt.value(r.h), fmt.value(r.l), fmt.value(r.c), ...volume ? [fmt.volume(r.v)] : []])
|
|
142
|
+
},
|
|
143
|
+
summary,
|
|
144
|
+
isEmpty,
|
|
145
|
+
engine,
|
|
146
|
+
build,
|
|
147
|
+
items
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export {
|
|
153
|
+
Candlestick
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=chunk-NCIQMRV3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/candlestick/candlestick.tsx"],"sourcesContent":["\"use client\";\n// Open, high, low, close per period — a price, an auction's bids per hour — with what a colour-blind reader needs: a\n// rising candle is hollow (outlined in the success tone), a falling one filled (danger), so the shape says the\n// direction as well as the colour. Optional volume in its own panel below (never a second axis on the same plot),\n// zoom by wheel and drag, thresholds. ECharts, loaded when the chart nears the screen.\nimport { useCallback, useMemo } from \"react\";\n\nimport { read } from \"../core/data\";\nimport { categoryFormatter, shareFormatter, valueFormatter } from \"../core/format\";\nimport { capitalize, fill } from \"../core/labels\";\nimport type { Accessor, CategoryFormat, Datum, Threshold, ValueFormat } from \"../core/types\";\nimport { EChartHost, type EngineProps, type WalkItem } from \"../echarts/host\";\nimport { baseOption, categoryAxis, type ResolvedTheme, tooltipHtml, valueAxis } from \"../echarts/theme\";\nimport type { ChartFrameProps } from \"../web/frame\";\nimport { useSettings } from \"../web/frame\";\n\nconst engine = () => import(\"../echarts/engines/candlestick\");\n\nexport interface CandlestickProps<T extends Datum> extends ChartFrameProps, EngineProps {\n /** One row per period, oldest first. */\n data: readonly T[];\n /** The field of the period (a date, an hour). */\n x: Accessor<T, unknown>;\n/** The field of the price at the start of the period. */\n open: Accessor<T, number>;\n/** The field of the highest price of the period. */\n high: Accessor<T, number>;\n/** The field of the lowest price of the period. */\n low: Accessor<T, number>;\n/** The field of the price at the end of the period. */\n close: Accessor<T, number>;\n /** The field of the volume: drawn in its own panel under the candles. */\n volume?: Accessor<T, number>;\n /** How the prices and the volume are written. */\n format?: ValueFormat;\n/** How the volume is written. Default `\"compact\"`. */\n volumeFormat?: ValueFormat;\n /** How the periods are written. */\n xFormat?: CategoryFormat;\n /** Horizontal lines: a reserve price, a target. */\n thresholds?: readonly Threshold[];\n /** Zoom with the wheel and drag to pan. Default true from 40 periods. */\n zoom?: boolean;\n /** The words of the table's columns and the tooltip's rows. */\n columnLabels?: { readonly open: string; readonly high: string; readonly low: string; readonly close: string; readonly volume: string };\n}\n\nconst DEFAULT_COLUMNS = { open: \"Open\", high: \"High\", low: \"Low\", close: \"Close\", volume: \"Volume\" };\n\nexport function Candlestick<T extends Datum>(props: CandlestickProps<T>) {\n const { data, x, open, high, low, close, volume, format, volumeFormat = \"compact\", xFormat, thresholds = [], zoom, columnLabels = DEFAULT_COLUMNS } = props;\n const { locale, labels } = useSettings(props);\n const fmt = useMemo(\n () => ({\n value: valueFormatter(format, locale, labels.noValue),\n axis: valueFormatter(format, locale, labels.noValue, true),\n volume: valueFormatter(volumeFormat, locale, labels.noValue),\n category: categoryFormatter(xFormat, locale),\n share: shareFormatter(locale),\n }),\n [format, volumeFormat, xFormat, locale, labels.noValue],\n );\n const rows = useMemo(\n () =>\n data.map((d, i) => ({\n x: fmt.category(read(x, d, i)),\n o: Number(read(open, d, i)),\n h: Number(read(high, d, i)),\n l: Number(read(low, d, i)),\n c: Number(read(close, d, i)),\n v: volume ? Number(read(volume, d, i)) : null,\n })),\n [data, x, open, high, low, close, volume, fmt],\n );\n const isEmpty = rows.length === 0;\n const first = rows[0];\n const last = rows[rows.length - 1];\n const hi = Math.max(...rows.map((r) => r.h));\n const lo = Math.min(...rows.map((r) => r.l));\n const change = first && last && first.o ? last.c / first.o - 1 : null;\n const summary = isEmpty\n ? labels.empty\n : [\n fill(labels.summaryIntro, { kind: labels.kinds.candlestick, count: `${rows.length} (${first!.x} – ${last!.x})` }),\n `${capitalize(fill(labels.summaryOhlc, { open: fmt.value(first!.o), close: fmt.value(last!.c), low: fmt.value(lo), high: fmt.value(hi) }))}${change === null ? \"\" : `, ${fill(change >= 0 ? labels.summaryTrendUp : labels.summaryTrendDown, { change: fmt.share(Math.abs(change)) })}`}.`,\n ].join(\" \");\n const items: WalkItem[] = rows.map((r, i) => ({ seriesIndex: 0, dataIndex: i, text: `${r.x}: ${columnLabels.open} ${fmt.value(r.o)}, ${columnLabels.high} ${fmt.value(r.h)}, ${columnLabels.low} ${fmt.value(r.l)}, ${columnLabels.close} ${fmt.value(r.c)}` }));\n const zoomOn = zoom ?? rows.length >= 40;\n\n const build = useCallback(\n (theme: ResolvedTheme) => {\n const base = baseOption(theme, true);\n const withVolume = rows.some((r) => r.v != null);\n const xs = rows.map((r) => r.x);\n const grids = withVolume\n ? [\n { left: 8, right: 12, top: 12, bottom: \"30%\", containLabel: true },\n { left: 8, right: 12, top: \"76%\", bottom: 8, containLabel: true },\n ]\n : [{ left: 8, right: 12, top: 12, bottom: 8, containLabel: true }];\n return {\n ...base,\n tooltip: {\n ...(base.tooltip as object),\n trigger: \"axis\",\n axisPointer: { type: \"line\", lineStyle: { color: theme.axis } },\n formatter: (params: { dataIndex: number }[]) => {\n const r = rows[params[0]!.dataIndex]!;\n const up = r.c >= r.o;\n return tooltipHtml(\n r.x,\n [\n { label: columnLabels.open, value: fmt.value(r.o) },\n { label: columnLabels.high, value: fmt.value(r.h) },\n { label: columnLabels.low, value: fmt.value(r.l) },\n { label: columnLabels.close, value: fmt.value(r.c), color: up ? theme.success : theme.danger },\n ...(r.v != null ? [{ label: columnLabels.volume, value: fmt.volume(r.v) }] : []),\n ],\n );\n },\n },\n grid: grids,\n xAxis: grids.map((_, i) => ({ ...categoryAxis(theme, xs), gridIndex: i, axisLabel: { color: theme.text2, hideOverlap: true, show: i === grids.length - 1 } })),\n yAxis: [\n { ...valueAxis(theme, (v: number) => fmt.axis(v)), scale: true, gridIndex: 0 },\n ...(withVolume ? [{ ...valueAxis(theme, (v: number) => fmt.volume(v)), gridIndex: 1, splitNumber: 2 }] : []),\n ],\n dataZoom: zoomOn ? [{ type: \"inside\", xAxisIndex: grids.map((_, i) => i), start: Math.max(0, 100 - (40 / rows.length) * 100), end: 100 }] : [],\n series: [\n {\n type: \"candlestick\",\n data: rows.map((r) => [r.o, r.c, r.l, r.h]),\n barMaxWidth: 14,\n itemStyle: { color: theme.surface, color0: theme.danger, borderColor: theme.success, borderColor0: theme.danger, borderWidth: 1.5 },\n markLine: thresholds.length\n ? {\n symbol: \"none\",\n silent: true,\n data: thresholds.map((t) => ({\n yAxis: t.value,\n label: { formatter: fill(labels.summaryThreshold, { label: t.label, value: fmt.value(t.value) }), color: theme.text, position: \"insideEndTop\", fontWeight: 600 },\n lineStyle: { color: t.tone && t.tone !== \"neutral\" ? theme[t.tone === \"accent\" ? \"accent\" : t.tone] : theme.text2, type: [6, 4], width: 1.5 },\n })),\n }\n : undefined,\n },\n ...(withVolume\n ? [\n {\n type: \"bar\",\n xAxisIndex: 1,\n yAxisIndex: 1,\n barMaxWidth: 14,\n data: rows.map((r) => ({ value: r.v, itemStyle: { color: r.c >= r.o ? theme.success : theme.danger, opacity: 0.45, borderRadius: [2, 2, 0, 0] } })),\n },\n ]\n : []),\n ],\n };\n },\n [rows, fmt, thresholds, zoomOn, columnLabels, labels.summaryThreshold],\n );\n\n return (\n <EChartHost\n kind=\"candlestick\"\n frame={props}\n defaultHeight={340}\n table={{\n columns: [labels.category, columnLabels.open, columnLabels.high, columnLabels.low, columnLabels.close, ...(volume ? [columnLabels.volume] : [])],\n rows: rows.map((r) => [r.x, fmt.value(r.o), fmt.value(r.h), fmt.value(r.l), fmt.value(r.c), ...(volume ? [fmt.volume(r.v)] : [])]),\n }}\n summary={summary}\n isEmpty={isEmpty}\n engine={engine}\n build={build}\n items={items}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,aAAa,eAAe;AA+JjC;AApJJ,IAAM,SAAS,MAAM,OAAO,2BAAgC;AA+B5D,IAAM,kBAAkB,EAAE,MAAM,QAAQ,MAAM,QAAQ,KAAK,OAAO,OAAO,SAAS,QAAQ,SAAS;AAE5F,SAAS,YAA6B,OAA4B;AACvE,QAAM,EAAE,MAAM,GAAG,MAAM,MAAM,KAAK,OAAO,QAAQ,QAAQ,eAAe,WAAW,SAAS,aAAa,CAAC,GAAG,MAAM,eAAe,gBAAgB,IAAI;AACtJ,QAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,KAAK;AAC5C,QAAM,MAAM;AAAA,IACV,OAAO;AAAA,MACL,OAAO,eAAe,QAAQ,QAAQ,OAAO,OAAO;AAAA,MACpD,MAAM,eAAe,QAAQ,QAA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AAI,MAAM,UAAU,MAAM,QAAQ,SAAS,MAAM,cAAc,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,EAAE,EAAE;AAAA,YACpJ;AAAA,UACF,IACA,CAAC;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,MAAM,KAAK,YAAY,QAAQ,cAAc,OAAO,gBAAgB;AAAA,EACvE;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,OAAO;AAAA,MACP,eAAe;AAAA,MACf,OAAO;AAAA,QACL,SAAS,CAAC,OAAO,UAAU,aAAa,MAAM,aAAa,MAAM,aAAa,KAAK,aAAa,OAAO,GAAI,SAAS,CAAC,aAAa,MAAM,IAAI,CAAC,CAAE;AAAA,QAC/I,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,MAAM,EAAE,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,GAAG,GAAI,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAE,CAAC;AAAA,MACnI;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/core/shape.ts
|
|
4
|
+
var r = (n) => Math.round(n * 100) / 100;
|
|
5
|
+
function segments(points) {
|
|
6
|
+
const out = [];
|
|
7
|
+
let current = [];
|
|
8
|
+
for (const point of points) {
|
|
9
|
+
if (point) current.push(point);
|
|
10
|
+
else if (current.length) {
|
|
11
|
+
out.push(current);
|
|
12
|
+
current = [];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (current.length) out.push(current);
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
function linePath(points, curve = "monotone") {
|
|
19
|
+
if (points.length === 0) return "";
|
|
20
|
+
const [x0, y0] = points[0];
|
|
21
|
+
if (points.length === 1) return `M${r(x0)},${r(y0)}`;
|
|
22
|
+
if (curve === "step") {
|
|
23
|
+
let d2 = `M${r(x0)},${r(y0)}`;
|
|
24
|
+
for (let i = 1; i < points.length; i += 1) {
|
|
25
|
+
const [px] = points[i - 1];
|
|
26
|
+
const [x, y] = points[i];
|
|
27
|
+
const mid = (px + x) / 2;
|
|
28
|
+
d2 += `H${r(mid)}V${r(y)}H${r(x)}`;
|
|
29
|
+
}
|
|
30
|
+
return d2;
|
|
31
|
+
}
|
|
32
|
+
if (curve === "linear" || points.length === 2) return points.map(([x, y], i) => `${i ? "L" : "M"}${r(x)},${r(y)}`).join("");
|
|
33
|
+
const tangents = monotoneTangents(points);
|
|
34
|
+
let d = `M${r(x0)},${r(y0)}`;
|
|
35
|
+
for (let i = 1; i < points.length; i += 1) {
|
|
36
|
+
const [xa, ya] = points[i - 1];
|
|
37
|
+
const [xb, yb] = points[i];
|
|
38
|
+
const h = (xb - xa) / 3;
|
|
39
|
+
d += `C${r(xa + h)},${r(ya + h * tangents[i - 1])} ${r(xb - h)},${r(yb - h * tangents[i])} ${r(xb)},${r(yb)}`;
|
|
40
|
+
}
|
|
41
|
+
return d;
|
|
42
|
+
}
|
|
43
|
+
function monotoneTangents(points) {
|
|
44
|
+
const n = points.length;
|
|
45
|
+
const slopes = [];
|
|
46
|
+
for (let i = 0; i < n - 1; i += 1) {
|
|
47
|
+
const [xa, ya] = points[i];
|
|
48
|
+
const [xb, yb] = points[i + 1];
|
|
49
|
+
slopes.push(xb === xa ? 0 : (yb - ya) / (xb - xa));
|
|
50
|
+
}
|
|
51
|
+
const tangents = [slopes[0]];
|
|
52
|
+
for (let i = 1; i < n - 1; i += 1) {
|
|
53
|
+
const a = slopes[i - 1];
|
|
54
|
+
const b = slopes[i];
|
|
55
|
+
tangents.push(a * b <= 0 ? 0 : 3 * a * b / (Math.max(a, b) * 2 + Math.min(a, b)) || 0);
|
|
56
|
+
}
|
|
57
|
+
tangents.push(slopes[n - 2]);
|
|
58
|
+
return tangents;
|
|
59
|
+
}
|
|
60
|
+
function areaPath(top, base, curve = "monotone") {
|
|
61
|
+
if (top.length === 0) return "";
|
|
62
|
+
const line = linePath(top, curve);
|
|
63
|
+
const bottom = typeof base === "number" ? [top[top.length - 1], top[0]].map(([x]) => [x, base]) : [...base].reverse();
|
|
64
|
+
if (typeof base === "number") return `${line}L${r(bottom[0][0])},${r(base)}L${r(bottom[1][0])},${r(base)}Z`;
|
|
65
|
+
return `${line}L${linePath(bottom, curve).slice(1)}Z`;
|
|
66
|
+
}
|
|
67
|
+
function barPath(x, y, width, height, radius = 4, horizontal = false, negative = false) {
|
|
68
|
+
if (width <= 0 || height <= 0) return "";
|
|
69
|
+
const rad = Math.min(radius, horizontal ? height / 2 : width / 2, horizontal ? width : height);
|
|
70
|
+
if (!horizontal) {
|
|
71
|
+
if (!negative) {
|
|
72
|
+
return `M${r(x)},${r(y + height)}V${r(y + rad)}Q${r(x)},${r(y)} ${r(x + rad)},${r(y)}H${r(x + width - rad)}Q${r(x + width)},${r(y)} ${r(x + width)},${r(y + rad)}V${r(y + height)}Z`;
|
|
73
|
+
}
|
|
74
|
+
return `M${r(x)},${r(y)}V${r(y + height - rad)}Q${r(x)},${r(y + height)} ${r(x + rad)},${r(y + height)}H${r(x + width - rad)}Q${r(x + width)},${r(y + height)} ${r(x + width)},${r(y + height - rad)}V${r(y)}Z`;
|
|
75
|
+
}
|
|
76
|
+
if (!negative) {
|
|
77
|
+
return `M${r(x)},${r(y)}H${r(x + width - rad)}Q${r(x + width)},${r(y)} ${r(x + width)},${r(y + rad)}V${r(y + height - rad)}Q${r(x + width)},${r(y + height)} ${r(x + width - rad)},${r(y + height)}H${r(x)}Z`;
|
|
78
|
+
}
|
|
79
|
+
return `M${r(x + width)},${r(y)}H${r(x + rad)}Q${r(x)},${r(y)} ${r(x)},${r(y + rad)}V${r(y + height - rad)}Q${r(x)},${r(y + height)} ${r(x + rad)},${r(y + height)}H${r(x + width)}Z`;
|
|
80
|
+
}
|
|
81
|
+
function polar(cx, cy, radius, angle) {
|
|
82
|
+
return [cx + radius * Math.sin(angle), cy - radius * Math.cos(angle)];
|
|
83
|
+
}
|
|
84
|
+
function arcPath(cx, cy, inner, outer, start, end) {
|
|
85
|
+
const sweep = end - start;
|
|
86
|
+
if (sweep <= 0 || outer <= 0) return "";
|
|
87
|
+
if (sweep >= Math.PI * 2 - 1e-6) {
|
|
88
|
+
const mid = start + Math.PI;
|
|
89
|
+
return `${arcPath(cx, cy, inner, outer, start, mid)}${arcPath(cx, cy, inner, outer, mid, start + Math.PI * 2)}`;
|
|
90
|
+
}
|
|
91
|
+
const large = sweep > Math.PI ? 1 : 0;
|
|
92
|
+
const [ox0, oy0] = polar(cx, cy, outer, start);
|
|
93
|
+
const [ox1, oy1] = polar(cx, cy, outer, end);
|
|
94
|
+
let d = `M${r(ox0)},${r(oy0)}A${r(outer)},${r(outer)} 0 ${large} 1 ${r(ox1)},${r(oy1)}`;
|
|
95
|
+
if (inner > 0) {
|
|
96
|
+
const [ix1, iy1] = polar(cx, cy, inner, end);
|
|
97
|
+
const [ix0, iy0] = polar(cx, cy, inner, start);
|
|
98
|
+
d += `L${r(ix1)},${r(iy1)}A${r(inner)},${r(inner)} 0 ${large} 0 ${r(ix0)},${r(iy0)}Z`;
|
|
99
|
+
} else d += `L${r(cx)},${r(cy)}Z`;
|
|
100
|
+
return d;
|
|
101
|
+
}
|
|
102
|
+
function strokeArcPath(cx, cy, radius, start, end) {
|
|
103
|
+
if (end - start <= 0) return "";
|
|
104
|
+
const [x0, y0] = polar(cx, cy, radius, start);
|
|
105
|
+
const [x1, y1] = polar(cx, cy, radius, end);
|
|
106
|
+
return `M${r(x0)},${r(y0)}A${r(radius)},${r(radius)} 0 ${end - start > Math.PI ? 1 : 0} 1 ${r(x1)},${r(y1)}`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
segments,
|
|
111
|
+
linePath,
|
|
112
|
+
areaPath,
|
|
113
|
+
barPath,
|
|
114
|
+
polar,
|
|
115
|
+
arcPath,
|
|
116
|
+
strokeArcPath
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=chunk-OB5EFDDH.js.map
|