Skip to content

Conversation

@Ovilia
Copy link
Member

@Ovilia Ovilia commented May 12, 2025

Support function for modifyHSL so that we can calculate dark theme color in ECharts from light color.

s != null && (colorArr[1] =
typeof s === 'function'
? s(colorArr[1])
: parseCssFloat(s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Use isFunction to help with code compression.
  2. If the input number h, s, l are performed by parseCssFloat and clampCssAngle - especially the "clamp" logic inside of them.
    the return of function h, s, l should also be processed by them,
    otherwise the semantics of the API is inconsistent.

e.g.,

colorArr[0] = clampCssAngle( isFunction(h) ? h(colorArr[0]) : h)

colorArr[1] = isFunction(s) ? clampCssFloat(s(colorArr[1])) : parseCssFloat(s)

color: string,
h?: number | ((h: number) => number),
s?: number | ((s: number) => number),
l?: number | ((l: number) => number)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TS type of s and l is incorrect historically.
Could we correct them? Since we modify it this time.

s: string | number | ((s: number) => number)   // accept css float like '30%' or float number like 0.3.
l: string | number | ((l: number) => number)   // accept css float like '30%' or float number like 0.3.

@100pah 100pah merged commit f7a821b into v6 May 12, 2025
3 checks passed
@Ovilia Ovilia deleted the feat-color branch May 13, 2025 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants