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

Comparison chart color not working #1628

Closed
TimoBaeuerle opened this issue Feb 21, 2024 · 4 comments
Closed

Comparison chart color not working #1628

TimoBaeuerle opened this issue Feb 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@TimoBaeuerle
Copy link

Bug summary

I added a line chart to my application that shows the user sessions for android and ios. Beside that it shows the previous period data in a comparison chart-line (isComparison = true). The problem is, that I have to add two comparisons (ios & android data), but the color attribute does not work on comparison chart-lines. (visible on screenshot)

Expected behavior

When I add a "color" attribute to the linechart group attributes is should colorize the chart-line exactly like the non-comparison chart-lines does.

Actual behavior

Currently it's just grey and not colorized in the preferred color:
image

The color attribute is set in the linechart.data like this:

const structuredData: LineChartGroup[] = [
  { name: 'iOS', color: "#5A39C6", data: iosData, isComparison: false },
  { name: 'Android', color: "#A4C639", data: androidData, isComparison: false },
  { name: 'Previous period (iOS)', color: "#5A39C6", data: [], isComparison: true },
  { name: 'Previous period (Android)', color: "#A4C639", data: [], isComparison: true }
];

Color works for the chart-lines that are set to isComparison = false, but not to the comparison chart-lines. This is a inconsistent behaviour and in my frontend, users can not differ between the two comparison chart-lines without hovering over the values.

Steps to reproduce the problem

  1. Create a line chart
  2. Add two or more comparison linechart groups
  3. Add a color attribute to the linechart groups
  4. Check out the color in your running application

Specifications

  • Polaris-Viz version number: "^10.3.2"
@TimoBaeuerle TimoBaeuerle added the bug Something isn't working label Feb 21, 2024
@envex
Copy link
Collaborator

envex commented Feb 28, 2024

We currently override the color value for series that have isComparison: true. Ideally, a data set would only have a single comparison value.

@TimoBaeuerle
Copy link
Author

Our line graph has two values (Android, iOS). This leads to multiple comparison values. How does polaris-viz deal with this? Overwriting the color value is already described in the bug report, but does not answer why it is overridden when a specific colour value is given. In my opinion the color value should have a consistent behaviour.

@envex
Copy link
Collaborator

envex commented Mar 4, 2024

We wanted to keep the comparison styling (dotted line & color) consistent which is why we don't allow the styling or color to be overridden.

If you want to show multiple comparison lines, you can remove isComparison: true from your data series and use styleOverride to change the strokeDasharray.

styleOverride: {
  line: {
    strokeDasharray: '0.1 4',
  },
},

The above strokeDasharray will get you the same dotted styling we apply for isComparison.

@TimoBaeuerle
Copy link
Author

That should work for me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants