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

VisArea gradient doesn't work properly with non-zero yDomain #548

Open
caiotarifa opened this issue Apr 2, 2025 · 4 comments
Open

VisArea gradient doesn't work properly with non-zero yDomain #548

caiotarifa opened this issue Apr 2, 2025 · 4 comments

Comments

@caiotarifa
Copy link

caiotarifa commented Apr 2, 2025

When using a custom yDomain that doesn't start at zero, the gradient in VisArea component doesn't render properly. The background gradient seems to be calculated from y=0 rather than from the minimum value in the yDomain.

Minimal reproduction (Vue):

<template>
  <VisXYContainer :data="data" : svg-defs="svgDefs" :y-domain="[145, undefined]">
    <VisLine :x="d => d.x" :y="d => d.y" />
    <VisArea :x="d => d.x" :y="d => d.y" color="url(#gradient)" />
  </VisXYContainer>
</template>

<script setup>
const svgDefs = `
  <linearGradient id="gradient" gradientTransform="rotate(90)">
    <stop offset="0%" stop-color="#3366FF" stop-opacity="1" />
    <stop offset="100%" stop-color="#3366FF" stop-opacity="0" />
  </linearGradient>
`;

// Sample data with y values that don't include zero
const data = [
  { x: 1, y: 150 },
  { x: 2, y: 145 },
  { x: 3, y: 155 },
  { x: 4, y: 148 }
];
</script>
@lee00678
Copy link
Collaborator

lee00678 commented Apr 3, 2025

Hi @caiotarifa can you clarify your question a little bit? I'm not sure why you want the yDomain to be undefined, I'm getting different results for :y-domain="[160, 0]" vs :y-domain="[160, 50]"

https://stackblitz.com/edit/9hzar2cp?file=src%2FApp.vue

Image
Image

@rokotyan
Copy link
Contributor

rokotyan commented Apr 3, 2025

@lee00678 For reference: I use undefined in the domain quite often to allow the chart calculate it.

@caiotarifa
Copy link
Author

Hi @lee00678.

undefined is a documented behavior, it allows the chart library to auto calculate the maximum value.

The problem here, as demonstrated in your prints, is: any value in yDomain should not interfere with the gradient distribution.

@lee00678
Copy link
Collaborator

lee00678 commented Apr 8, 2025

Hi @lee00678.

undefined is a documented behavior, it allows the chart library to auto calculate the maximum value.

The problem here, as demonstrated in your prints, is: any value in yDomain should not interfere with the gradient distribution.

I see, you are right, does seem like an issue.

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

3 participants