@flourish/chart-layout
Advanced tools
Comparing version 10.3.0 to 10.3.1
{ | ||
"name": "@flourish/chart-layout", | ||
"version": "10.3.0", | ||
"version": "10.3.1", | ||
"private": false, | ||
@@ -8,2 +8,9 @@ "description": "Create axes", | ||
"module": "src/index.js", | ||
"scripts": { | ||
"lint": "eslint src", | ||
"build": "rollup -c", | ||
"prepare": "npm run build && npm run minify", | ||
"minify": "terser -m -o chart-layout.min.js chart-layout.js", | ||
"precommit": "lint-staged" | ||
}, | ||
"author": "Kiln Enterprises Ltd", | ||
@@ -27,3 +34,3 @@ "license": "LicenseRef-LICENSE", | ||
"@flourish/enhanced-arrays": "^1.1.0", | ||
"@flourish/pocket-knife": "^0.3.1", | ||
"@flourish/pocket-knife": "^0.3.2", | ||
"d3-scale": "3.2.3", | ||
@@ -38,9 +45,3 @@ "d3-selection": "^2.0.0", | ||
} | ||
}, | ||
"scripts": { | ||
"lint": "eslint src", | ||
"build": "rollup -c", | ||
"minify": "terser -m -o chart-layout.min.js chart-layout.js", | ||
"precommit": "lint-staged" | ||
} | ||
} | ||
} |
@@ -0,1 +1,4 @@ | ||
# 10.3.1 | ||
* Fix custom tick {{FIRST}} and {{LAST}} | ||
# 10.3.0 | ||
@@ -2,0 +5,0 @@ * Increase the max available y axis space to 50% of chart |
@@ -33,21 +33,27 @@ import { isDate, isValidDate, textareaToArray } from "../../common"; | ||
else { | ||
let tick_list; | ||
const is_datetime = data.datetime_array; | ||
const domain = scale.domain(); | ||
const domain_min = Math.min(...domain); | ||
const domain_max = Math.max(...domain); | ||
if (axis_state.tick_mode === "custom") { | ||
const parser_name = axis + (is_datetime ? "Datetime" : "Number") + "Parse"; | ||
const parser = instance[parser_name](); | ||
const formatter = is_datetime ? instance[axis + "Format"]() : function(d) { return d; }; | ||
const custom_ticks = axis_state.tick_custom.replace("{{FIRST}}", formatter(domain[0])).replace("{{LAST}}", formatter(domain[domain.length - 1])); | ||
tick_list = textareaToArray(custom_ticks).map(d => parser(d)); | ||
let custom_ticks = textareaToArray(axis_state.tick_custom); | ||
ticks = custom_ticks.map(d => { | ||
if (d === "{{FIRST}}") return domain[0]; | ||
if (d === "{{LAST}}") return domain[domain.length - 1]; | ||
return parser(d); | ||
}); | ||
} | ||
else { | ||
const auto = instance[axis + "AutoTicks"](); | ||
tick_list = Array.isArray(auto) ? auto : auto(); | ||
ticks = Array.isArray(auto) ? auto : auto(); | ||
} | ||
tick_list = removeDuplicates(tick_list); | ||
const min = Math.min(...domain); | ||
const max = Math.max(...domain); | ||
if (is_datetime) ticks = tick_list.filter(d => isValidDate(d) && d >= min && d <= max); | ||
else ticks = tick_list.filter(d => !isNaN(d) && d >= min && d <= max); | ||
if (is_datetime) ticks = ticks.filter(d => isValidDate(d) && d >= domain_min && d <= domain_max); | ||
else ticks = ticks.filter(d => !isNaN(d) && d >= domain_min && d <= domain_max); | ||
ticks = removeDuplicates(ticks); | ||
} | ||
@@ -54,0 +60,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
471206
56
11306
1