color-js / color-js/elements

[color-chart] How should a chart look if the underlying `<color-scale>` has only one color?

Open
#128 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
30
Forks
4
PR merge metrics
No merged PRs in 30d

Description

For now, it throws because [the `getAxis()` function](https://github.com/color-js/elements/blob/5cf02760b3a971173d29cc7989c74b41548c167d/src/color-chart/color-chart.js#L218-L241) returns `NaN` for `min`, `max`, and `steps` when calculating the corresponding props for the X-axis.

I checked what Excel does when it gets only one data point. It looks like Excel calculates the range based on an ”assumption“ that the chart should look nice. If I understand correctly, it uses 1 as the X coord (if not explicitly specified). I suggest that the one data point will never be outside the range.

![image](https://github.com/user-attachments/assets/3958a078-315d-4c79-83f7-b325994f68dd)

We can probably do something similar (for the range of X).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.