@orchidsoftware/charts 0.0.1
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/CHANGELOG.md +71 -0
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/dist/core/Chart.js +1 -0
- package/dist/core/Chart.js.map +1 -0
- package/dist/core/ChartData.js +1 -0
- package/dist/core/ChartData.js.map +1 -0
- package/dist/core/ChartDefinition.js +1 -0
- package/dist/core/ChartDefinition.js.map +1 -0
- package/dist/core/ChartSelection.js +1 -0
- package/dist/core/ChartSelection.js.map +1 -0
- package/dist/core/ChartTooltip.js +1 -0
- package/dist/core/ChartTooltip.js.map +1 -0
- package/dist/core/InteractionController.js +1 -0
- package/dist/core/InteractionController.js.map +1 -0
- package/dist/core/NormalizeAnnotations.js +1 -0
- package/dist/core/NormalizeAnnotations.js.map +1 -0
- package/dist/core/Options.js +1 -0
- package/dist/core/Options.js.map +1 -0
- package/dist/core/builders/Builder.js +1 -0
- package/dist/core/builders/Builder.js.map +1 -0
- package/dist/core/builders/BuilderArguments.js +1 -0
- package/dist/core/builders/BuilderArguments.js.map +1 -0
- package/dist/core/builders/BuilderScopes.js +1 -0
- package/dist/core/builders/BuilderScopes.js.map +1 -0
- package/dist/core/builders/BuilderState.js +1 -0
- package/dist/core/builders/BuilderState.js.map +1 -0
- package/dist/core/builders/BuilderValidation.js +1 -0
- package/dist/core/builders/BuilderValidation.js.map +1 -0
- package/dist/core/builders/CartesianBuilders.js +1 -0
- package/dist/core/builders/CartesianBuilders.js.map +1 -0
- package/dist/core/builders/CompositionBuilders.js +1 -0
- package/dist/core/builders/CompositionBuilders.js.map +1 -0
- package/dist/core/builders/TemporalBuilders.js +1 -0
- package/dist/core/builders/TemporalBuilders.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/renderers/ChartRendering.js +1 -0
- package/dist/renderers/ChartRendering.js.map +1 -0
- package/dist/renderers/LegendRenderer.js +1 -0
- package/dist/renderers/LegendRenderer.js.map +1 -0
- package/dist/renderers/SvgSurface.js +1 -0
- package/dist/renderers/SvgSurface.js.map +1 -0
- package/dist/renderers/cartesian/CartesianAxesRenderer.js +1 -0
- package/dist/renderers/cartesian/CartesianAxesRenderer.js.map +1 -0
- package/dist/renderers/cartesian/CartesianInspectorRenderer.js +1 -0
- package/dist/renderers/cartesian/CartesianInspectorRenderer.js.map +1 -0
- package/dist/renderers/cartesian/CartesianLayout.js +1 -0
- package/dist/renderers/cartesian/CartesianLayout.js.map +1 -0
- package/dist/renderers/cartesian/CartesianRendering.js +1 -0
- package/dist/renderers/cartesian/CartesianRendering.js.map +1 -0
- package/dist/renderers/cartesian/CartesianSeriesRendering.js +1 -0
- package/dist/renderers/cartesian/CartesianSeriesRendering.js.map +1 -0
- package/dist/renderers/composition/AggregationRendering.js +1 -0
- package/dist/renderers/composition/AggregationRendering.js.map +1 -0
- package/dist/renderers/composition/Composition.js +1 -0
- package/dist/renderers/composition/Composition.js.map +1 -0
- package/dist/renderers/composition/PolarAreaRendering.js +1 -0
- package/dist/renderers/composition/PolarAreaRendering.js.map +1 -0
- package/dist/renderers/composition/RadarRendering.js +1 -0
- package/dist/renderers/composition/RadarRendering.js.map +1 -0
- package/dist/renderers/temporal/HeatmapRendering.js +1 -0
- package/dist/renderers/temporal/HeatmapRendering.js.map +1 -0
- package/dist/renderers/temporal/TimesheetLayout.js +1 -0
- package/dist/renderers/temporal/TimesheetLayout.js.map +1 -0
- package/dist/renderers/temporal/TimesheetRendering.js +1 -0
- package/dist/renderers/temporal/TimesheetRendering.js.map +1 -0
- package/dist/support/Constants.js +1 -0
- package/dist/support/Constants.js.map +1 -0
- package/dist/support/Dom.js +1 -0
- package/dist/support/Dom.js.map +1 -0
- package/dist/support/Normalize.js +2 -0
- package/dist/support/Normalize.js.map +1 -0
- package/dist/support/Validation.js +1 -0
- package/dist/support/Validation.js.map +1 -0
- package/dist/support/geometry/CartesianGeometry.js +1 -0
- package/dist/support/geometry/CartesianGeometry.js.map +1 -0
- package/dist/support/geometry/Scale.js +1 -0
- package/dist/support/geometry/Scale.js.map +1 -0
- package/dist/support/geometry/SectorGeometry.js +1 -0
- package/dist/support/geometry/SectorGeometry.js.map +1 -0
- package/dist/support/presentation/Formatting.js +1 -0
- package/dist/support/presentation/Formatting.js.map +1 -0
- package/dist/support/presentation/Presentation.js +1 -0
- package/dist/support/presentation/Presentation.js.map +1 -0
- package/dist/support/presentation/Time.js +1 -0
- package/dist/support/presentation/Time.js.map +1 -0
- package/docs/api-reference.md +322 -0
- package/docs/bar.md +110 -0
- package/docs/bubble.md +76 -0
- package/docs/chart-types.md +35 -0
- package/docs/customization.md +178 -0
- package/docs/donut.md +55 -0
- package/docs/exporting.md +87 -0
- package/docs/frameworks.md +203 -0
- package/docs/getting-started.md +121 -0
- package/docs/heatmap.md +95 -0
- package/docs/line.md +148 -0
- package/docs/mixed.md +114 -0
- package/docs/percentage.md +48 -0
- package/docs/pie.md +58 -0
- package/docs/polar-area.md +46 -0
- package/docs/radar.md +49 -0
- package/docs/readme.md +37 -0
- package/docs/scatter.md +83 -0
- package/docs/timesheet.md +125 -0
- package/docs/updates-and-interaction.md +124 -0
- package/package.json +133 -0
- package/src/index.d.ts +481 -0
- package/src/styles.css +350 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
This page takes you from an empty element to a responsive product chart.
|
|
4
|
+
|
|
5
|
+
## Install Charts2
|
|
6
|
+
|
|
7
|
+
Install the package with npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @orchidsoftware/charts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Charts2 ships as an ES module. Import the chart you need and its stylesheet:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
17
|
+
import "@orchidsoftware/charts/style.css";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Render your first chart
|
|
21
|
+
|
|
22
|
+
Add a host element to your page:
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<div id="revenue"></div>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Create a line chart inside it:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
32
|
+
import "@orchidsoftware/charts/style.css";
|
|
33
|
+
|
|
34
|
+
const revenue = LineChart.make("#revenue")
|
|
35
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
36
|
+
.dataset("Revenue", [42, 48, 57, 63])
|
|
37
|
+
.render();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Charts2 uses the width of the host element and redraws when that width changes.
|
|
41
|
+
The default height, palette, axes, legend, labels, and tooltip are ready to use.
|
|
42
|
+
|
|
43
|
+
## Understand the chain
|
|
44
|
+
|
|
45
|
+
Every chart follows the same path:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
make(parent) → add data → render()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- `make(parent)` accepts a CSS selector or an `Element`.
|
|
52
|
+
- Data methods describe the values to show. Most charts use `labels()` and
|
|
53
|
+
`dataset()`.
|
|
54
|
+
- `render()` mounts the chart and returns its small runtime API.
|
|
55
|
+
|
|
56
|
+
Methods before `render()` shape the whole chart:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
60
|
+
|
|
61
|
+
const revenue = LineChart.make("#revenue")
|
|
62
|
+
.title("Monthly revenue")
|
|
63
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
64
|
+
.dataset("Revenue", [42, 48, 57, 63])
|
|
65
|
+
.colors(["#2563eb"])
|
|
66
|
+
.height(300)
|
|
67
|
+
.smooth()
|
|
68
|
+
.gradient()
|
|
69
|
+
.render();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Add another series
|
|
73
|
+
|
|
74
|
+
Call `dataset()` again. Names appear in the legend and tooltip.
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
78
|
+
|
|
79
|
+
const revenue = LineChart.make("#revenue")
|
|
80
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
81
|
+
.dataset("Actual", [42, 48, 57, 63])
|
|
82
|
+
.dataset("Plan", [45, 50, 55, 65])
|
|
83
|
+
.colors(["#2563eb", "#94a3b8"])
|
|
84
|
+
.render();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Each dataset must contain one value for every label.
|
|
88
|
+
|
|
89
|
+
## Use Charts2 without a build step
|
|
90
|
+
|
|
91
|
+
For a plain HTML page, use an import map and load the stylesheet with a
|
|
92
|
+
`<link>`. Pin an exact version in production.
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<div id="chart"></div>
|
|
96
|
+
|
|
97
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@orchidsoftware/charts@0.0.1/src/styles.css" />
|
|
98
|
+
|
|
99
|
+
<script type="importmap">
|
|
100
|
+
{
|
|
101
|
+
"imports": {
|
|
102
|
+
"@orchidsoftware/charts": "https://cdn.jsdelivr.net/npm/@orchidsoftware/charts@0.0.1/dist/index.js"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<script type="module">
|
|
108
|
+
import { BarChart } from "@orchidsoftware/charts";
|
|
109
|
+
|
|
110
|
+
BarChart.make("#chart").labels(["Starter", "Team", "Business"]).dataset("Accounts", [84, 46, 21]).render();
|
|
111
|
+
</script>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Native browsers load CSS through `<link>`; a JavaScript `import` cannot load the
|
|
115
|
+
stylesheet without a bundler.
|
|
116
|
+
|
|
117
|
+
## Where to go next
|
|
118
|
+
|
|
119
|
+
- Pick a visualization in [Chart types](./chart-types.md).
|
|
120
|
+
- Make it fit your interface in [Customization](./customization.md).
|
|
121
|
+
- Connect it to changing data in [Updates and interaction](./updates-and-interaction.md).
|
package/docs/heatmap.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Calendar heatmaps
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Calendar heatmaps show activity day by day. Color intensity makes recurring
|
|
6
|
+
patterns, quiet periods, and unusually active days easy to find.
|
|
7
|
+
|
|
8
|
+
## Creating a calendar heatmap
|
|
9
|
+
|
|
10
|
+
Point keys use the timezone-free `YYYY-MM-DD` form:
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { HeatmapChart } from "@orchidsoftware/charts";
|
|
14
|
+
import "@orchidsoftware/charts/style.css";
|
|
15
|
+
|
|
16
|
+
const chart = HeatmapChart.make("#activity")
|
|
17
|
+
.points({
|
|
18
|
+
"2026-08-26": 3,
|
|
19
|
+
"2026-08-27": 7,
|
|
20
|
+
"2026-08-28": 4,
|
|
21
|
+
"2026-08-29": 9,
|
|
22
|
+
})
|
|
23
|
+
.render();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Point values must be finite numbers. Zero is valid and represents an inactive
|
|
27
|
+
day.
|
|
28
|
+
|
|
29
|
+
## Displaying a fixed range
|
|
30
|
+
|
|
31
|
+
Without `range()`, Charts2 derives the calendar range from the first and last
|
|
32
|
+
point. Use `range(start, end)` when the chart should also show inactive days
|
|
33
|
+
outside that interval:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import { HeatmapChart } from "@orchidsoftware/charts";
|
|
37
|
+
|
|
38
|
+
HeatmapChart.make("#activity")
|
|
39
|
+
.range(new Date("2026-01-01T00:00:00Z"), new Date("2026-12-31T00:00:00Z"))
|
|
40
|
+
.points(activity)
|
|
41
|
+
.render();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Naming the count
|
|
45
|
+
|
|
46
|
+
`countLabel()` names the unit in the tooltip and accessible text:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import { HeatmapChart } from "@orchidsoftware/charts";
|
|
50
|
+
|
|
51
|
+
HeatmapChart.make("#activity").points(activity).countLabel("contributions").render();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Color scale
|
|
55
|
+
|
|
56
|
+
For a heatmap, `colors()` defines a low-to-high intensity scale. Unlike a
|
|
57
|
+
series palette, the supplied colors are used once rather than cycled:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import { HeatmapChart } from "@orchidsoftware/charts";
|
|
61
|
+
|
|
62
|
+
HeatmapChart.make("#activity")
|
|
63
|
+
.points(activity)
|
|
64
|
+
.colors(["#eff6ff", "#bfdbfe", "#60a5fa", "#2563eb", "#1e3a8a"])
|
|
65
|
+
.render();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Rounded day cells
|
|
69
|
+
|
|
70
|
+
Use `radius()` to round each day cell in CSS pixels:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
import { HeatmapChart } from "@orchidsoftware/charts";
|
|
74
|
+
|
|
75
|
+
HeatmapChart.make("#activity").points(activity).radius(2).render();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Formatting the tooltip
|
|
79
|
+
|
|
80
|
+
The heatmap tooltip provides `formatDate()` and `formatValue()`:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
import { HeatmapChart } from "@orchidsoftware/charts";
|
|
84
|
+
|
|
85
|
+
HeatmapChart.make("#activity")
|
|
86
|
+
.points(activity)
|
|
87
|
+
.tooltip((tooltip) => {
|
|
88
|
+
tooltip.formatDate((date) => date.toLocaleDateString()).formatValue((value) => `${value} contributions`);
|
|
89
|
+
})
|
|
90
|
+
.render();
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Calendar heatmaps also support the shared `title()`, `description()`,
|
|
94
|
+
`ariaLabel()`, `width()`, `height()`, `colors()`, `tooltip()`, and `onSelect()`
|
|
95
|
+
methods. See [Customization](./customization.md) for details.
|
package/docs/line.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Line charts
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Line charts are a good choice when the shape of change matters: revenue over
|
|
6
|
+
time, response time by hour, or the growth of several plans. A line chart may
|
|
7
|
+
contain one or more datasets, and every dataset must contain one value for each
|
|
8
|
+
label.
|
|
9
|
+
|
|
10
|
+
## Creating a line chart
|
|
11
|
+
|
|
12
|
+
Import `LineChart`, choose a host element with `make()`, add the labels and
|
|
13
|
+
values, and call `render()`:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
17
|
+
import "@orchidsoftware/charts/style.css";
|
|
18
|
+
|
|
19
|
+
const chart = LineChart.make("#revenue")
|
|
20
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
21
|
+
.dataset("Revenue", [42, 48, 57, 63])
|
|
22
|
+
.render();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The value returned by `render()` is the mounted chart. You may use it to
|
|
26
|
+
[update the data](./updates-and-interaction.md#replace-the-data), react to a
|
|
27
|
+
selection, or export the SVG.
|
|
28
|
+
|
|
29
|
+
## Multiple lines
|
|
30
|
+
|
|
31
|
+
Call `dataset()` once for each line. Named datasets appear in the legend and
|
|
32
|
+
tooltip:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
36
|
+
|
|
37
|
+
LineChart.make("#revenue")
|
|
38
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
39
|
+
.dataset("Actual", [42, 48, 57, 63])
|
|
40
|
+
.dataset("Plan", [45, 50, 55, 65])
|
|
41
|
+
.colors(["#2563eb", "#94a3b8"])
|
|
42
|
+
.render();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Smooth lines
|
|
46
|
+
|
|
47
|
+
The `smooth()` method rounds the path between points. It applies to every line
|
|
48
|
+
in the chart:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
52
|
+
|
|
53
|
+
LineChart.make("#signups")
|
|
54
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
55
|
+
.dataset("Signups", [120, 156, 184, 231])
|
|
56
|
+
.smooth()
|
|
57
|
+
.render();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
You may pass a boolean when the choice is conditional:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
64
|
+
|
|
65
|
+
LineChart.make("#signups").dataset(values).smooth(shouldSmooth).render();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Gradient and area fills
|
|
69
|
+
|
|
70
|
+
The `gradient()` method fills the area beneath every visible line with a
|
|
71
|
+
fading version of its color:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
75
|
+
|
|
76
|
+
LineChart.make("#revenue")
|
|
77
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
78
|
+
.dataset("Revenue", [42, 48, 57, 63])
|
|
79
|
+
.gradient()
|
|
80
|
+
.render();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
To control the fade, pass the starting and ending opacity:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
87
|
+
|
|
88
|
+
LineChart.make("#revenue")
|
|
89
|
+
.dataset([42, 48, 57, 63])
|
|
90
|
+
.gradient({ fromOpacity: 0.35, toOpacity: 0.02 })
|
|
91
|
+
.render();
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use `area()` for a solid area fill. Use `line(false)` when the filled shape
|
|
95
|
+
should appear without its line:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
99
|
+
|
|
100
|
+
LineChart.make("#usage").dataset([18, 24, 31, 39]).area().line(false).render();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Points and stroke
|
|
104
|
+
|
|
105
|
+
Use `dots(false)` to hide points, `dotSize()` to resize them, and
|
|
106
|
+
`strokeWidth()` to change the line width:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
110
|
+
|
|
111
|
+
LineChart.make("#latency").dataset([180, 210, 195, 205]).dots(false).dotSize(5).strokeWidth(3).render();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Compact line charts
|
|
115
|
+
|
|
116
|
+
`frameless()` hides the axes, grid, direct values, legend, tooltip, and points
|
|
117
|
+
unless you explicitly enable one of them. This is useful for a chart embedded
|
|
118
|
+
inside a small metric card:
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
122
|
+
|
|
123
|
+
LineChart.make("#revenue-trend").dataset([42, 48, 57, 63]).height(90).gradient().frameless().render();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Customizing one line
|
|
127
|
+
|
|
128
|
+
Chart-level methods are the usual choice. When one line needs different
|
|
129
|
+
styling, configure only that dataset:
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
import { LineChart } from "@orchidsoftware/charts";
|
|
133
|
+
|
|
134
|
+
LineChart.make("#revenue")
|
|
135
|
+
.dataset("Actual", [42, 48, 57], (line) => {
|
|
136
|
+
line.color("#2563eb").smooth().gradient().strokeWidth(3);
|
|
137
|
+
})
|
|
138
|
+
.dataset("Plan", [45, 50, 55], (line) => {
|
|
139
|
+
line.color("#94a3b8").dots(false).opacity(0.7);
|
|
140
|
+
})
|
|
141
|
+
.render();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
A line dataset supports `color()`, `opacity()`, `formatValue()`, `smooth()`,
|
|
145
|
+
`gradient()`, `dots()`, `dotSize()`, `line()`, `area()`, and `strokeWidth()`.
|
|
146
|
+
|
|
147
|
+
Line charts also support the shared [cartesian presentation, formatting, and
|
|
148
|
+
annotation methods](./customization.md).
|
package/docs/mixed.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Mixed charts
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Mixed charts place line, bar, and scatter datasets on the same cartesian scale.
|
|
6
|
+
They are useful for comparing an actual value with a plan, or showing events
|
|
7
|
+
alongside a trend.
|
|
8
|
+
|
|
9
|
+
## Creating a mixed chart
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { MixedChart } from "@orchidsoftware/charts";
|
|
13
|
+
import "@orchidsoftware/charts/style.css";
|
|
14
|
+
|
|
15
|
+
const chart = MixedChart.make("#plan")
|
|
16
|
+
.labels(["Jan", "Feb", "Mar", "Apr"])
|
|
17
|
+
.bar("Actual", [42, 48, 57, 63])
|
|
18
|
+
.line("Plan", [45, 50, 55, 65])
|
|
19
|
+
.render();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Unlike other series charts, mixed charts use a method named after the desired
|
|
23
|
+
dataset type.
|
|
24
|
+
|
|
25
|
+
## Line datasets
|
|
26
|
+
|
|
27
|
+
Use `line(name, values, colorOrCallback?)` to add a line:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { MixedChart } from "@orchidsoftware/charts";
|
|
31
|
+
|
|
32
|
+
MixedChart.make("#plan")
|
|
33
|
+
.labels(["Jan", "Feb", "Mar"])
|
|
34
|
+
.line("Plan", [45, 50, 55], (line) => {
|
|
35
|
+
line.color("#2563eb").smooth().dots(false).strokeWidth(3);
|
|
36
|
+
})
|
|
37
|
+
.render();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The callback supports every line-dataset method: `color()`, `opacity()`,
|
|
41
|
+
`formatValue()`, `smooth()`, `gradient()`, `dots()`, `dotSize()`, `line()`,
|
|
42
|
+
`area()`, and `strokeWidth()`.
|
|
43
|
+
|
|
44
|
+
## Bar datasets
|
|
45
|
+
|
|
46
|
+
Use `bar(name, values, colorOrCallback?)` to add bars:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import { MixedChart } from "@orchidsoftware/charts";
|
|
50
|
+
|
|
51
|
+
MixedChart.make("#plan")
|
|
52
|
+
.labels(["Jan", "Feb", "Mar"])
|
|
53
|
+
.bar("Actual", [42, 48, 57], (bars) => {
|
|
54
|
+
bars.color("#8b5cf6").radius(5);
|
|
55
|
+
})
|
|
56
|
+
.render();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The callback supports `color()`, `opacity()`, `formatValue()`, and `radius()`.
|
|
60
|
+
|
|
61
|
+
## Scatter datasets
|
|
62
|
+
|
|
63
|
+
Use `scatter(name, values, colorOrCallback?)` to add individual observations:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
import { MixedChart } from "@orchidsoftware/charts";
|
|
67
|
+
|
|
68
|
+
MixedChart.make("#plan")
|
|
69
|
+
.scatter("Releases", [
|
|
70
|
+
{ x: 0, y: 42 },
|
|
71
|
+
{ x: 2, y: 57 },
|
|
72
|
+
])
|
|
73
|
+
.render();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Scatter values may be `{ x, y }` points or numbers. The callback supports
|
|
77
|
+
`color()`, `opacity()`, and `formatValue()`.
|
|
78
|
+
|
|
79
|
+
## Gradient fills
|
|
80
|
+
|
|
81
|
+
Call `gradient()` on the chart to add a fading fill to every line dataset:
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import { MixedChart } from "@orchidsoftware/charts";
|
|
85
|
+
|
|
86
|
+
MixedChart.make("#plan")
|
|
87
|
+
.labels(["Jan", "Feb", "Mar"])
|
|
88
|
+
.bar("Actual", [42, 48, 57])
|
|
89
|
+
.line("Plan", [45, 50, 55])
|
|
90
|
+
.gradient({ fromOpacity: 0.3, toOpacity: 0.02 })
|
|
91
|
+
.render();
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use a line callback when only one line should have a gradient.
|
|
95
|
+
|
|
96
|
+
## Advanced dataset input
|
|
97
|
+
|
|
98
|
+
The named methods are the clearest way to add mixed data. When your data is
|
|
99
|
+
already stored as objects, `dataset()` also accepts an explicit `chartType`:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import { MixedChart } from "@orchidsoftware/charts";
|
|
103
|
+
|
|
104
|
+
MixedChart.make("#plan")
|
|
105
|
+
.dataset({ chartType: "bar", name: "Actual", values: [42, 48, 57] })
|
|
106
|
+
.dataset({ chartType: "line", name: "Plan", values: [45, 50, 55] })
|
|
107
|
+
.render();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The `chartType` must be `"line"`, `"bar"`, or `"scatter"`. Its value also
|
|
111
|
+
determines which methods are available in an optional dataset callback.
|
|
112
|
+
|
|
113
|
+
Mixed charts also support the shared [cartesian presentation, formatting, and
|
|
114
|
+
annotation methods](./customization.md).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Percentage charts
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Percentage charts show composition as a compact horizontal strip. They are a
|
|
6
|
+
good fit for storage, plan distribution, progress allocation, and other places
|
|
7
|
+
where a full pie or donut would use too much space.
|
|
8
|
+
|
|
9
|
+
## Creating a percentage chart
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { PercentageChart } from "@orchidsoftware/charts";
|
|
13
|
+
import "@orchidsoftware/charts/style.css";
|
|
14
|
+
|
|
15
|
+
const chart = PercentageChart.make("#storage")
|
|
16
|
+
.labels(["Used", "Available"])
|
|
17
|
+
.dataset([68, 32])
|
|
18
|
+
.colors(["#2563eb", "#e2e8f0"])
|
|
19
|
+
.render();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Values must be non-negative and at least one value must be positive. Charts2
|
|
23
|
+
calculates each category's share from the supplied values; they do not need to
|
|
24
|
+
sum to 100.
|
|
25
|
+
|
|
26
|
+
## Limiting segments
|
|
27
|
+
|
|
28
|
+
Use `maxSlices()` to keep the largest categories and combine the remainder:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { PercentageChart } from "@orchidsoftware/charts";
|
|
32
|
+
|
|
33
|
+
PercentageChart.make("#traffic").labels(sources).dataset(visits).maxSlices(5).render();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Rounded segments
|
|
37
|
+
|
|
38
|
+
The `radius()` method rounds segment corners in CSS pixels:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
import { PercentageChart } from "@orchidsoftware/charts";
|
|
42
|
+
|
|
43
|
+
PercentageChart.make("#storage").labels(["Used", "Available"]).dataset([68, 32]).radius(6).render();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Percentage charts also support `formatLabel()`, `formatValue()`,
|
|
47
|
+
`legend(false)`, and the shared [colors, dimensions, tooltip, and selection
|
|
48
|
+
methods](./customization.md).
|
package/docs/pie.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Pie charts
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Pie charts show how a whole is divided into a small number of categories. They
|
|
6
|
+
work best when the differences between slices are clear and precise comparison
|
|
7
|
+
is not required.
|
|
8
|
+
|
|
9
|
+
## Creating a pie chart
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { PieChart } from "@orchidsoftware/charts";
|
|
13
|
+
import "@orchidsoftware/charts/style.css";
|
|
14
|
+
|
|
15
|
+
const chart = PieChart.make("#plans")
|
|
16
|
+
.labels(["Starter", "Team", "Business"])
|
|
17
|
+
.dataset([58, 31, 11])
|
|
18
|
+
.colors(["#2563eb", "#8b5cf6", "#f59e0b"])
|
|
19
|
+
.render();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Pie values must be non-negative and at least one value must be positive.
|
|
23
|
+
|
|
24
|
+
## Limiting slices
|
|
25
|
+
|
|
26
|
+
Use `maxSlices()` when incoming data may contain more categories than the chart
|
|
27
|
+
can communicate clearly. Charts2 keeps the largest slices and combines the
|
|
28
|
+
remainder:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { PieChart } from "@orchidsoftware/charts";
|
|
32
|
+
|
|
33
|
+
PieChart.make("#sources").labels(sources).dataset(visits).maxSlices(5).render();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Starting angle
|
|
37
|
+
|
|
38
|
+
`startAngle()` rotates the chart by the given number of degrees:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
import { PieChart } from "@orchidsoftware/charts";
|
|
42
|
+
|
|
43
|
+
PieChart.make("#plans").labels(plans).dataset(accounts).startAngle(-90).render();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Slice spacing and corners
|
|
47
|
+
|
|
48
|
+
Use `padAngle()` to place space between slices and `cornerRadius()` to soften
|
|
49
|
+
their corners:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { PieChart } from "@orchidsoftware/charts";
|
|
53
|
+
|
|
54
|
+
PieChart.make("#plans").labels(plans).dataset(accounts).padAngle(2).cornerRadius(4).render();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Pie charts also support `formatLabel()`, `formatValue()`, `legend(false)`, and
|
|
58
|
+
the shared [colors, dimensions, tooltip, and selection methods](./customization.md).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Polar area charts
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Polar area charts give every category the same angle and encode its value with
|
|
6
|
+
radius. Use one when the circular form is useful and magnitude—not a share of a
|
|
7
|
+
fixed whole—is the main comparison.
|
|
8
|
+
|
|
9
|
+
## Creating a polar area chart
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { PolarAreaChart } from "@orchidsoftware/charts";
|
|
13
|
+
import "@orchidsoftware/charts/style.css";
|
|
14
|
+
|
|
15
|
+
const chart = PolarAreaChart.make("#sources")
|
|
16
|
+
.labels(["Search", "Direct", "Partners", "Social"])
|
|
17
|
+
.dataset([48, 31, 22, 15])
|
|
18
|
+
.colors(["#2563eb", "#8b5cf6", "#f59e0b", "#16a34a"])
|
|
19
|
+
.render();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Values must be non-negative and at least one value must be positive.
|
|
23
|
+
|
|
24
|
+
## Segment spacing
|
|
25
|
+
|
|
26
|
+
`padAngle()` adds space between segments, measured in degrees:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { PolarAreaChart } from "@orchidsoftware/charts";
|
|
30
|
+
|
|
31
|
+
PolarAreaChart.make("#sources").labels(sources).dataset(visits).padAngle(3).render();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Rounded segments
|
|
35
|
+
|
|
36
|
+
Use `cornerRadius()` to round segment corners in CSS pixels:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import { PolarAreaChart } from "@orchidsoftware/charts";
|
|
40
|
+
|
|
41
|
+
PolarAreaChart.make("#sources").labels(sources).dataset(visits).padAngle(3).cornerRadius(4).render();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Polar area charts also support `formatLabel()`, `formatValue()`,
|
|
45
|
+
`legend(false)`, and the shared [colors, dimensions, tooltip, and selection
|
|
46
|
+
methods](./customization.md).
|
package/docs/radar.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Radar charts
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Radar charts compare profiles across several measures that share a common
|
|
6
|
+
scale. They work best with a small number of measures and datasets.
|
|
7
|
+
|
|
8
|
+
## Creating a radar chart
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
import { RadarChart } from "@orchidsoftware/charts";
|
|
12
|
+
import "@orchidsoftware/charts/style.css";
|
|
13
|
+
|
|
14
|
+
const chart = RadarChart.make("#quality")
|
|
15
|
+
.labels(["Speed", "Reliability", "Ease", "Support", "Value"])
|
|
16
|
+
.dataset("Current", [78, 91, 86, 74, 82])
|
|
17
|
+
.render();
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Radar values must be non-negative. Every dataset must contain one value for
|
|
21
|
+
each label.
|
|
22
|
+
|
|
23
|
+
## Comparing profiles
|
|
24
|
+
|
|
25
|
+
Add another named dataset to compare profiles on the same scale:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { RadarChart } from "@orchidsoftware/charts";
|
|
29
|
+
|
|
30
|
+
RadarChart.make("#quality")
|
|
31
|
+
.labels(["Speed", "Reliability", "Ease", "Support", "Value"])
|
|
32
|
+
.dataset("Current", [78, 91, 86, 74, 82])
|
|
33
|
+
.dataset("Previous", [69, 84, 80, 70, 76])
|
|
34
|
+
.colors(["#2563eb", "#94a3b8"])
|
|
35
|
+
.render();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Stroke width
|
|
39
|
+
|
|
40
|
+
Use `strokeWidth()` to change the outline of every profile:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { RadarChart } from "@orchidsoftware/charts";
|
|
44
|
+
|
|
45
|
+
RadarChart.make("#quality").labels(metrics).dataset(scores).strokeWidth(3).render();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Radar charts also support `formatLabel()`, `formatValue()`, `legend(false)`,
|
|
49
|
+
and the shared [colors, dimensions, tooltip, and selection methods](./customization.md).
|