Skip to content
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

[Feature Request]: Use data or alias as filter parameter insted of a fixed value #166

Open
whschopke98 opened this issue Jun 29, 2022 · 1 comment

Comments

@whschopke98
Copy link

Problem to solve
I have a table of contents (TOC) I want to create for a report.
Some parts of the TOC are supposed to be colored differently depending on the version of the report.
I can almost solve this, but the Array Filter only accepts fixed values as the filtering parameter while the report version is provided via json, since the template is supposed to fit all versions (and change accordingly).

Proposed solution
Use the dynamic colors functionality combined with Array Filter using a parameter provided in the json file.

Describe alternatives you've considered
I tried a solution based on the {bindColor()} marker combined with the array filter.
I set the color to the text to be #000001, then used the following marker.
{bindColor(#000001, #hexa) = d.colorTable[version=d.version].color}

What I expected to happen is:
The value of d.version is used as a filter parameter to locate the corresponding color in the colorTable object.
Then this color is applied to the text in color #000001.

I have seen examples of a similar usage of this type of filter combined with bindColor, but the filter value is always static, like d.colorTable[version=3].color.

I think that this application of changing color based on a condition signalized via the json data could be very useful.

I have also tried using variations like:
{bindColor(#000001, #hexa) = $fontColor($version)}
{#fontColor($reportVersion) = d.colorTable[version = $reportVersion].color}
{#version = d.version}

Additional context
I am using Carbone Studio
Data used:

{
  "version": 2,
  "colorTable": [
    {"version": 1, "color": "#FF0000"},
    {"version": 2, "color": "#FF00FF"}
  ]
}

Comment
I am happy to receive suggestions to solve my problem alternatively and also to provide any necessary further clarification :).

@whschopke98
Copy link
Author

I would like to add that I found a solution to my problem in the Help Center.
https://help.carbone.io/en-us/article/replace-colors-dynamically-according-to-conditions-11dmn8l/

This method works, but my request stays, as I think it would be beneficial to have the filter parameter be a value provided in the json data.

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

No branches or pull requests

1 participant