Skip to content

Update docs #12037

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

Merged
merged 2 commits into from
Feb 25, 2025
Merged

Update docs #12037

merged 2 commits into from
Feb 25, 2025

Conversation

joshkel
Copy link
Contributor

@joshkel joshkel commented Feb 22, 2025

Grammar and style: "TypeScript", add articles, etc.

Add docs covering the Array[] version of data. Please review and let me know if I've made any mistakes.

Fix an apparent mistake in the parsing: false description of category axes: I believe it's trying to say that strings would be a mistake.

Grammar and style: "TypeScript", add articles, etc.

Add docs covering the `Array[]` version of data. Please review and let me know if I've made any mistakes.

Fix an apparent mistake in the `parsing: false` description of category axes: I believe it's trying to say that _strings_ would be a mistake.
@kurkle
Copy link
Member

kurkle commented Feb 22, 2025

I'm not sure, but I'd suspect the common mistake of using integers for category scale was correct. When using strings, the scale automatically creates the labels array, but with integers it just tries to access the array at given indices.

@joshkel
Copy link
Contributor Author

joshkel commented Feb 25, 2025

Thanks, @kurkle. Looking into this a little further:

I thought that this paragraph was specifically about use with parsing: false, but reading it again, it looks like I was mistaken.

From what I can tell in testing and from inspecting the source code, the category axis can take string labels or numeric indexes. Numeric indexes are its internal format.

Even if parsing: false is used, a plot that uses a category or time axis works if unparsed values are passed (e.g., if a category scale receives data like {x: 'January', y: 10 }). It looks like the data is assigned to meta._parsed, which seems to violate assumptions about how meta._parsed is used, but then scale methods like getPixelForValue check for unparsed data anyway, so it works. Based on the Chart.js docs, this seems accidental (or at least not guaranteed), so I assume it shouldn't be advertised.

I've updated this PR to try to be clearer. Let me know if this seems better.

@etimberg etimberg merged commit 44908f5 into chartjs:master Feb 25, 2025
4 checks passed
@joshkel joshkel deleted the docs-updates branch February 25, 2025 16:37
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