@flourish/custom-colors

中文文档
3.0.1发布于 2020/03/31UNLICENSEDESM + CJS近 30 天下载 1967

Adds custom color settings

此软件包已被标记为弃用

This project has been renamed to @flourish/colors

原始使用文档
文档目录3 节
  1. Install
  2. Basic usage
  3. Methods

Flourish custom colors

Add settings and logic to easily add custom colors to your template

Install

npm install @flourish/custom-colors

Basic usage

The settings.yml file should be imported into your template’s template.yml file, like this:

  - Colours
  - property: color
    import: "@flourish/custom-colors"

Import the package like import createCustomColors from "@flourish/custom-colors"

var colors = createCustomColors(state.color) creates a new object colors.

You only need to pass in a state to get the color function working.

Methods

colors.getColor(value) finds the correct color for value. Will just return the fallback value unless the updateColorScale method has been called at some point.

colors.fallback([value]) returns the current fallback value if value is undefined or (usually) sets it to value if it is defined and returns the colors object. The value "default" (re)sets the fallback to be the default value of null. The fallback value is returned whenever the getColor method cannot interpret the value passed into it (for example if that value is non-numeric when in sequential or diverging mode).

colors.stringNormalizer([func]) returns the current string normalizer function if func is undefined or (usually) sets it to func if it is defined and returns the colors object. The value "default" (re)sets the normalizer function to a function that lowercases input and strips out whitespace. Passing in any other value that is not a function (e.g. null) tells the colors object to not perform any normalization.

The string normalizer function is only used when in categorical mode. Its purpose is to allow for insignifcant (as viewed by the developer) discrepancies (such as case and whitespacing) in spelling in input data. After calling witha value for func, the updateColorScale method should be called.

colors.updateColorScale(domain) updates the color scale based on the domain array.

版本与发布记录

@flourish/custom-colors 共发布 16 个版本,首次发布于 2018/08/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.1latest2020/03/316 年前
3.0.1-prerelease.1next2020/03/116 年前
3.0.02019/02/017 年前
3.0.0-alpha.52019/02/017 年前
3.0.0-alpha.42019/02/017 年前
3.0.0-alpha.32019/01/307 年前

关于 @flourish/custom-colors 的常见问题

@flourish/custom-colors 是什么?

Adds custom color settings注意:该包已被作者标记为弃用——This project has been renamed to @flourish/colors

如何安装 @flourish/custom-colors?

在项目目录运行 npm install @flourish/custom-colors,或使用 pnpm add / yarn add / bun add。

@flourish/custom-colors 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/flourish__custom-colors 是否存在。

@flourish/custom-colors 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@flourish/custom-colors 可以商用吗?

@flourish/custom-colors 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@flourish/custom-colors 的下载量有多少?

根据 npm 官方下载统计,@flourish/custom-colors 在 2026/10/15 – 2026/11/13 这 30 天内被下载 1,967 次,日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flourish/custom-colors 还在维护吗?

最新版本 3.0.1 发布于 2020/03/31(6 年前);至今共发布 16 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/08/01。作者已将其标记为弃用,新项目建议寻找替代方案。