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

remove constant for default tick values #49

Merged
merged 4 commits into from
Mar 15, 2024
Merged
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
83 changes: 15 additions & 68 deletions custom-elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
"type": {
"text": "number[]"
},
"default": "DEFAULT_TICK_VALUES",
"description": "The explicit values to be used for axis ticks",
"attribute": "tickValues"
},
Expand Down Expand Up @@ -169,7 +168,8 @@
{
"kind": "field",
"name": "colorScale",
"description": "A type of d3-scale for applying color values to the legend item(s),\nset internally by the colorScaleSetter."
"description": "A type of d3-scale for applying color values to the legend item(s),\nset internally by the colorScaleSetter.",
"readonly": true
},
{
"kind": "field",
Expand All @@ -181,7 +181,8 @@
{
"kind": "field",
"name": "xScale",
"description": "A d3 linear scale used for generating axis ticks,\nset internally by the axisTickSetter"
"description": "A d3 linear scale used for generating axis ticks,\nset internally by the axisTickSetter",
"readonly": true
},
{
"kind": "field",
Expand All @@ -196,63 +197,42 @@
"name": "titleText",
"default": "DEFAULT_TITLE_TEXT",
"description": "The title text that displays at the top of the legend",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "titleText"
},
{
"name": "width",
"default": "DEFAULT_WIDTH",
"description": "The width of the SVG or categorical legend div element",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "width"
},
{
"name": "height",
"default": "DEFAULT_HEIGHT",
"description": "The height of the SVG element",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "height"
},
{
"name": "marginTop",
"default": "DEFAULT_MARGIN_TOP",
"description": "The spacing between the legend bar and top most extent of the SVG",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "marginTop"
},
{
"name": "marginRight",
"default": "DEFAULT_MARGIN_RIGHT",
"description": "The spacing between the legend bar and right most extent of the SVG",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "marginRight"
},
{
"name": "marginBottom",
"default": "DEFAULT_MARGIN_BOTTOM",
"description": "The spacing between the legend bar and bottom most extent of the SVG",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "marginBottom"
},
{
"name": "marginLeft",
"default": "DEFAULT_MARGIN_LEFT",
"description": "The spacing between the legend bar and left most extent of the SVG",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "marginLeft"
},
{
Expand All @@ -262,9 +242,6 @@
},
"default": "DEFAULT_SCALE_TYPE",
"description": "The type of legend to render based on d3-scale",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "scaleType"
},
{
Expand All @@ -274,66 +251,44 @@
},
"default": "DEFAULT_DOMAIN",
"description": "The color scale's domain values",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "domain"
},
{
"name": "range",
"default": "DEFAULT_RANGE",
"description": "The color scale's range values",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "range"
},
{
"name": "markType",
"default": "DEFAULT_MARK_TYPE",
"description": "The symbology used for categorical legends",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "markType"
},
{
"name": "ticks",
"default": "DEFAULT_TICKS",
"description": "The desired number of axis ticks",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "ticks"
},
{
"name": "tickFormat",
"default": "DEFAULT_TICK_FORMAT",
"description": "The d3-format specifier to format axis tick values",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "tickFormat"
},
{
"name": "tickSize",
"default": "DEFAULT_TICK_SIZE",
"description": "The size or length of the axis ticks",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "tickSize"
},
{
"name": "tickValues",
"type": {
"text": "number[]"
},
"default": "DEFAULT_TICK_VALUES",
"description": "The explicit values to be used for axis ticks",
"resolveInitializer": {
"module": "/src/constants"
},
"fieldName": "tickValues"
}
],
Expand Down Expand Up @@ -514,14 +469,6 @@
},
"default": "6"
},
{
"kind": "variable",
"name": "DEFAULT_TICK_VALUES",
"type": {
"text": "number[]"
},
"default": "null"
},
{
"kind": "variable",
"name": "DEFAULT_TICK_FORMAT",
Expand Down Expand Up @@ -556,11 +503,19 @@
},
{
"kind": "variable",
"name": "DEFAULT_MARK_TYPE"
"name": "DEFAULT_MARK_TYPE",
"type": {
"text": "MarkType"
},
"default": "\"circle\""
},
{
"kind": "variable",
"name": "DEFAULT_SCALE_TYPE"
"name": "DEFAULT_SCALE_TYPE",
"type": {
"text": "ScaleType"
},
"default": "\"continuous\""
},
{
"kind": "variable",
Expand All @@ -576,7 +531,7 @@
"type": {
"text": "array"
},
"default": "[\n \"scaleType\",\n \"ticks\",\n \"tickSize\",\n \"tickValues\",\n \"tickFormat\",\n \"domain\",\n \"range\",\n \"marginLeft\",\n \"marginRight\",\n \"marginBottom\",\n \"marginTop\",\n \"width\",\n \"height\",\n]"
"default": "[\n \"scaleType\",\n \"ticks\",\n \"tickSize\",\n \"tickValues\",\n \"tickFormat\",\n \"tickFormatter\",\n \"domain\",\n \"range\",\n \"marginLeft\",\n \"marginRight\",\n \"marginBottom\",\n \"marginTop\",\n \"width\",\n \"height\",\n]"
}
],
"exports": [
Expand Down Expand Up @@ -644,14 +599,6 @@
"module": "src/constants.ts"
}
},
{
"kind": "js",
"name": "DEFAULT_TICK_VALUES",
"declaration": {
"name": "DEFAULT_TICK_VALUES",
"module": "src/constants.ts"
}
},
{
"kind": "js",
"name": "DEFAULT_TICK_FORMAT",
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/color-legend-element.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/color-legend-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
DEFAULT_TICKS,
DEFAULT_TICK_FORMAT,
DEFAULT_TICK_SIZE,
DEFAULT_TICK_VALUES,
} from "./constants";

@customElement("color-legend")
Expand Down Expand Up @@ -120,7 +119,7 @@ export class ColorLegendElement extends LitElement {
* The explicit values to be used for axis ticks
*/
@property({ type: Array })
tickValues: number[] = DEFAULT_TICK_VALUES;
tickValues: number[];

/**
* Reference to the SVG node
Expand Down
1 change: 0 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const DEFAULT_MARGIN_LEFT = 12;

export const DEFAULT_TICKS = 5;
export const DEFAULT_TICK_SIZE = 6;
export const DEFAULT_TICK_VALUES: number[] = null;
export const DEFAULT_TICK_FORMAT = ".1f";

export const DEFAULT_DOMAIN = [0, 1];
Expand Down
4 changes: 2 additions & 2 deletions src/test/x-scale-axis_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ suite("AxisTicksSetter", () => {
></color-legend>`,
)) as ColorLegendElement;
await el.updateComplete;
assert.isNull(el.tickValues);
assert.isUndefined(el.tickValues);
});

test("handleAxisTicks categorical", async () => {
Expand All @@ -135,6 +135,6 @@ suite("AxisTicksSetter", () => {
></color-legend>`,
)) as ColorLegendElement;
await el.updateComplete;
assert.isNull(el.tickValues);
assert.isUndefined(el.tickValues);
});
});
Loading