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
domainMid of diverging color scheme ignored when it falls outside data range #6544
Comments
You could use Open the Chart in the Vega Editor What do you expect the behavior of Vega-Lite to be? If the middle is outside the domain, I think it's not totally unreasonable to drop the mid value. |
If I use a diverging color scheme and set the domainMid to zero, I expect that the lower half of the color scheme will used with and only with negative values. If there aren't any negative values in the data, then that part of the range would not be used. Thanks for the alternative workaround, that's indeed better than mine! |
I looked a bit more into it. Vega-Lite actually just passes the domain mid to Vega and the warning you see comes from Vega. I think that's where we should fix it. I'm closing the issue here. Can you file an issue at https://github.com/vega/vega/issues/new/choose with a small example and the description of the issue so it can be addressed at the Vega level? |
I'm happy to help, but I could use some guidance on whether the pared down example:
Here are some pared-down Vega-Lite versions: |
Ideally, it would be a Vega specification stripped down from a spec generated by Vega-Lite but a Vega-Lite spec is fine if you don't have much experience with vega yet. We really appreciate you writing up the issue so anything that you can do in a few minutes will help. |
Signed-off-by: F.N. Claessen <felix@seita.nl>
This PR masks overlapping data during a DST transition (commonly on 1 day during fall) and then shows it split up vertically in a separate layer. * Introduce new sensor chart type Signed-off-by: F.N. Claessen <felix@seita.nl> * Fix alignment of y-axis labels Signed-off-by: F.N. Claessen <felix@seita.nl> * Add button to switch between sensor chart types Signed-off-by: F.N. Claessen <felix@seita.nl> * Streamline button title with others Signed-off-by: F.N. Claessen <felix@seita.nl> * Improve alignment of first and last time-of-day labels Signed-off-by: F.N. Claessen <felix@seita.nl> * Cleaner solution to prevent showing next date outside selected daterange Signed-off-by: F.N. Claessen <felix@seita.nl> * refactor: field definitions Signed-off-by: F.N. Claessen <felix@seita.nl> * remove obsolete line Signed-off-by: F.N. Claessen <felix@seita.nl> * fix: replay ruler for new chart type Signed-off-by: F.N. Claessen <felix@seita.nl> * black Signed-off-by: F.N. Claessen <felix@seita.nl> * fix: separate overlapping data during the fall DST transition Signed-off-by: F.N. Claessen <felix@seita.nl> * refactor: reuse code Signed-off-by: F.N. Claessen <felix@seita.nl> * fix: tooltip Signed-off-by: F.N. Claessen <felix@seita.nl> * fix: mind the gap Signed-off-by: F.N. Claessen <felix@seita.nl> * add: warn users when viewing sensor data that includes a DST transition Signed-off-by: F.N. Claessen <felix@seita.nl> * add: also warn users when viewing asset data that includes a DST transition Signed-off-by: F.N. Claessen <felix@seita.nl> * add: UI styling Signed-off-by: F.N. Claessen <felix@seita.nl> * add: add timezone to tooltip during fall DST transition Signed-off-by: F.N. Claessen <felix@seita.nl> * style: black Signed-off-by: F.N. Claessen <felix@seita.nl> * feat: remember selected chart type within session Signed-off-by: F.N. Claessen <felix@seita.nl> * refactor: move towards a single function to set session variables from request variables Signed-off-by: F.N. Claessen <felix@seita.nl> * refactor: move template variables Signed-off-by: F.N. Claessen <felix@seita.nl> * only store non-None session variables Signed-off-by: F.N. Claessen <felix@seita.nl> * docs: changelog entry Signed-off-by: F.N. Claessen <felix@seita.nl> * flake8 Signed-off-by: F.N. Claessen <felix@seita.nl> * feat: top y-coordinate of ruler moves with belief time, too Signed-off-by: F.N. Claessen <felix@seita.nl> * rename matrix chart to heatmap Signed-off-by: F.N. Claessen <felix@seita.nl> * feat: heatmap shows only data from a single source Signed-off-by: F.N. Claessen <felix@seita.nl> * feat: selected source is the one with the most visible data Signed-off-by: F.N. Claessen <felix@seita.nl> * docs: add name of new chart type to changelog entry Signed-off-by: F.N. Claessen <felix@seita.nl> * fix: workaround for vega/vega-lite#6544 Signed-off-by: F.N. Claessen <felix@seita.nl> * docs: changelog entry Signed-off-by: F.N. Claessen <felix@seita.nl> * fix: in case of a tied rank, where multiple sources have exactly the same number of data points, arbitrarily pick the first one in the data Signed-off-by: F.N. Claessen <felix@seita.nl> * feature: show a warning message whenever a heatmap is shown that masks sources (#780) Signed-off-by: F.N. Claessen <felix@seita.nl> --------- Signed-off-by: F.N. Claessen <felix@seita.nl>
I have a heatmap where I use a diverging color scheme with
{"domainMid": 0}
with the intent that negative values will stand out from positive ones. However, today I ran into an edge case where, because all of the values are positive, the libraries apparently choose to just ignore mydomainMid
setting:Adding
"domain": [0, 30]
works around the issue, but it seems to me like a case where the libraries are counterintuitively ignoring a reasonable chart spec with sensible semantics. It also requires me to bind my chart spec more tightly to the actual data—I must compute the domain from the actual data, which means that having the data at hand becomes a prerequisite for generating the spec. In Altair I implemented my workaround this way, which might be a candidate solution to adopt in the library itself:Here's the example that ran into the issue:
Open the Chart in the Vega Editor
The text was updated successfully, but these errors were encountered: