4.0.7 • Published 1 year ago

@thematic/core v4.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

This package contains the core theme parsing and transformation.

Getting Started

To load the default theme, you can call load without any parameters:

	import { load } from '@thematic/core'

	const theme = load()

The Theme interface includes configuration objects for a wide variety of mark types and scales. Most of these follow a few basic format principles:

  • where possible, we use svg attribute names for natural visual mappings
  • all values are retrieved via functions rather than direct properties, this leaves us room to put optional modifier parameters in
  • when colors are retrieved, they use a Color interface that has a variety of format functions

For example, to retrieve the configuration for rectangles on a chart (such as for a bar chart), it might look something like:

	const bar = theme.rect()
	const fill = bar.fill().hex() // get the hex code version of the fill color

The mark functions accept parameters ('MarkConfig') that allow for scale mappings, selection states, etc. The individual attr functions always accept a datum that can be used if scale mappings are provided.

For example:

	import { scaleLinear } from 'd3-scale'

	// get the selected bar config
	const normalBar = theme.rect()
	const selectedBar = theme.rect({ selectionState: SelectionState.Selected })
	const normalFill = normalBar.fill().hex() // default color
	const selectedFill = selectedBar.fill().hex() // darker color

	// bind a scale
	const scale = scaleLinear().range([1, 10])
	const scaledCircle = theme.circle({
		scaleBindings: {
			radius: {
				scale,
			}
		}
	})
	const r0 = scaledCircle.radius(0) // 1
	const r1 = scaledCircle.radius(1) // 10
4.0.7

1 year ago

4.0.6

1 year ago

4.0.5

1 year ago

4.0.4

1 year ago

4.0.3

1 year ago

4.0.2

1 year ago

3.1.1

2 years ago

4.0.1

1 year ago

4.0.0

1 year ago

2.1.3

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.7

2 years ago

2.0.5

2 years ago

2.0.6

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.3.0

2 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.0.2

3 years ago

1.0.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.9.0

4 years ago

0.8.0

4 years ago