@coinbase/cds-mcp-server 8.52.0 → 8.52.2
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 +8 -0
- package/mcp-docs/mobile/components/AreaChart.txt +12 -222
- package/mcp-docs/mobile/components/BarChart.txt +222 -333
- package/mcp-docs/mobile/components/CartesianChart.txt +6 -3
- package/mcp-docs/mobile/components/Checkbox.txt +2 -2
- package/mcp-docs/mobile/components/Chip.txt +74 -29
- package/mcp-docs/mobile/components/LineChart.txt +54 -134
- package/mcp-docs/mobile/components/Point.txt +1 -0
- package/mcp-docs/mobile/components/Radio.txt +2 -2
- package/mcp-docs/mobile/components/Scrubber.txt +2 -1
- package/mcp-docs/mobile/components/XAxis.txt +54 -1
- package/mcp-docs/mobile/components/YAxis.txt +3 -1
- package/mcp-docs/mobile/routes.txt +1 -1
- package/mcp-docs/web/components/AreaChart.txt +26 -118
- package/mcp-docs/web/components/BarChart.txt +228 -116
- package/mcp-docs/web/components/CartesianChart.txt +6 -3
- package/mcp-docs/web/components/Checkbox.txt +2 -2
- package/mcp-docs/web/components/Chip.txt +74 -29
- package/mcp-docs/web/components/FocusTrap.txt +2 -1
- package/mcp-docs/web/components/FullscreenModal.txt +2 -2
- package/mcp-docs/web/components/FullscreenModalLayout.txt +2 -2
- package/mcp-docs/web/components/LineChart.txt +42 -2
- package/mcp-docs/web/components/Modal.txt +67 -2
- package/mcp-docs/web/components/Point.txt +1 -0
- package/mcp-docs/web/components/Radio.txt +2 -2
- package/mcp-docs/web/components/ReferenceLine.txt +1 -1
- package/mcp-docs/web/components/Scrubber.txt +2 -1
- package/mcp-docs/web/components/Tray.txt +69 -2
- package/mcp-docs/web/components/XAxis.txt +55 -2
- package/mcp-docs/web/components/YAxis.txt +4 -2
- package/mcp-docs/web/routes.txt +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ import { BarChart } from '@coinbase/cds-mobile-visualization'
|
|
|
10
10
|
|
|
11
11
|
## Examples
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### Basics
|
|
14
14
|
|
|
15
15
|
Bar charts are a useful component for comparing discrete categories of data.
|
|
16
16
|
They are helpful for highlighting trends to users or allowing them to compare proportions at a glance.
|
|
@@ -34,6 +34,54 @@ To start, pass in a series of data to the chart.
|
|
|
34
34
|
/>
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
### Horizontal Bars
|
|
38
|
+
|
|
39
|
+
To render horizontal bars, set the `layout` prop to `"horizontal"`. In this layout, the Y axis becomes the categorical axis and the X axis becomes the value axis.
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
function HorizontalBars() {
|
|
43
|
+
const dataset = [
|
|
44
|
+
{ month: 'Jan', seoul: 21 },
|
|
45
|
+
{ month: 'Feb', seoul: 28 },
|
|
46
|
+
{ month: 'Mar', seoul: 41 },
|
|
47
|
+
{ month: 'Apr', seoul: 73 },
|
|
48
|
+
{ month: 'May', seoul: 99 },
|
|
49
|
+
{ month: 'June', seoul: 144 },
|
|
50
|
+
{ month: 'July', seoul: 319 },
|
|
51
|
+
{ month: 'Aug', seoul: 249 },
|
|
52
|
+
{ month: 'Sept', seoul: 131 },
|
|
53
|
+
{ month: 'Oct', seoul: 55 },
|
|
54
|
+
{ month: 'Nov', seoul: 48 },
|
|
55
|
+
{ month: 'Dec', seoul: 25 },
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<BarChart
|
|
60
|
+
height={400}
|
|
61
|
+
layout="horizontal"
|
|
62
|
+
series={[
|
|
63
|
+
{
|
|
64
|
+
id: 'seoul',
|
|
65
|
+
label: 'Seoul rainfall',
|
|
66
|
+
data: dataset.map((d) => d.seoul),
|
|
67
|
+
color: 'var(--color-accentBoldBlue)',
|
|
68
|
+
},
|
|
69
|
+
]}
|
|
70
|
+
showXAxis
|
|
71
|
+
showYAxis
|
|
72
|
+
xAxis={{
|
|
73
|
+
label: 'rainfall (mm)',
|
|
74
|
+
showGrid: true,
|
|
75
|
+
}}
|
|
76
|
+
yAxis={{
|
|
77
|
+
position: 'left',
|
|
78
|
+
data: dataset.map((d) => d.month),
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
37
85
|
### Multiple Series
|
|
38
86
|
|
|
39
87
|
You can also provide multiple series of data to the chart. Series will have their bars for each data point rendered side by side.
|
|
@@ -293,7 +341,7 @@ function MonthlyGainsByAsset() {
|
|
|
293
341
|
|
|
294
342
|
### Border Radius
|
|
295
343
|
|
|
296
|
-
Bars have a default
|
|
344
|
+
Bars have a default borderRadius of `4`. You can change this by setting the `borderRadius` prop on the chart.
|
|
297
345
|
|
|
298
346
|
Stacks will only round the top corners of touching bars.
|
|
299
347
|
|
|
@@ -640,7 +688,7 @@ You can also set the `barMinSize` prop to control the minimum size for individua
|
|
|
640
688
|
/>
|
|
641
689
|
```
|
|
642
690
|
|
|
643
|
-
#### Multiple
|
|
691
|
+
#### Multiple Axes
|
|
644
692
|
|
|
645
693
|
You can render bars from separate y axes in one `BarPlot`, however they aren't able to be stacked.
|
|
646
694
|
|
|
@@ -710,349 +758,113 @@ function MultipleYAxes() {
|
|
|
710
758
|
}
|
|
711
759
|
```
|
|
712
760
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
You can configure chart transitions using the `transitions` prop.
|
|
716
|
-
|
|
717
|
-
#### Customized Transitions
|
|
718
|
-
|
|
719
|
-
You can pass in a custom spring based transition to your `BarChart` for a custom update transition.
|
|
761
|
+
When using horizontal layout, you can use multiple x axes.
|
|
720
762
|
|
|
721
763
|
```jsx
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
{
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
useEffect(() => {
|
|
781
|
-
const intervalId = setInterval(() => {
|
|
782
|
-
setData((currentData) => {
|
|
783
|
-
const lastValue = currentData[currentData.length - 1] ?? minValue;
|
|
784
|
-
const newValue = generateNextValue(lastValue);
|
|
785
|
-
|
|
786
|
-
return [...currentData.slice(1), newValue];
|
|
787
|
-
});
|
|
788
|
-
}, updateInterval);
|
|
789
|
-
|
|
790
|
-
return () => clearInterval(intervalId);
|
|
791
|
-
}, []);
|
|
792
|
-
|
|
793
|
-
const series = seriesConfig.map((config, index) => ({
|
|
794
|
-
id: config.id,
|
|
795
|
-
label: config.label,
|
|
796
|
-
color: config.color,
|
|
797
|
-
data: index === 0 ? data : Array(dataCount).fill(seriesSpacing),
|
|
798
|
-
}));
|
|
799
|
-
|
|
800
|
-
return (
|
|
801
|
-
<BarChart
|
|
802
|
-
stacked
|
|
803
|
-
height={300}
|
|
804
|
-
series={series}
|
|
805
|
-
transitions={{
|
|
806
|
-
enter: { type: 'spring', stiffness: 700, damping: 80 },
|
|
807
|
-
update: { type: 'spring', stiffness: 700, damping: 20 },
|
|
808
|
-
}}
|
|
809
|
-
inset={0}
|
|
810
|
-
showYAxis
|
|
811
|
-
yAxis={{
|
|
812
|
-
showGrid: true,
|
|
813
|
-
width: 0,
|
|
814
|
-
tickLabelFormatter: () => '',
|
|
815
|
-
domain: { min: 0, max: domainLimit },
|
|
816
|
-
}}
|
|
817
|
-
/>
|
|
818
|
-
);
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
return <AnimatedChart />;
|
|
822
|
-
}
|
|
764
|
+
<CartesianChart
|
|
765
|
+
layout="horizontal"
|
|
766
|
+
legend
|
|
767
|
+
height={400}
|
|
768
|
+
inset={{ top: 8, bottom: 8, left: 0, right: 0 }}
|
|
769
|
+
legendPosition="bottom"
|
|
770
|
+
series={[
|
|
771
|
+
{
|
|
772
|
+
id: 'revenue',
|
|
773
|
+
label: 'Revenue ($)',
|
|
774
|
+
data: [455, 520, 380, 455, 285, 235],
|
|
775
|
+
xAxisId: 'revenue',
|
|
776
|
+
color: 'var(--color-accentBoldYellow)',
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
id: 'profitMargin',
|
|
780
|
+
label: 'Profit Margin (%)',
|
|
781
|
+
data: [23, 20, 16, 38, 12, 9],
|
|
782
|
+
xAxisId: 'profitMargin',
|
|
783
|
+
color: 'var(--color-fgPositive)',
|
|
784
|
+
},
|
|
785
|
+
]}
|
|
786
|
+
xAxis={[
|
|
787
|
+
{
|
|
788
|
+
id: 'revenue',
|
|
789
|
+
domain: { min: 0 },
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
id: 'profitMargin',
|
|
793
|
+
domain: { min: 0, max: 100 },
|
|
794
|
+
},
|
|
795
|
+
]}
|
|
796
|
+
yAxis={{
|
|
797
|
+
data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
|
|
798
|
+
scaleType: 'band',
|
|
799
|
+
}}
|
|
800
|
+
>
|
|
801
|
+
<YAxis showLine showTickMarks position="left" />
|
|
802
|
+
<XAxis
|
|
803
|
+
showGrid
|
|
804
|
+
showLine
|
|
805
|
+
showTickMarks
|
|
806
|
+
axisId="revenue"
|
|
807
|
+
position="top"
|
|
808
|
+
requestedTickCount={5}
|
|
809
|
+
height={60}
|
|
810
|
+
tickLabelFormatter={(value) => `$${value}k`}
|
|
811
|
+
/>
|
|
812
|
+
<XAxis
|
|
813
|
+
showLine
|
|
814
|
+
showTickMarks
|
|
815
|
+
axisId="profitMargin"
|
|
816
|
+
position="bottom"
|
|
817
|
+
requestedTickCount={5}
|
|
818
|
+
tickLabelFormatter={(value) => `${value}%`}
|
|
819
|
+
/>
|
|
820
|
+
<BarPlot />
|
|
821
|
+
</CartesianChart>
|
|
823
822
|
```
|
|
824
823
|
|
|
825
|
-
|
|
824
|
+
### Animations
|
|
826
825
|
|
|
827
|
-
You can
|
|
826
|
+
You can configure chart transitions using the `transitions` prop.
|
|
828
827
|
|
|
829
828
|
```jsx
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
const seriesSpacing = 30;
|
|
839
|
-
|
|
840
|
-
const seriesConfig = [
|
|
841
|
-
{ id: 'red', label: 'Red', color: `rgb(${theme.spectrum.red40})` },
|
|
842
|
-
{ id: 'orange', label: 'Orange', color: `rgb(${theme.spectrum.orange40})` },
|
|
843
|
-
{ id: 'yellow', label: 'Yellow', color: `rgb(${theme.spectrum.yellow40})` },
|
|
844
|
-
{ id: 'green', label: 'Green', color: `rgb(${theme.spectrum.green40})` },
|
|
845
|
-
{ id: 'blue', label: 'Blue', color: `rgb(${theme.spectrum.blue40})` },
|
|
846
|
-
{ id: 'indigo', label: 'Indigo', color: `rgb(${theme.spectrum.indigo40})` },
|
|
847
|
-
{ id: 'purple', label: 'Purple', color: `rgb(${theme.spectrum.purple40})` },
|
|
848
|
-
];
|
|
849
|
-
|
|
850
|
-
const domainLimit = maxValue + seriesConfig.length * seriesSpacing;
|
|
851
|
-
|
|
852
|
-
function generateNextValue(previousValue) {
|
|
853
|
-
const range = maxStep - minStep;
|
|
854
|
-
const offset = Math.random() * range + minStep;
|
|
855
|
-
|
|
856
|
-
let direction;
|
|
857
|
-
if (previousValue >= maxValue) {
|
|
858
|
-
direction = -1;
|
|
859
|
-
} else if (previousValue <= minValue) {
|
|
860
|
-
direction = 1;
|
|
861
|
-
} else {
|
|
862
|
-
direction = Math.random() < 0.5 ? -1 : 1;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
let newValue = previousValue + offset * direction;
|
|
866
|
-
newValue = Math.max(minValue, Math.min(maxValue, newValue));
|
|
867
|
-
return newValue;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
function generateInitialData() {
|
|
871
|
-
const data = [];
|
|
872
|
-
|
|
873
|
-
let previousValue = minValue + Math.random() * (maxValue - minValue);
|
|
874
|
-
data.push(previousValue);
|
|
875
|
-
|
|
876
|
-
for (let i = 1; i < dataCount; i++) {
|
|
877
|
-
const newValue = generateNextValue(previousValue);
|
|
878
|
-
data.push(newValue);
|
|
879
|
-
previousValue = newValue;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
return data;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
function AnimatedChart() {
|
|
886
|
-
const [data, setData] = useState(generateInitialData);
|
|
887
|
-
|
|
888
|
-
useEffect(() => {
|
|
889
|
-
const intervalId = setInterval(() => {
|
|
890
|
-
setData((currentData) => {
|
|
891
|
-
const lastValue = currentData[currentData.length - 1] ?? minValue;
|
|
892
|
-
const newValue = generateNextValue(lastValue);
|
|
893
|
-
|
|
894
|
-
return [...currentData.slice(1), newValue];
|
|
895
|
-
});
|
|
896
|
-
}, updateInterval);
|
|
897
|
-
|
|
898
|
-
return () => clearInterval(intervalId);
|
|
899
|
-
}, []);
|
|
829
|
+
<BarChart
|
|
830
|
+
{...props}
|
|
831
|
+
transitions={{
|
|
832
|
+
enter: { type: 'spring', stiffness: 700, damping: 80 },
|
|
833
|
+
update: { type: 'spring', stiffness: 700, damping: 20 },
|
|
834
|
+
}}
|
|
835
|
+
/>
|
|
836
|
+
```
|
|
900
837
|
|
|
901
|
-
|
|
902
|
-
id: config.id,
|
|
903
|
-
label: config.label,
|
|
904
|
-
color: config.color,
|
|
905
|
-
data: index === 0 ? data : Array(dataCount).fill(seriesSpacing),
|
|
906
|
-
}));
|
|
838
|
+
Also, you can toggle animations by setting `animate` to `true` or `false`.
|
|
907
839
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
animate={false}
|
|
911
|
-
stacked
|
|
912
|
-
height={300}
|
|
913
|
-
series={series}
|
|
914
|
-
inset={0}
|
|
915
|
-
showYAxis
|
|
916
|
-
yAxis={{
|
|
917
|
-
showGrid: true,
|
|
918
|
-
width: 0,
|
|
919
|
-
tickLabelFormatter: () => '',
|
|
920
|
-
domain: { min: 0, max: domainLimit },
|
|
921
|
-
}}
|
|
922
|
-
/>
|
|
923
|
-
);
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
return <AnimatedChart />;
|
|
927
|
-
}
|
|
840
|
+
```jsx
|
|
841
|
+
<BarChart {...props} animate={false} />
|
|
928
842
|
```
|
|
929
843
|
|
|
930
844
|
#### Stagger Delay
|
|
931
845
|
|
|
932
|
-
You can
|
|
846
|
+
You can set `staggerDelay` (in milliseconds) on bar transitions to create a cascading animation effect where bars animate sequentially from left to right. The delay is distributed across bars based on their horizontal position — the leftmost bar starts immediately, and the rightmost bar starts after the full `staggerDelay` duration.
|
|
933
847
|
|
|
934
848
|
```jsx
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
<HStack gap={2}>
|
|
942
|
-
<Button
|
|
943
|
-
compact
|
|
944
|
-
onPress={() => {
|
|
945
|
-
setData(data.map(() => Math.floor(Math.random() * 150) + 20));
|
|
946
|
-
}}
|
|
947
|
-
>
|
|
948
|
-
Update Data
|
|
949
|
-
</Button>
|
|
950
|
-
<Button compact onPress={() => setKey((k) => k + 1)}>
|
|
951
|
-
Reset
|
|
952
|
-
</Button>
|
|
953
|
-
</HStack>
|
|
954
|
-
|
|
955
|
-
<Text font="label">Staggered Enter</Text>
|
|
956
|
-
<BarChart
|
|
957
|
-
key={`enter-${key}`}
|
|
958
|
-
height={150}
|
|
959
|
-
series={[{ id: 'data', data }]}
|
|
960
|
-
transitions={{
|
|
961
|
-
enter: { type: 'timing', duration: 750, staggerDelay: 250 },
|
|
962
|
-
update: null,
|
|
963
|
-
}}
|
|
964
|
-
showXAxis
|
|
965
|
-
showYAxis
|
|
966
|
-
xAxis={{
|
|
967
|
-
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
968
|
-
}}
|
|
969
|
-
yAxis={{
|
|
970
|
-
showGrid: true,
|
|
971
|
-
domain: { max: 250 },
|
|
972
|
-
}}
|
|
973
|
-
/>
|
|
974
|
-
|
|
975
|
-
<Text font="label">Staggered Update</Text>
|
|
976
|
-
<BarChart
|
|
977
|
-
height={150}
|
|
978
|
-
series={[{ id: 'data', data }]}
|
|
979
|
-
transitions={{
|
|
980
|
-
enter: null,
|
|
981
|
-
update: { type: 'spring', stiffness: 300, damping: 20, staggerDelay: 150 },
|
|
982
|
-
}}
|
|
983
|
-
showXAxis
|
|
984
|
-
showYAxis
|
|
985
|
-
xAxis={{
|
|
986
|
-
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
987
|
-
}}
|
|
988
|
-
yAxis={{
|
|
989
|
-
showGrid: true,
|
|
990
|
-
domain: { max: 250 },
|
|
991
|
-
}}
|
|
992
|
-
/>
|
|
993
|
-
</VStack>
|
|
994
|
-
);
|
|
995
|
-
}
|
|
849
|
+
<BarChart
|
|
850
|
+
{...props}
|
|
851
|
+
transitions={{
|
|
852
|
+
enter: { type: 'spring', stiffness: 700, damping: 80, staggerDelay: 250 },
|
|
853
|
+
}}
|
|
854
|
+
/>
|
|
996
855
|
```
|
|
997
856
|
|
|
998
857
|
#### Delay
|
|
999
858
|
|
|
1000
|
-
You can
|
|
859
|
+
You can set `delay` (in milliseconds) on transitions to add a pause before the animation starts.
|
|
1001
860
|
|
|
1002
861
|
```jsx
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
Reset
|
|
1010
|
-
</Button>
|
|
1011
|
-
|
|
1012
|
-
<Text font="label">No Delay</Text>
|
|
1013
|
-
<BarChart
|
|
1014
|
-
key={`no-delay-${key}`}
|
|
1015
|
-
height={150}
|
|
1016
|
-
series={[{ id: 'data', data: [45, 80, 120, 95, 150, 110, 85] }]}
|
|
1017
|
-
transitions={{
|
|
1018
|
-
enter: { type: 'timing', duration: 500 },
|
|
1019
|
-
}}
|
|
1020
|
-
showXAxis
|
|
1021
|
-
xAxis={{
|
|
1022
|
-
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
1023
|
-
}}
|
|
1024
|
-
/>
|
|
1025
|
-
|
|
1026
|
-
<Text font="label">500ms Delay</Text>
|
|
1027
|
-
<BarChart
|
|
1028
|
-
key={`delay-${key}`}
|
|
1029
|
-
height={150}
|
|
1030
|
-
series={[{ id: 'data', data: [45, 80, 120, 95, 150, 110, 85] }]}
|
|
1031
|
-
transitions={{
|
|
1032
|
-
enter: { type: 'timing', duration: 500, delay: 500 },
|
|
1033
|
-
}}
|
|
1034
|
-
showXAxis
|
|
1035
|
-
xAxis={{
|
|
1036
|
-
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
1037
|
-
}}
|
|
1038
|
-
/>
|
|
1039
|
-
|
|
1040
|
-
<Text font="label">Stagger + Delay</Text>
|
|
1041
|
-
<BarChart
|
|
1042
|
-
key={`stagger-delay-${key}`}
|
|
1043
|
-
height={150}
|
|
1044
|
-
series={[{ id: 'data', data: [45, 80, 120, 95, 150, 110, 85] }]}
|
|
1045
|
-
transitions={{
|
|
1046
|
-
enter: { type: 'spring', stiffness: 400, damping: 15, delay: 300, staggerDelay: 200 },
|
|
1047
|
-
}}
|
|
1048
|
-
showXAxis
|
|
1049
|
-
xAxis={{
|
|
1050
|
-
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
1051
|
-
}}
|
|
1052
|
-
/>
|
|
1053
|
-
</VStack>
|
|
1054
|
-
);
|
|
1055
|
-
}
|
|
862
|
+
<BarChart
|
|
863
|
+
{...props}
|
|
864
|
+
transitions={{
|
|
865
|
+
enter: { type: 'spring', stiffness: 700, damping: 80, delay: 250 },
|
|
866
|
+
}}
|
|
867
|
+
/>
|
|
1056
868
|
```
|
|
1057
869
|
|
|
1058
870
|
### Composed Examples
|
|
@@ -1291,7 +1103,7 @@ function SunlightChartExample() {
|
|
|
1291
1103
|
borderRadius={0}
|
|
1292
1104
|
seriesIds={['sunlight']}
|
|
1293
1105
|
transitions={{
|
|
1294
|
-
enter: { type: 'spring', stiffness: 700, damping: 40, staggerDelay:
|
|
1106
|
+
enter: { type: 'spring', stiffness: 700, damping: 40, staggerDelay: 1000 },
|
|
1295
1107
|
}}
|
|
1296
1108
|
/>
|
|
1297
1109
|
</CartesianChart>
|
|
@@ -1303,6 +1115,86 @@ function SunlightChartExample() {
|
|
|
1303
1115
|
}
|
|
1304
1116
|
```
|
|
1305
1117
|
|
|
1118
|
+
#### Buy vs Sell
|
|
1119
|
+
|
|
1120
|
+
You can combine a horizontal BarChart with a custom legend to create a buy vs sell chart.
|
|
1121
|
+
|
|
1122
|
+
```tsx
|
|
1123
|
+
function BuyVsSellExample() {
|
|
1124
|
+
function BuyVsSellLegend({ buy, sell }: { buy: number; sell: number }) {
|
|
1125
|
+
return (
|
|
1126
|
+
<HStack gap={1} justifyContent="space-between">
|
|
1127
|
+
<DefaultLegendEntry
|
|
1128
|
+
label={
|
|
1129
|
+
<Text font="legal" color="fgMuted">
|
|
1130
|
+
{buy}% bought
|
|
1131
|
+
</Text>
|
|
1132
|
+
}
|
|
1133
|
+
color="var(--color-fgPositive)"
|
|
1134
|
+
/>
|
|
1135
|
+
<DefaultLegendEntry
|
|
1136
|
+
label={
|
|
1137
|
+
<Text font="legal" color="fgMuted">
|
|
1138
|
+
{sell}% sold
|
|
1139
|
+
</Text>
|
|
1140
|
+
}
|
|
1141
|
+
color="var(--color-fgNegative)"
|
|
1142
|
+
/>
|
|
1143
|
+
</HStack>
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
function BuyVsSellChart({
|
|
1148
|
+
buy,
|
|
1149
|
+
sell,
|
|
1150
|
+
animate = false,
|
|
1151
|
+
borderRadius = 3,
|
|
1152
|
+
height = 6,
|
|
1153
|
+
inset = 0,
|
|
1154
|
+
layout = 'horizontal',
|
|
1155
|
+
stackGap = 4,
|
|
1156
|
+
xAxis,
|
|
1157
|
+
yAxis,
|
|
1158
|
+
...props
|
|
1159
|
+
}: Omit<BarChartProps, 'series'> & { buy: number; sell: number }) {
|
|
1160
|
+
return (
|
|
1161
|
+
<VStack gap={1.5}>
|
|
1162
|
+
<BarChart
|
|
1163
|
+
animate={animate}
|
|
1164
|
+
roundBaseline
|
|
1165
|
+
stacked
|
|
1166
|
+
borderRadius={borderRadius}
|
|
1167
|
+
height={height}
|
|
1168
|
+
inset={inset}
|
|
1169
|
+
layout={layout}
|
|
1170
|
+
series={[
|
|
1171
|
+
{
|
|
1172
|
+
id: 'buy',
|
|
1173
|
+
data: [buy],
|
|
1174
|
+
color: 'var(--color-fgPositive)',
|
|
1175
|
+
legendShape: 'circle',
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
id: 'sell',
|
|
1179
|
+
data: [sell],
|
|
1180
|
+
color: 'var(--color-fgNegative)',
|
|
1181
|
+
legendShape: 'circle',
|
|
1182
|
+
},
|
|
1183
|
+
]}
|
|
1184
|
+
stackGap={stackGap}
|
|
1185
|
+
xAxis={{ domainLimit: 'strict', ...xAxis }}
|
|
1186
|
+
yAxis={{ categoryPadding: 0, ...yAxis }}
|
|
1187
|
+
{...props}
|
|
1188
|
+
/>
|
|
1189
|
+
<BuyVsSellLegend buy={buy} sell={sell} />
|
|
1190
|
+
</VStack>
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
return <BuyVsSellChart buy={76} sell={24} />;
|
|
1195
|
+
}
|
|
1196
|
+
```
|
|
1197
|
+
|
|
1306
1198
|
## Props
|
|
1307
1199
|
|
|
1308
1200
|
| Prop | Type | Required | Default | Description |
|
|
@@ -1319,15 +1211,11 @@ function SunlightChartExample() {
|
|
|
1319
1211
|
| `background` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
1320
1212
|
| `barMinSize` | `number` | No | `-` | Minimum size for individual bars in the stack. |
|
|
1321
1213
|
| `barPadding` | `number` | No | `0.1` | Padding between bar groups (0-1). |
|
|
1322
|
-
| `borderBottomLeftRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
1323
|
-
| `borderBottomRightRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
1324
1214
|
| `borderBottomWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
1325
1215
|
| `borderColor` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
1326
1216
|
| `borderEndWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
1327
|
-
| `borderRadius` | `
|
|
1217
|
+
| `borderRadius` | `number` | No | `4` | Border radius for the bar. |
|
|
1328
1218
|
| `borderStartWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
1329
|
-
| `borderTopLeftRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
1330
|
-
| `borderTopRightRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
1331
1219
|
| `borderTopWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
1332
1220
|
| `borderWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
1333
1221
|
| `bordered` | `boolean` | No | `-` | Add a border around all sides of the box. |
|
|
@@ -1360,6 +1248,7 @@ function SunlightChartExample() {
|
|
|
1360
1248
|
| `inset` | `number \| Partial<ChartInset>` | No | `-` | Inset around the entire chart (outside the axes). |
|
|
1361
1249
|
| `justifyContent` | `flex-start \| flex-end \| center \| space-between \| space-around \| space-evenly` | No | `-` | - |
|
|
1362
1250
|
| `key` | `Key \| null` | No | `-` | - |
|
|
1251
|
+
| `layout` | `horizontal \| vertical` | No | `'vertical'` | Chart layout - describes the direction bars/areas grow. - vertical (default): Bars grow vertically. X is category axis, Y is value axis. - horizontal: Bars grow horizontally. Y is category axis, X is value axis. |
|
|
1363
1252
|
| `left` | `string \| number` | No | `-` | - |
|
|
1364
1253
|
| `legend` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Whether to show the legend or a custom legend element. - true renders the default Legend component - A React element renders that element as the legend - false or omitted hides the legend |
|
|
1365
1254
|
| `legendAccessibilityLabel` | `string` | No | `'Legend'` | Accessibility label for the legend group. |
|
|
@@ -1425,8 +1314,8 @@ function SunlightChartExample() {
|
|
|
1425
1314
|
| `transitions` | `{ enter?: BarTransition \| null; update?: BarTransition \| null \| undefined; } \| undefined` | No | `transitions = {{ enter: { type: 'spring', stiffness: 900, damping: 120, staggerDelay: 250 }, update: { type: 'spring', stiffness: 900, damping: 120 } }}` | Transition configuration for enter and update animations. |
|
|
1426
1315
|
| `userSelect` | `none \| auto \| text \| contain \| all` | No | `-` | - |
|
|
1427
1316
|
| `width` | `string \| number` | No | `-` | - |
|
|
1428
|
-
| `xAxis` | `(Partial<
|
|
1429
|
-
| `yAxis` | `(Partial<
|
|
1317
|
+
| `xAxis` | `(Partial<CartesianAxisConfigProps> & AxisBaseProps & { GridLineComponent?: LineComponent; LineComponent?: LineComponent \| undefined; TickMarkLineComponent?: LineComponent \| undefined; tickLabelFormatter?: ((value: number) => ChartTextChildren) \| undefined; TickLabelComponent?: AxisTickLabelComponent \| undefined; } & { axisId?: string \| undefined; position?: top \| bottom \| undefined; height?: number \| undefined; }) \| undefined` | No | `-` | Configuration for x-axis. Accepts axis config and axis props. To show the axis, set showXAxis to true. |
|
|
1318
|
+
| `yAxis` | `(Partial<CartesianAxisConfigProps> & AxisBaseProps & { GridLineComponent?: LineComponent; LineComponent?: LineComponent \| undefined; TickMarkLineComponent?: LineComponent \| undefined; tickLabelFormatter?: ((value: number) => ChartTextChildren) \| undefined; TickLabelComponent?: AxisTickLabelComponent \| undefined; } & { axisId?: string \| undefined; position?: left \| right \| undefined; width?: number \| undefined; }) \| undefined` | No | `-` | Configuration for y-axis. Accepts axis config and axis props. To show the axis, set showYAxis to true. |
|
|
1430
1319
|
| `zIndex` | `number` | No | `-` | - |
|
|
1431
1320
|
|
|
1432
1321
|
|