woocommerce/plugins/woocommerce-admin/packages/components/src/chart
Jeff Stieler 8e61f55017 Allow packages to be built in isolation. (https://github.com/woocommerce/woocommerce-admin/pull/7286)
* Use yarn instead of npm.

In prep for workspaces, since we're locked to npm < 7. See: https://github.com/woocommerce/woocommerce-admin/pull/7126#issue-661287749

* Initial workspace creation.

* Add initial tsc build to @woocommerce/number.

* Attempt to build experimental package.

* Try currency package.

* Define all packages as workspaces.

* Use tsconfig common to packages.

* Fix currency package build.

* Build csv-export with tsc.

* Try to build customer-effort-score with tsc.

* Fix JSX pragma.

* Build data package with tsc.

* Build date package with tsc.

* Build experimental package with tsc.

* Try to build explat package with tsc.

* Build navigation package with tsc.

* Build notices package with tsc.

* Build onboarding package with tsc.

* Build components package with tsc.

* Swap in package JS build into main script.

* Fix experimental package build.

* Try per-package css build with components.

* Try to run components package tests in isolation.

Broken on JSX in test files not being transformed.

* Move @woocommerce/wc-admin-settings into a package.

* Try to fix components package tests.

Fails because we aren't setting up the jest/jest-dom globals.

* Move JS test code to reusable (private) package.

* Enable incremental TS builds.

* Use workspaces to run JS tests.

* Use new jest configs for update snapshot scripts.

* Fix style builds.

* Fix package version in components.

* Fix client test debug and watch scripts.

* Update yarn lock.

* Update test-staged behavior.

* Try to fix storybook.

* Fix storybook.

* Update more npm commands to yarn.

* Add changelog.

* Fix lint errors.

* Update packages readme script references.

* Clean up unused gitignore match.

* Fix another npm command.

* Fix JS builds on watch.

* Fix start script.

* Fix start scripts for packages.

* Use tsc to build packages before tests

* yarn -> npm.

# Conflicts:
#	package-lock.json
#	package.json

* Fix linter error.

* Remove workspace definitions.

* Fix missing Fragment import.

* Fix package lock.

* Fix missing reference.

* Only build commonjs module for js-tests helper.

* Remove errant dependency from components.

* Remove noop scripts.

* Fix package JS build before testing.

* Revert noisy formatting changes.

* Fix precommit and test scripts.

* Fix minimum expected recommended extension count.

Japan test case breaks this.

* Revert babel config changes.

* chore(release): publish

 - @woocommerce/components@7.2.0
 - @woocommerce/csv-export@1.4.0
 - @woocommerce/currency@3.2.0
 - @woocommerce/customer-effort-score@1.1.0
 - @woocommerce/data@1.4.0
 - @woocommerce/date@3.1.0
 - @woocommerce/dependency-extraction-webpack-plugin@1.7.0
 - @woocommerce/eslint-plugin@1.3.0
 - @woocommerce/experimental@1.5.0
 - @woocommerce/explat@1.1.0
 - @woocommerce/js-tests@1.1.0
 - @woocommerce/navigation@6.1.0
 - @woocommerce/notices@3.1.0
 - @woocommerce/number@2.2.0
 - @woocommerce/onboarding@1.1.0
 - @woocommerce/tracks@1.1.0
 - @woocommerce/wc-admin-settings@1.1.0

* Add script for running 'start' in a package.

* Remove yarn from gitignore.

* Update package changelogs, prep versions for release.

* Try to fix E2E tests after main merge.

* Some cleanup.

* Add changelog.

Co-authored-by: Paul Sealock <psealock@gmail.com>
2021-07-14 16:38:57 -04:00
..
d3chart Allow packages to be built in isolation. (https://github.com/woocommerce/woocommerce-admin/pull/7286) 2021-07-14 16:38:57 -04:00
docs Fix dependency declarations (https://github.com/woocommerce/woocommerce-admin/pull/4972) 2020-08-13 14:05:22 +12:00
README.md Decouple wcSettings from published packages. (https://github.com/woocommerce/woocommerce-admin/pull/3001) 2019-10-11 11:45:45 -04:00
constants.js Align WooCommerce javascript code standards/linting/styles with WordPress core. (https://github.com/woocommerce/woocommerce-admin/pull/3674) 2020-02-14 15:23:21 +13:00
index.js Allow packages to be built in isolation. (https://github.com/woocommerce/woocommerce-admin/pull/7286) 2021-07-14 16:38:57 -04:00
placeholder.js Allow packages to be built in isolation. (https://github.com/woocommerce/woocommerce-admin/pull/7286) 2021-07-14 16:38:57 -04:00
style.scss Use sass-migrator to migrate division to math.div (https://github.com/woocommerce/woocommerce-admin/pull/7136) 2021-06-10 17:09:27 +08:00

README.md

Chart

A chart container using d3, to display timeseries data with an interactive legend.

Usage

const data = [
	{
		date: '2018-05-30T00:00:00',
		Hoodie: {
			label: 'Hoodie',
			value: 21599,
		},
		Sunglasses: {
			label: 'Sunglasses',
			value: 38537,
		},
		Cap: {
			label: 'Cap',
			value: 106010,
		},
	},
	{
		date: '2018-05-31T00:00:00',
		Hoodie: {
			label: 'Hoodie',
			value: 14205,
		},
		Sunglasses: {
			label: 'Sunglasses',
			value: 24721,
		},
		Cap: {
			label: 'Cap',
			value: 70131,
		},
	},
	{
		date: '2018-06-01T00:00:00',
		Hoodie: {
			label: 'Hoodie',
			value: 10581,
		},
		Sunglasses: {
			label: 'Sunglasses',
			value: 19991,
		},
		Cap: {
			label: 'Cap',
			value: 53552,
		},
	},
	{
		date: '2018-06-02T00:00:00',
		Hoodie: {
			label: 'Hoodie',
			value: 9250,
		},
		Sunglasses: {
			label: 'Sunglasses',
			value: 16072,
		},
		Cap: {
			label: 'Cap',
			value: 47821,
		},
	},
];

<Chart data={ data } title="Example Chart" layout="item-comparison" />

Props

Name Type Default Description
allowedIntervals Array null Allowed intervals to show in a dropdown
baseValue Number 0 Base chart value. If no data value is different than the baseValue, the emptyMessage will be displayed if provided
chartType One of: 'bar', 'line' 'line' Chart type of either line or bar
data Array [] An array of data
dateParser String '%Y-%m-%dT%H:%M:%S' Format to parse dates into d3 time format
emptyMessage String null The message to be displayed if there is no data to render. If no message is provided, nothing will be displayed
filterParam String null Name of the param used to filter items. If specified, it will be used, in combination with query, to detect which elements are being used by the current filter and must be displayed even if their value is 0
itemsLabel String null Label describing the legend items
mode One of: 'item-comparison', 'time-comparison' 'time-comparison' item-comparison (default) or time-comparison, this is used to generate correct ARIA properties
path String null Current path
query Object null The query string represented in object form
interactiveLegend Boolean true Whether the legend items can be activated/deactivated
interval One of: 'hour', 'day', 'week', 'month', 'quarter', 'year' 'day' Interval specification (hourly, daily, weekly etc)
intervalData Object null Information about the currently selected interval, and set of allowed intervals for the chart. See getIntervalsForQuery
isRequesting Boolean false Render a chart placeholder to signify an in-flight data request
legendPosition One of: 'bottom', 'side', 'top' null Position the legend must be displayed in. If it's not defined, it's calculated depending on the viewport width and the mode
legendTotals Object null Values to overwrite the legend totals. If not defined, the sum of all line values will be used
screenReaderFormat One of type: string, func '%B %-d, %Y' A datetime formatting string or overriding function to format the screen reader labels
showHeaderControls Boolean true Wether header UI controls must be displayed
title String null A title describing this chart
tooltipLabelFormat One of type: string, func '%B %-d, %Y' A datetime formatting string or overriding function to format the tooltip label
tooltipValueFormat One of type: string, func ',' A number formatting string or function to format the value displayed in the tooltips
tooltipTitle String null A string to use as a title for the tooltip. Takes preference over tooltipLabelFormat
valueType String null What type of data is to be displayed? Number, Average, String?
xFormat String '%d' A datetime formatting string, passed to d3TimeFormat
x2Format String '%b %Y' A datetime formatting string, passed to d3TimeFormat
yBelow1Format String null A number formatting string, passed to d3Format
yFormat String null A number formatting string, passed to d3Format
currency Object {} An object with currency properties for usage in the chart. The following properties are expected: decimal, symbol, symbolPosition, thousands. This is passed to d3Format.