Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Charts): Add the Data Visualization tab with pages Getting Started, Chart Types, and Chart Demos. Add new examples in the storybook. #1544

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/feat-add-new-charts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- Uncomment when adding new charts. Issues: #1054, #1055, #1056 -->
<!-- ---
'@react-magma/charts': minor
---

feat(CarbonCharts): Add new charts: `Histogram`, `Scatter`, `Step`, `SparkLine`, `Boxplot`, `Bullet`, `Combo`, `Bubble`, `Gauge`, `Meter`, and `Radar`. -->
5 changes: 5 additions & 0 deletions .changeset/feat-charts-documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-magma-docs': patch
---

feat(Charts): Add the `Data Visualization` tab with pages `Getting Started`, `Chart Types` and `Chart Demos`.
29 changes: 28 additions & 1 deletion packages/charts/src/components/CarbonChart/CarbonChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import {
PieChart,
SimpleBarChart,
StackedBarChart,
RadarChart,
BoxplotChart,
BubbleChart,
BulletChart,
GaugeChart,
HistogramChart,
MeterChart,
ScatterChart,
ComboChart,
} from '@carbon/charts-react';
import './styles.min.css';

Expand All @@ -21,10 +30,19 @@ export enum CarbonChartType {
bar = 'bar',
barGrouped = 'barGrouped',
barStacked = 'barStacked',
boxplot = 'boxplot',
bubble = 'bubble',
bullet = 'bullet',
donut = 'donut',
gauge = 'gauge',
histogram = 'histogram',
line = 'line',
pie = 'pie',
lollipop = 'lollipop',
meter = 'meter',
pie = 'pie',
radar = 'radar',
scatter = 'scatter',
combo = 'combo',
}

export interface CarbonChartProps extends React.HTMLAttributes<HTMLDivElement> {
Expand Down Expand Up @@ -460,6 +478,15 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
line: LineChart,
lollipop: LollipopChart,
pie: PieChart,
radar: RadarChart,
boxplot: BoxplotChart,
bubble: BubbleChart,
bullet: BulletChart,
gauge: GaugeChart,
histogram: HistogramChart,
meter: MeterChart,
scatter: ScatterChart,
Comment on lines +481 to +488
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to go through all of these charts and update the custom styles. @orion-cengage will need to review them and provide feedback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also merge as is (after the release) and use the separate tickets to address the styling.

combo: ComboChart,
};

function buildColors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,105 @@ AreaTimeSeries.args = {
},
};

export const AreaDiscreteDomain = Template.bind({});
AreaDiscreteDomain.args = {
isInverse: false,
type: CarbonChartType.area,
dataSet: [
{
group: 'Dataset 1',
value: 10000,
key: 'a',
},
{
group: 'Dataset 1',
value: 65000,
key: 'b',
},
{
group: 'Dataset 1',
value: 10000,
key: 'c',
},
{
group: 'Dataset 1',
value: 49213,
key: 'd',
},
{
group: 'Dataset 1',
value: 51213,
key: 'e',
},
{
group: 'Dataset 2',
value: 20000,
key: 'a',
},
{
group: 'Dataset 2',
value: 25000,
key: 'b',
},
{
group: 'Dataset 2',
value: 60000,
key: 'c',
},
{
group: 'Dataset 2',
value: 30213,
key: 'd',
},
{
group: 'Dataset 2',
value: 55213,
key: 'e',
},
{
group: 'Dataset 3',
value: 30000,
key: 'a',
},
{
group: 'Dataset 3',
value: 20000,
key: 'b',
},
{
group: 'Dataset 3',
value: 40000,
key: 'c',
},
{
group: 'Dataset 3',
value: 60213,
key: 'd',
},
{
group: 'Dataset 3',
value: 25213,
key: 'e',
},
],
options: {
title: 'Discrete Domain',
axes: {
bottom: {
title: '2023 Annual Sales Figures',
mapsTo: 'key',
scaleType: 'labels',
},
left: {
mapsTo: 'value',
title: 'Conversion rate',
scaleType: 'linear',
},
},
height: '400px',
},
};

