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

Add chart animations to Area, Bar, Line, and (opacity-only) Scatter #224

Open
wants to merge 121 commits into
base: byu-team-animations
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
ab5e3f7
chore: add timer value to signals
gideontonkinson Feb 14, 2024
c421d9f
fix: remove debug from chart.story.tsx
gideontonkinson Feb 14, 2024
9e09a53
chore: add tests for timer signal
gideontonkinson Feb 14, 2024
b8f65df
fix: remove debug
gideontonkinson Feb 14, 2024
30a0af4
feat: add timer value to signals (#127)
gideontonkinson Feb 14, 2024
84b075f
feat: add previous data table to data
gideontonkinson Feb 16, 2024
20288a6
fix: fix broken test
gideontonkinson Feb 16, 2024
41d7141
fix: remove debug
gideontonkinson Feb 19, 2024
3b09115
Gtonkinson/animations (#132)
gideontonkinson Feb 19, 2024
c8fc4df
Merge remote to local
Judd2000 Feb 20, 2024
3bcd803
Animations implement from zero and using previous data
Judd2000 Feb 20, 2024
4876f79
Animations Between Data: starting implementation
Judd2000 Feb 21, 2024
b4405e3
Animations finished new-old data animations for line chart
Judd2000 Feb 23, 2024
d36b674
Animations remove todo
Judd2000 Feb 23, 2024
df8c5fb
Animations remove todo
Judd2000 Feb 23, 2024
c1fc3d7
Animations added static line animations and removed lint issues
Judd2000 Feb 23, 2024
a7897f1
Animations stacked bar and areas animations added)
Judd2000 Feb 26, 2024
c349cd5
Animations dodged bar experimentaion
Judd2000 Feb 28, 2024
496e62f
Resolve merge conflicts
gideontonkinson Feb 28, 2024
248d2d2
resolve merge conflicts
gideontonkinson Feb 28, 2024
43a29ff
Animations add dodged bar-specific animations as well as hide labels …
Judd2000 Feb 29, 2024
d96361f
Animations lint fixes
Judd2000 Feb 29, 2024
e736d42
Animations use structuredClone instead of JSON.stringify
Judd2000 Feb 29, 2024
a3c56d9
Merge pull request #153 from adobe/nathaniel-judd/byu-team/animations
Judd2000 Mar 1, 2024
00ec648
Add animation easing
jacob-hart Mar 1, 2024
e7bcc86
Merge pull request #160 from adobe/jacob-hart/byu-team/easing
Judd2000 Mar 1, 2024
af1a1e6
Animations added global mock for structuredClone
Judd2000 Mar 1, 2024
56b39a5
Merge remote to local
Judd2000 Mar 1, 2024
6159cad
Test: Add animations story
gideontonkinson Mar 1, 2024
644ec12
Animations added extra check for animating between datasets that they…
Judd2000 Mar 1, 2024
53c2c06
animation storybook
gideontonkinson Mar 4, 2024
560d4e1
merge in changes
gideontonkinson Mar 4, 2024
7702d7a
Animations fixed previousData causing strange animations
Judd2000 Mar 6, 2024
18bba7a
Merge branch 'animations' of github.com:adobe/react-spectrum-charts i…
gideontonkinson Mar 6, 2024
fb885e6
feat: add animations storybook
gideontonkinson Mar 6, 2024
4b849ed
Add animation spec backwards compatibility with existing tests (#169)
jacob-hart Mar 8, 2024
956e421
Animations fix previousData, add filter
Judd2000 Mar 8, 2024
8174613
Merge branch 'animations' of https://github.com/adobe/react-spectrum-…
Judd2000 Mar 8, 2024
5cc4c2a
merge in main animations
gideontonkinson Mar 8, 2024
9832018
failed to remove merge conflict
gideontonkinson Mar 8, 2024
e56701b
missed an additional merge conflict
gideontonkinson Mar 8, 2024
c7cc0a1
Test: Add testing for the animation stories
gideontonkinson Mar 8, 2024
83bad13
feat: add more tests
gideontonkinson Mar 8, 2024
abe7efd
Animations fix (most) remaining tests
Judd2000 Mar 8, 2024
14285ba
merge in main branch
gideontonkinson Mar 11, 2024
acb855e
Merge "main" into "animations"
Judd2000 Mar 11, 2024
1aa7490
Animation resolve new test data expected lengths
Judd2000 Mar 11, 2024
9329ade
Animations disable animations for the dodged trellis bar
Judd2000 Mar 13, 2024
cbea9a1
Animations re-add semicolon
Judd2000 Mar 13, 2024
2bf86f8
Animations disabled animations on animation-supported chart types
Judd2000 Mar 13, 2024
0fca769
Animations remove unused import
Judd2000 Mar 13, 2024
5c53a88
Merge "main" into "animations"
Judd2000 Mar 14, 2024
8905b7e
Merge "main" into "animations"
Judd2000 Mar 18, 2024
7174ba9
Merge branch 'main' into njudd/byu-team/animations
Judd2000 Mar 18, 2024
628ee82
Animations fix tests from main
Judd2000 Mar 18, 2024
151cbe2
Animations added interface to allow certain tests to override animati…
Judd2000 Mar 18, 2024
b7bcc62
Animations move VegaChart out to useMemo
Judd2000 Mar 19, 2024
a2f9e66
Animations removed console log:
Judd2000 Mar 19, 2024
1c7c546
Animations njudd remove comments
Judd2000 Mar 19, 2024
42ece8e
Animations useState var for spec, when popoverIsOpen set spec to no a…
Judd2000 Mar 20, 2024
e785232
Animations trying to fix rerendering
Judd2000 Mar 21, 2024
6aa151e
Change animation duration (#198)
jacob-hart Mar 24, 2024
b6a0b91
njudd/animations added animateFromZero state variable to RscChart and…
Judd2000 Mar 27, 2024
23345a7
Animations sounarcloud code smells
Judd2000 Mar 27, 2024
aa2e00c
Made animateFromZero optional
Judd2000 Mar 27, 2024
e217127
Merge pull request #207 from adobe/njudd/byu-team/animations
Judd2000 Mar 29, 2024
fc12bef
Animations removed console.logs
Judd2000 Apr 1, 2024
c3ee2b8
Animations made area and line charts have tooltips and highlight mark…
Judd2000 Apr 1, 2024
78d712a
Removed unused vars
Judd2000 Apr 1, 2024
46b5251
Minor build fixes
Judd2000 Apr 1, 2024
44cac56
Animations made area and line charts have tooltips and highlight mark…
Judd2000 Apr 3, 2024
05d1de3
Add animations to window and regression trendlines (#212)
jacob-hart Apr 3, 2024
f15f413
Add Opacity animation functionality to line, bar, scatter, trendline,…
agardn87 Apr 3, 2024
7fdca27
Gtonkinson/animations (#225)
gideontonkinson Apr 4, 2024
2a9de92
Animations-3 fixed issues with stacked bars and stacked areas - added…
Judd2000 Apr 5, 2024
b68afae
Merge "adam/byu-team/animations" into "animations-demo"
Judd2000 Apr 5, 2024
04128b1
Merge "adam/byu-team/animations" into "animations-demo"
Judd2000 Apr 5, 2024
2b75a2b
Animations fix utils
Judd2000 Apr 5, 2024
f001052
Merge pull request #228 from adobe/njudd/byu-team/animations-3
Judd2000 Apr 5, 2024
7fc39fa
fix: add proper switch testing
gideontonkinson Apr 5, 2024
03c4ebe
Merge branch 'animations' of github.com:adobe/react-spectrum-charts i…
gideontonkinson Apr 5, 2024
d34b64c
fix: tests
gideontonkinson Apr 6, 2024
f255a21
Animations code cleanup, logical flipping, removal of magic numbers
Judd2000 Apr 8, 2024
5aa58af
Animation more code cleanup
Judd2000 Apr 8, 2024
ce160d5
Animations made ANIMATION_FUNCTION constant that is assigned to EASE_…
Judd2000 Apr 10, 2024
52e5826
Animations only add timer signal when animations are enabled
Judd2000 Apr 10, 2024
f6a7f1c
Animations fixed timer signal and annotation opacity
Judd2000 Apr 10, 2024
b1ac8ba
Animations pass animations to scatterSpecBuilder, add animations togg…
Judd2000 Apr 10, 2024
6c9cb9a
Animations removed nested ternary inside markUtils
Judd2000 Apr 10, 2024
67a5778
fix: remove todo where tests are already implemented
gideontonkinson Apr 10, 2024
57a120f
Merge branch 'animations' of github.com:adobe/react-spectrum-charts i…
gideontonkinson Apr 10, 2024
97c8c6b
Animations fixed tests to not expect timerValue when animations are offA
Judd2000 Apr 10, 2024
7365302
Merge branch 'animations' of https://github.com/adobe/react-spectrum-…
Judd2000 Apr 10, 2024
7927719
Replace timer value with constant
agardn87 Apr 10, 2024
f87e38c
Animatioins moved usePreviousChartData out to the react hooks directo…
Judd2000 Apr 10, 2024
579dcf9
Merge branch 'animations' of https://github.com/adobe/react-spectrum-…
Judd2000 Apr 10, 2024
dabe3e9
Animations removed console.warn
Judd2000 Apr 10, 2024
2923b15
Animations removed unnecessary const
Judd2000 Apr 10, 2024
31dc879
Add animation toggle to opacity animation stories
agardn87 Apr 10, 2024
51e4b18
Merge branch 'animations' of https://github.com/adobe/react-spectrum-…
agardn87 Apr 10, 2024
1a64554
fix unneccessary logic
gideontonkinson Apr 12, 2024
3bd61d6
remove todo where tests are already completed
gideontonkinson Apr 12, 2024
c2e20e3
Use mark id for animations
jacob-hart Apr 12, 2024
1488446
Merge branch 'animations' of https://github.com/adobe/react-spectrum-…
jacob-hart Apr 12, 2024
a5e9caf
Remove unused imports
jacob-hart Apr 12, 2024
a1bebf4
add more testing
gideontonkinson Apr 12, 2024
ede3c17
removed unneccessary todos
gideontonkinson Apr 12, 2024
0d82e8f
Merge branch 'animations' of github.com:adobe/react-spectrum-charts i…
gideontonkinson Apr 12, 2024
fc9273f
Animations more logical suggestion fixes
Judd2000 Apr 12, 2024
2771e35
Merge branch 'animations' of https://github.com/adobe/react-spectrum-…
Judd2000 Apr 12, 2024
2f7e3a8
Animations removed commented code and uneccessary space
Judd2000 Apr 12, 2024
fc1ce4c
remove added console.logs
gideontonkinson Apr 12, 2024
af6f684
Merge branch 'animations' of github.com:adobe/react-spectrum-charts i…
gideontonkinson Apr 12, 2024
6546d0c
remove warns
gideontonkinson Apr 12, 2024
a1b32db
remove more todos
gideontonkinson Apr 12, 2024
f695e8c
remove documentation todo
gideontonkinson Apr 12, 2024
00b1d03
fixed nested turnerary
gideontonkinson Apr 12, 2024
573305b
Animations removed useMemo wrapping the VegaChart component
Judd2000 Apr 12, 2024
05db649
Animations moved onNewView inline lambda to const
Judd2000 Apr 12, 2024
d9aa043
Animation set SharedChartProps animations to optional, added necessar…
Judd2000 Apr 12, 2024
39b7a41
Animations switched to ?? instead of comparing against undefined
Judd2000 Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -17,4 +17,6 @@ test-report.xml

# exclude vscode config except for our shared snippets
.vscode/*
!.vscode/reactSpectrumCharts.code-snippets
!.vscode/reactSpectrumCharts.code-snippets

.idea/
7 changes: 6 additions & 1 deletion .storybook/main.ts
Expand Up @@ -4,7 +4,12 @@ import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
const config: StorybookConfig = {
stories: ['../src/**/*.story.mdx', '../src/**/*.story.@(js|jsx|ts|tsx)'],

addons: ['@storybook/addon-links', '@storybook/addon-essentials', 'storybook-dark-mode'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'storybook-dark-mode',
'@storybook/addon-webpack5-compiler-babel'
],

framework: {
name: '@storybook/react-webpack5',
Expand Down
1 change: 1 addition & 0 deletions global.mock.js
@@ -0,0 +1 @@
global.structuredClone = (value) => JSON.parse(JSON.stringify(value));
4 changes: 1 addition & 3 deletions jest.config.js
Expand Up @@ -21,9 +21,7 @@ module.exports = {
transform: {
'^.+\\.(j|t)sx?$': 'babel-jest',
},
globals: {
structuredClone: (value) => JSON.parse(JSON.stringify(value)),
},
setupFiles: ['./global.mock.js'],
moduleDirectories: ['src', 'node_modules'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
Expand Down
19 changes: 10 additions & 9 deletions package.json
Expand Up @@ -56,14 +56,15 @@
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.20.6",
"@storybook/addon-actions": "7.6.17",
"@storybook/addon-essentials": "7.6.17",
"@storybook/addon-links": "7.6.17",
"@storybook/addon-actions": "^8.0.4",
"@storybook/addon-essentials": "^8.0.4",
"@storybook/addon-links": "^8.0.4",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/preset-scss": "^1.0.3",
"@storybook/react": "7.6.17",
"@storybook/react-webpack5": "7.6.17",
"@storybook/testing-library": "^0.2.2",
"@storybook/theming": "7.6.17",
"@storybook/react": "^8.0.4",
"@storybook/react-webpack5": "^8.0.4",
"@storybook/test": "^8.0.4",
"@storybook/theming": "^8.0.4",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "^14.4.3",
Expand Down Expand Up @@ -100,9 +101,9 @@
"react-docgen-typescript-loader": "3.7.2",
"react-dom": "17.0.2",
"resize-observer-polyfill": "^1.5.1",
"storybook": "7.6.17",
"storybook": "^8.0.4",
"storybook-addon-react-docgen": "^1.2.44",
"storybook-dark-mode": "^3.0.3",
"storybook-dark-mode": "^4.0.1",
"style-loader": "^3.3.3",
"ts-jest": "^29.0.3",
"ts-loader": "^9.4.2",
Expand Down
14 changes: 12 additions & 2 deletions src/Chart.tsx
Expand Up @@ -13,11 +13,16 @@ import { FC, forwardRef, useEffect, useMemo, useRef, useState } from 'react';

import { EmptyState } from '@components/EmptyState';
import { LoadingState } from '@components/LoadingState';
import { DEFAULT_BACKGROUND_COLOR, DEFAULT_COLOR_SCHEME, DEFAULT_LINE_TYPES, DEFAULT_LOCALE } from '@constants';
import {
DEFAULT_BACKGROUND_COLOR,
DEFAULT_COLOR_SCHEME,
DEFAULT_LINE_TYPES,
DEFAULT_LOCALE
} from '@constants';
import useChartImperativeHandle from '@hooks/useChartImperativeHandle';
import useChartWidth from '@hooks/useChartWidth';
import { useResizeObserver } from '@hooks/useResizeObserver';
import { getColorValue } from '@specBuilder/specUtils';
import { getColorValue, usePreviousChartData } from '@specBuilder/specUtils';
import { RscChart } from 'RscChart';
import { v4 as uuid } from 'uuid';
import { View } from 'vega';
Expand All @@ -40,6 +45,7 @@ export const Chart = forwardRef<ChartHandle, ChartProps>(
{
backgroundColor = DEFAULT_BACKGROUND_COLOR,
data,
animations = true,
colors = 'categorical12',
colorScheme = DEFAULT_COLOR_SCHEME,
config,
Expand Down Expand Up @@ -77,6 +83,8 @@ export const Chart = forwardRef<ChartHandle, ChartProps>(

useChartImperativeHandle(forwardedRef, { chartView, title });

const previousChartData = usePreviousChartData(data);

const containerRef = useResizeObserver<HTMLDivElement>((_target, entry) => {
if (typeof width === 'number') return;
setContainerWidth(entry.contentRect.width);
Expand Down Expand Up @@ -129,6 +137,8 @@ export const Chart = forwardRef<ChartHandle, ChartProps>(
chartView={chartView}
chartId={chartId}
data={data}
previousData={previousChartData}
animations={animations}
backgroundColor={backgroundColor}
colors={colors}
colorScheme={colorScheme}
Expand Down
54 changes: 41 additions & 13 deletions src/RscChart.tsx
Expand Up @@ -68,6 +68,8 @@
chartView,
backgroundColor = DEFAULT_BACKGROUND_COLOR,
data,
previousData,
animations,
colors = 'categorical12',
colorScheme = DEFAULT_COLOR_SCHEME,
config,
Expand All @@ -93,6 +95,9 @@
forwardedRef
) => {
// uuid is used to make a unique id so there aren't duplicate ids if there is more than one Chart component in the document

// state variable for storing if chart should reanimate from zero / animate across data sets
const [animateFromZero, setAnimateFromZero] = useState(true);
const selectedData = useRef<Datum | null>(null); // data that is currently selected, get's set on click if a popover exists
const selectedDataName = useRef<string>();
const selectedDataBounds = useRef<MarkBounds>();
Expand All @@ -102,12 +107,20 @@

const sanitizedChildren = sanitizeRscChartChildren(props.children);

// THE MAGIC, builds our spec
// when data changes, make sure that we are animating from zero (especially in the case where a popover was just
// opened and closed)
useEffect(() => {
setAnimateFromZero(true);
}, [data]);

const spec = useSpec({
backgroundColor,
children: sanitizedChildren,
colors,
data,
previousData,
animations,
animateFromZero,
description,
hiddenSeries,
highlightedSeries,
Expand All @@ -130,8 +143,11 @@
// Hide tooltips on all charts when a popover is open
tooltipElement.hidden = popoverIsOpen;

// if the popover is closed, reset the selected data
if (!popoverIsOpen) {

if (popoverIsOpen) {
setAnimateFromZero(false);
} else {
// if the popover is closed, reset the selected data
selectedData.current = null;
}
}, [popoverIsOpen]);
Expand Down Expand Up @@ -198,6 +214,7 @@
const signals: Record<string, unknown> = {
backgroundColor: getColorValue('gray-50', colorScheme),
};

if (legendIsToggleable) {
signals.hiddenSeries = hiddenSeriesState;
}
Expand All @@ -207,18 +224,15 @@
return signals;
}, [colorScheme, hiddenSeriesState, legendIsToggleable]);

return (
<>
<div
id={`${chartId.current}-popover-anchor`}
data-testid="rsc-popover-anchor"
ref={popoverAnchorRef}
style={targetStyle}
/>
const newSpec = JSON.stringify(spec);
Judd2000 marked this conversation as resolved.
Show resolved Hide resolved

const chart = useMemo(() => {
return (
<VegaChart
spec={spec}
spec={JSON.parse(newSpec)}
config={chartConfig}
data={data}
previousData={previousData ?? []}
debug={debug}
renderer={renderer}
width={chartWidth}
Expand Down Expand Up @@ -275,6 +289,20 @@
// this will trigger the autosize calculation making sure that everything is correct size
}}
/>
);
}, [newSpec, chartConfig, data, previousData, debug, renderer, chartWidth, height, locale,

Check warning on line 293 in src/RscChart.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useMemo has an unnecessary dependency: 'colorScheme'. Either exclude it or remove the dependency array
padding, signals, tooltipConfig, chartView, popovers.length, legendIsToggleable, onLegendClick,
onLegendMouseOver, onLegendMouseOut, hiddenSeriesState, chartId, setHiddenSeries, colorScheme]);

return (
<>
<div
id={`${chartId.current}-popover-anchor`}
data-testid="rsc-popover-anchor"
ref={popoverAnchorRef}
style={targetStyle}
/>
{chart}
<ChartDialog
datum={selectedData.current}
targetElement={popoverAnchorRef}
Expand Down Expand Up @@ -332,4 +360,4 @@

const itemIsLegendItem = (item: Item<unknown>): boolean => {
return 'name' in item.mark && typeof item.mark.name === 'string' && item.mark.name.includes('legend');
};
};
27 changes: 24 additions & 3 deletions src/VegaChart.tsx
Expand Up @@ -11,7 +11,7 @@
*/
import { FC, useEffect, useMemo, useRef } from 'react';

import { TABLE } from '@constants';
import { PREVIOUS_TABLE, TABLE } from '@constants';
import { useDebugSpec } from '@hooks/useDebugSpec';
import { extractValues, isVegaData } from '@specBuilder/specUtils';
import { expressionFunctions, formatTimeDurationLabels } from 'expressionFunctions';
Expand All @@ -25,6 +25,7 @@ export interface VegaChartProps {
config: Config;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: ChartData[];
previousData: ChartData[];
debug: boolean;
height: number;
locale: ChartProps['locale'];
Expand All @@ -40,6 +41,7 @@ export interface VegaChartProps {
export const VegaChart: FC<VegaChartProps> = ({
config,
data,
previousData,
debug,
height,
locale,
Expand All @@ -58,7 +60,7 @@ export const VegaChart: FC<VegaChartProps> = ({

// Need to de a deep copy of the data because vega tries to transform the data
const chartData = useMemo(() => {
const clonedData = JSON.parse(JSON.stringify(data));
const clonedData = structuredClone(data);

// We received a full Vega data array with potentially multiple dataset objects
if (isVegaData(clonedData)) {
Expand All @@ -69,7 +71,19 @@ export const VegaChart: FC<VegaChartProps> = ({
return { [TABLE]: clonedData };
}, [data]);

useDebugSpec(debug, spec, chartData, width, height, config);
const previousChartData = useMemo(() => {
const clonedData = structuredClone(previousData);

// We received a full Vega data array with potentially multiple dataset objects
if (isVegaData(clonedData)) {
return extractValues(clonedData);
}

// We received a simple array of data and we'll set a default key of 'table' to reference internally
return { [PREVIOUS_TABLE]: clonedData };
}, [previousData]);

useDebugSpec(debug, spec, { ...previousChartData, ...chartData }, width, height, config);

useEffect(() => {
if (width && height && containerRef.current) {
Expand All @@ -78,6 +92,10 @@ export const VegaChart: FC<VegaChartProps> = ({
if (tableData && 'values' in tableData) {
tableData.values = chartData.table;
}
const previousTableData = specCopy.data?.find((d) => d.name === PREVIOUS_TABLE);
if (previousTableData && 'values' in previousTableData) {
previousTableData.values = previousChartData ? previousChartData.previousTable : [];
}
if (signals) {
specCopy.signals = specCopy.signals?.map((signal) => {
if (signal.name in signals && signals[signal.name] !== undefined && 'value' in signal) {
Expand All @@ -86,6 +104,7 @@ export const VegaChart: FC<VegaChartProps> = ({
return signal;
});
}

embed(containerRef.current, specCopy, {
actions: false,
config,
Expand Down Expand Up @@ -116,8 +135,10 @@ export const VegaChart: FC<VegaChartProps> = ({
};
}, [
chartData.table,
previousChartData,
config,
data,
previousData,
height,
numberLocale,
timeLocale,
Expand Down
11 changes: 11 additions & 0 deletions src/constants.ts
Expand Up @@ -39,6 +39,10 @@ export const DEFAULT_TITLE_FONT_WEIGHT = 'bold';
// vega data table name
export const TABLE = 'table';
export const FILTERED_TABLE = 'filteredTable';
export const PREVIOUS_TABLE = 'previousTable';

export const FILTERED_PREVIOUS_TABLE = 'filteredPreviousTable';
export const PREVIOUS_PREFIX = 'previous_';

// vega data field names
export const SERIES_ID = 'rscSeriesId';
Expand Down Expand Up @@ -77,6 +81,8 @@ export const TRELLIS_PADDING = 0.2;
// ratio that each opacity is divded by when hovering or highlighting from legend
export const HIGHLIGHT_CONTRAST_RATIO = 5;

export const RSC_ANIMATION = `rscAnimation`;

// legend tooltips
export const LEGEND_TOOLTIP_DELAY = 350;

Expand All @@ -86,3 +92,8 @@ export const BACKGROUND_COLOR = 'chartBackgroundColor';

// time constants
export const MS_PER_DAY = 86400000;

// chart animation constants
export const DATA_ANIMATION_DURATION_FRAMES = 78; // 60 fps * 1.3 seconds = 78 frames
export const DATA_ANIMATION_MILLISECONDS_PER_FRAME = 1000 / 60; // 60fps
export const EASE_OUT_CUBIC = '(1 - pow(1 - timerValue, 3))';
Judd2000 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/hooks/useChartProps.tsx
Expand Up @@ -14,5 +14,5 @@ import { ChartProps } from 'types';

export default function useChartProps(props: ChartProps): ChartProps {
const darkMode = useDarkMode();
return { colorScheme: darkMode ? 'dark' : 'light', ...props };
return { colorScheme: darkMode ? 'dark' : 'light', animations: false, ...props };
}
10 changes: 10 additions & 0 deletions src/hooks/useSpec.tsx
Expand Up @@ -23,6 +23,9 @@ export default function useSpec({
colors,
colorScheme,
data,
previousData,
animations,
animateFromZero,
description,
hiddenSeries,
highlightedSeries,
Expand Down Expand Up @@ -57,6 +60,10 @@ export default function useSpec({
backgroundColor,
children,
colors,
data,
previousData,
animations,
animateFromZero,
colorScheme,
description,
hiddenSeries,
Expand All @@ -76,6 +83,9 @@ export default function useSpec({
colors,
colorScheme,
data,
previousData,
animations,
animateFromZero,
description,
hiddenSeries,
highlightedSeries,
Expand Down