chartformers 1.0.36
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/README.md +112 -0
- package/dist/chartformers.css +1 -0
- package/dist/chartformers.es.js +4011 -0
- package/dist/chartformers.umd.js +37 -0
- package/dist/charts/barchart.d.ts +13 -0
- package/dist/charts/piechart.d.ts +10 -0
- package/dist/charts/stacked-barchart-variants/grouped-barchart.d.ts +3 -0
- package/dist/charts/stacked-barchart-variants/percentage-barchart.d.ts +3 -0
- package/dist/charts/stacked-barchart-variants/stacked-barchart.d.ts +7 -0
- package/dist/charts/stacked-barchart-variants/types.d.ts +21 -0
- package/dist/components/tooltip.d.ts +16 -0
- package/dist/data/constants.d.ts +96 -0
- package/dist/hooks/useContainerSize.d.ts +7 -0
- package/dist/hooks/useD3.d.ts +3 -0
- package/dist/hooks/useLayerIndex.d.ts +1 -0
- package/dist/hooks/useParentSize.d.ts +12 -0
- package/dist/hooks/useUIControls.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/types.d.ts +4 -0
- package/dist/utils.d.ts +8 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# chartformers
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/chartformers)
|
|
4
|
+
[](https://www.npmjs.com/package/chartformers)
|
|
5
|
+
[](https://bundlephobia.com/package/chartformers)
|
|
6
|
+
[](https://github.com/petrando/chartformers)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
**chartformers** is a lightweight React.js library for rendering **interactive, responsive, and animated D3.js charts**.
|
|
11
|
+

|
|
12
|
+
It is designed to simplify chart creation in modern React apps while retaining the full power of D3 under the hood.
|
|
13
|
+
|
|
14
|
+
## ✨ Features
|
|
15
|
+
- Easy-to-use React components for common chart types
|
|
16
|
+
- Smooth animated transitions
|
|
17
|
+
- Small bundle size
|
|
18
|
+
- Full typescript
|
|
19
|
+
- Responsive charts that auto-fit their containers
|
|
20
|
+
- Simple styling with the included CSS
|
|
21
|
+
- Powered by D3.js + React
|
|
22
|
+
|
|
23
|
+
## 📦 Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install chartformers@latest
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To use a bar chart component import these:
|
|
30
|
+
```bash
|
|
31
|
+
import { BarChart } from 'chartformers';
|
|
32
|
+
import 'chartformers/dist/chartformers.css';
|
|
33
|
+
```
|
|
34
|
+
Render the chart inside a container with explicit width and height:
|
|
35
|
+
```js
|
|
36
|
+
<div className="w-full h-60 md:h-96">
|
|
37
|
+
<BarChart data={[]} />
|
|
38
|
+
</div>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Example: sortable stacked bar chart
|
|
42
|
+
```js
|
|
43
|
+
import { StackedBarChart } from "chartformers";
|
|
44
|
+
import 'chartformers/dist/chartformers.css';
|
|
45
|
+
|
|
46
|
+
export default function StackedBarChartExample() {
|
|
47
|
+
export const stackData2 = [
|
|
48
|
+
{
|
|
49
|
+
label: "Initech",
|
|
50
|
+
alpha: 14900,
|
|
51
|
+
beta: 8800,
|
|
52
|
+
delta: 9600,
|
|
53
|
+
epsilon: 5400,
|
|
54
|
+
theta: 6100,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: "Umbrella",
|
|
58
|
+
alpha: 6800,
|
|
59
|
+
beta: 7400,
|
|
60
|
+
delta: 17100,
|
|
61
|
+
epsilon: 9300,
|
|
62
|
+
theta: 5200,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "Hooli",
|
|
66
|
+
alpha: 6900,
|
|
67
|
+
beta: 10400,
|
|
68
|
+
delta: 7400,
|
|
69
|
+
epsilon: 16200,
|
|
70
|
+
theta: 5700,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: "Aperture Labs",
|
|
74
|
+
alpha: 8200,
|
|
75
|
+
beta: 9100,
|
|
76
|
+
delta: 14300,
|
|
77
|
+
epsilon: 7600,
|
|
78
|
+
theta: 4600,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
label: "Cyberdyne Systems",
|
|
82
|
+
alpha: 18800,
|
|
83
|
+
beta: 9700,
|
|
84
|
+
delta: 6900,
|
|
85
|
+
epsilon: 8300,
|
|
86
|
+
theta: 6200,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: "Massive Dynamic",
|
|
90
|
+
alpha: 9600,
|
|
91
|
+
beta: 7800,
|
|
92
|
+
delta: 4900,
|
|
93
|
+
epsilon: 7200,
|
|
94
|
+
theta: 15500,
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div className="w-full h-60 md:h-96">
|
|
100
|
+
<StackedBarChart data={stackData2} />
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
For full explanations on the options and properties, with live demo:
|
|
108
|
+
## Visit the [chartformers documentation](https://chartformers-docs.vercel.app/).
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
Or you can grab the source code at:
|
|
112
|
+
## the [github repo](https://github.com/Petrando/chartformers)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._tooltip_4lu3m_3{max-width:18rem;background-color:#141414eb;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);padding:.75rem .85rem;border-radius:.5rem;box-shadow:0 4px 12px #0006;pointer-events:none;color:#f0f0f0;line-height:1.35;position:fixed}._tooltip_4lu3m_3:before,._tooltip_4lu3m_3:after{content:"";position:absolute;left:50%;transform:translate(-50%);width:0;height:0;pointer-events:none;filter:drop-shadow(0 2px 4px rgba(0,0,0,.25))}._tooltip--arrow-up_4lu3m_73:before{bottom:100%;margin-bottom:-1px;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:10px solid rgba(20,20,20,.92)}._tooltip--arrow-down_4lu3m_101:after{top:100%;margin-top:-1px;border-left:8px solid transparent;border-right:8px solid transparent;border-top:10px solid rgba(20,20,20,.92)}@media(min-width:768px){._tooltip_4lu3m_3{background-color:#141414d9}._tooltip--arrow-up_4lu3m_73:before{border-bottom-color:#141414d9}._tooltip--arrow-down_4lu3m_101:after{border-top-color:#141414d9}}@media(min-width:1024px){._tooltip_4lu3m_3{background-color:#141414bf}._tooltip--arrow-up_4lu3m_73:before{border-bottom-color:#141414bf}._tooltip--arrow-down_4lu3m_101:after{border-top-color:#141414bf}}._tooltip_4lu3m_3 ._title_4lu3m_167{font-weight:600;text-align:center;font-size:.9rem;margin-bottom:.25rem;color:#fff}@media(min-width:768px){._tooltip_4lu3m_3 ._title_4lu3m_167{font-weight:700;font-size:1rem}}text-small{font-size:.75rem;font-weight:600;margin:.15rem 0;color:#e5e5e5}@media(min-width:768px){._text-small_4lu3m_213{font-size:.875rem}}._right-label_4lu3m_225{font-size:.75rem;font-weight:600;text-align:right;margin:.15rem 0;color:#e7e7e7}@media(min-width:768px){._right-label_4lu3m_225{font-size:.875rem}}._controls-container_18scr_1{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;padding:.5rem 1rem 0;background:#fffc;border-bottom:1px solid #ddd;z-index:10;overflow:hidden}._fill-container_18scr_25{flex:1;width:100%;height:100%;overflow:hidden;overflow-y:visible}._controls-label_18scr_41{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;font-size:.9rem;font-weight:500;color:#333;height:50px;padding-top:0}._disabled_18scr_67{opacity:.5;pointer-events:none}._controls-checkbox_18scr_75{width:16px;height:16px;cursor:pointer;accent-color:#007bff}._chart-svg_18scr_89{position:relative;display:block}._rotatedAxisText_f02qn_1{text-anchor:start;transform:rotate(25deg)}._axisText_f02qn_11{text-anchor:middle;transform:rotate(0)}._legend_7ftsg_1,._legend-active_7ftsg_1{display:flex;align-items:center;min-width:14px;height:16px;gap:8px;position:absolute;cursor:pointer}._legend-rect_7ftsg_21{width:14px;height:14px;border-radius:4px;flex-shrink:0}._legend-label_7ftsg_35{white-space:nowrap}@media screen and (max-width:480px){._legend_7ftsg_1,._legend-active_7ftsg_1{font-size:12px;height:14px;gap:6px}._legend-rect_7ftsg_21{width:12px;height:12px;border-radius:3px}}._legend-active_7ftsg_1 ._legend-rect_7ftsg_21{border:1.5px solid #3b82f6}._pieSlice_7ftsg_77{stroke:#f0f8ff;stroke-width:.25}._pieSliceNotHovered_7ftsg_87{stroke:#f0f8ff;stroke-width:2;animation-name:_animateNotHovered_7ftsg_1;animation-duration:.5s;animation-fill-mode:forwards}@keyframes _animateNotHovered_7ftsg_1{0%{opacity:1}to{opacity:.55}}._pieSliceExit_7ftsg_111{stroke:#f0f8ff;stroke-width:.25;pointer-events:none;animation-name:_animateHide_7ftsg_1;animation-duration:1s;animation-fill-mode:forwards}._pieLabelEnter_7ftsg_129{font:14px Helvetica Neue,Helvetica,Arial,sans-serif;text-anchor:middle;text-shadow:0 1px 0 rgb(238,244,238),1px 0 0 rgb(238,244,238),-1px 0 0 rgb(238,244,238),0 -1px 0 rgb(238,244,238);pointer-events:none;opacity:0;animation-name:_showText_7ftsg_1;animation-duration:1s;animation-delay:1s;animation-fill-mode:forwards}._pieLabelUnhover_7ftsg_153{font:14px Helvetica Neue,Helvetica,Arial,sans-serif;text-anchor:middle;text-shadow:0 1px 0 rgb(238,244,238),1px 0 0 rgb(238,244,238),-1px 0 0 rgb(238,244,238),0 -1px 0 rgb(238,244,238);pointer-events:none;animation-name:_showText_7ftsg_1;animation-duration:1s;animation-fill-mode:forwards}@keyframes _showText_7ftsg_1{0%{opacity:0}to{opacity:1}}._pieLabelUpdate_7ftsg_183{font:14px Helvetica Neue,Helvetica,Arial,sans-serif;text-anchor:middle;text-shadow:0 1px 0 rgb(238,244,238),1px 0 0 rgb(238,244,238),-1px 0 0 rgb(238,244,238),0 -1px 0 rgb(238,244,238);pointer-events:none}._pieLabelExit_7ftsg_197{font:14px Helvetica Neue,Helvetica,Arial,sans-serif;text-anchor:middle;text-shadow:0 1px 0 rgb(238,244,238),1px 0 0 rgb(238,244,238),-1px 0 0 rgb(238,244,238),0 -1px 0 rgb(238,244,238);pointer-events:none;animation-name:_animateHide_7ftsg_1;animation-duration:.25s;animation-fill-mode:forwards}@keyframes _animateHide_7ftsg_1{0%{opacity:1}to{opacity:0}}._legends-container_brzcg_1{display:flex;flex-direction:row;align-items:center;gap:6px;position:relative;width:100%;overflow-y:hidden;overflow-x:auto;padding:0 8px;height:53px;scrollbar-width:thin;-webkit-overflow-scrolling:touch}._legends-container_brzcg_1::-webkit-scrollbar{height:6px}._legends-container_brzcg_1::-webkit-scrollbar-track{background:transparent}._legends-container_brzcg_1::-webkit-scrollbar-thumb{background:#bbb;border-radius:3px}._legend-container_brzcg_61,._legend-container-active_brzcg_61,._legend-container-inactive_brzcg_61{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;cursor:pointer;border:"1px solid #ccc";width:80px;height:53px;text-align:center;position:absolute}._legend-container_brzcg_61,._legend-container-inactive_brzcg_61{padding-top:3px}._legend-container-active_brzcg_61{padding-top:1px}._legend-rect_brzcg_105{border-radius:4px;width:16px;height:16px;border:1px solid #ccc;transition:all .2s ease-in-out}._legend-label_brzcg_121{font-size:12px;color:#333;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;text-align:center;transition:all .2s ease-in-out}@media(min-width:768px){._legend-label_brzcg_121{white-space:normal;word-break:break-word;font-size:.85rem}}._legend-container_brzcg_61:hover ._legend-label_brzcg_121{font-weight:600}._legend-container_brzcg_61:hover ._legend-rect_brzcg_105{width:18px;height:18px;border:1px solid #007bff}._legend-container-active_brzcg_61 ._legend-rect_brzcg_105{border:2px solid #007bff;width:18px;height:18px}._legend-container-active_brzcg_61 ._legend-label_brzcg_121{font-weight:700}._rect_brzcg_201,._rectCard_brzcg_201{stroke-width:1;stroke:#0d9488}._rect_brzcg_201{stroke-width:1.5}._rectLegendNotHovered_brzcg_221{stroke-width:0}._legend_brzcg_1,._rectCard_brzcg_201{transition:stroke-width;transition-duration:.25s}._rect_brzcg_201:hover{stroke-width:1.5}._rectCard_brzcg_201:hover,._legend_brzcg_1:hover{stroke-width:1}._rect_brzcg_201:hover,._rectCard_brzcg_201:hover,._legend_brzcg_1:hover,._rectHoveredLegend_brzcg_257{stroke:#3f3f46;stroke-dasharray:none}._rectCardLegendHovered_brzcg_267{stroke:#0d9488;stroke-width:1;stroke-dasharray:none}._rectLegendHovered_brzcg_279{stroke:#0d9488;stroke-width:2;stroke-dasharray:none}._rectLegendNotHovered_brzcg_221{stroke:transparent;stroke-width:2}._rotatedAxisText_brzcg_301{text-anchor:start;transform:rotate(25deg)}._axisText_brzcg_311{text-anchor:middle;transform:rotate(0)}._hoveredAxisText_brzcg_321{font-weight:700}._yAxisLabel_brzcg_335{font: 14px Roboto;fill:#0891b2}
|