export const BoundedAreaTimeSeriesNaturalCurve = Template.bind({});
BoundedAreaTimeSeriesNaturalCurve.args = {
isInverse: false,
Expand Down Expand Up @@ -268,6 +367,179 @@ BoundedAreaTimeSeriesNaturalCurve.args = {
},
};

export const AreaMultipleBoundedAreasNaturalCurve = Template.bind({});
AreaMultipleBoundedAreasNaturalCurve.args = {
isInverse: false,
type: CarbonChartType.area,
dataSet: [
{
group: 'Dataset 1',
date: '2023-01-01',
value: 47263,
min: 40000,
max: 50000,
},
{
group: 'Dataset 1',
date: '2023-01-05',
value: 14178,
min: 10000,
max: 20000,
},
{
group: 'Dataset 1',
date: '2023-01-08',
value: 23094,
min: 10000,
max: 25000,
},
{
group: 'Dataset 1',
date: '2023-01-13',
value: 45281,
min: 42000,
max: 50000,
},
{
group: 'Dataset 1',
date: '2023-01-19',
value: -63954,
min: -70000,
max: -10000,
},
],
options: {
title: 'Multiple Bounded Areas (Natural Curve)',
legend: {
enabled: false,
},
bounds: {
upperBoundMapsTo: 'max',
lowerBoundMapsTo: 'min',
},
axes: {
bottom: {
title: '2023 Annual Sales Figures',
mapsTo: 'date',
scaleType: 'time',
highlights: {
highlightStartMapsTo: 'startHighlight',
highlightEndMapsTo: 'endHighlight',
labelMapsTo: 'label',
data: [
{
startHighlight: new Date(2023, 0, 3, 0, 0, 0),
label: 'Custom formatter',
endHighlight: new Date(2023, 0, 8, 0, 0, 0),
},
{
startHighlight: new Date(2023, 0, 13, 0, 0, 0),
label: 'Custom formatter',
endHighlight: new Date(2023, 0, 14, 0, 0, 0),
},
],
},
},
left: {
mapsTo: 'value',
scaleType: 'linear',
},
},
curve: 'curveNatural',
height: '400px',
},
};

export const AreaMultipleBoundedAreasNaturalCurveZoomBarEnabled = Template.bind(
{}
);
AreaMultipleBoundedAreasNaturalCurveZoomBarEnabled.args = {
isInverse: false,
type: CarbonChartType.area,
dataSet: [
{
group: 'Dataset 1',
date: '2023-01-01',
value: 47263,
min: 40000,
max: 50000,
},
{
group: 'Dataset 1',
date: '2023-01-05',
value: 14178,
min: 10000,
max: 20000,
},
{
group: 'Dataset 1',
date: '2023-01-08',
value: 23094,
min: 10000,
max: 25000,
},
{
group: 'Dataset 1',
date: '2023-01-13',
value: 45281,
min: 42000,
max: 50000,
},
{
group: 'Dataset 1',
date: '2023-01-19',
value: -63954,
min: -70000,
max: -10000,
},
],
options: {
title: 'Multiple Bounded Areas (Natural Curve) - Zoom bar enabled',
legend: {
enabled: false,
},
bounds: {
upperBoundMapsTo: 'max',
lowerBoundMapsTo: 'min',
},
axes: {
bottom: {
title: '2023 Annual Sales Figures',
mapsTo: 'date',
scaleType: 'time',
highlights: {
highlightStartMapsTo: 'startHighlight',
highlightEndMapsTo: 'endHighlight',
labelMapsTo: 'label',
data: [
{
startHighlight: new Date(2023, 0, 3, 0, 0, 0),
label: 'Custom formatter',
endHighlight: new Date(2023, 0, 8, 0, 0, 0),
},
{
startHighlight: new Date(2023, 0, 13, 0, 0, 0),
label: 'Custom formatter',
endHighlight: new Date(2023, 0, 14, 0, 0, 0),
},
],
},
},
left: {
mapsTo: 'value',
scaleType: 'linear',
},
},
curve: 'curveNatural',
height: '400px',
zoomBar: {
top: {
enabled: true,
},
},
},
};

export const AreaSkeleton = Template.bind({});
AreaSkeleton.args = {
isInverse: false,
Expand Down
Loading
Loading