Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Enhancement idea: Can we improve things with css attr values? #74

Closed
IDisposable opened this issue Oct 31, 2022 · 1 comment
Closed

Comments

@IDisposable
Copy link

Looking at the samples <td style="--size: calc( 60 / 100 );"> $ 60K </td> might be more semantically valuable if we did something like

<td data-value="60" data-total="100" style="--size: calc( attr("data-value") / attr("data-total");"> $ 60K </td> or something similar... and we could have the default style for size be implicitly that calc and do similar for --start. Also would be cool to be able to reach up for the data-total value using the cascading of CSS ;)

@ramiy
Copy link
Collaborator

ramiy commented Nov 2, 2022

When I started developing Charts.CSS I tested all the available methods. There where several use cases where data-* attributes had less flexibility. That is why I decided to use CSS variables.

In your example, the --size calculation is attr("data-value") / attr("data-total"), this is not always the default size.

When you prefer to display stacked chart, you need to change the "total" value. Read the stacked docs, and see the examples on the Simple vs. Percentage section.

In addition, when using CSS variables, you can use math functions everywhere. With data attributes you have to use static value. You can't use calculations like data-total="calc( 2 + 3 + 4 )"

@ChartsCSS ChartsCSS locked and limited conversation to collaborators Jun 29, 2023
@ramiy ramiy converted this issue into discussion #81 Jun 29, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants