Skip to content

Conversation

@extua
Copy link
Contributor

@extua extua commented Oct 18, 2025

Added a short example for creating a stacked area chart.

stacked_lilaq(1)

@Mc-Zen
Copy link
Member

Mc-Zen commented Oct 19, 2025

This is a great idea, especially until there is a built-in function for that. Also see lilaq-project/lilaq#105.

I wonder whether it is more useful for users to provide the solution for any number of series (given in the first answer to the issue linked above). Also, the example does not compile at the moment because the x array is not defined.

this should render properly now!
@extua
Copy link
Contributor Author

extua commented Oct 19, 2025

I didn't see your example in lilaq-project/lilaq#105 (comment); the way you've written it is much better!

@Mc-Zen
Copy link
Member

Mc-Zen commented Oct 19, 2025

How about we propose an implementation of a new high-level plot type stacked-area like this

#let stacked-area(x, ..y) = {
  y
    .pos()
    .fold(
      ((0,) * x.len(),) , (ys-stacked, ys) => {
        let previous = ys-stacked.last()
        ys-stacked.push(lq.vec.add(previous, ys))
        ys-stacked
      }
    )
    .windows(2)
    .map(((y1, y2)) => lq.fill-between(x, y1, y2: y2))
}

#let x = range(10)
#let y1= (0, 1, 3, 9, 5, 4, 2, 2, 1, 0)
#let y2 = (5, 3, 2, 0, 1, 2, 2, 2, 3, 2)
#let y3 = (0, 0, 0, 0, 1, 2, 4, 5, 5, 9)

#lq.diagram(
  ..stacked-area(x, y1, y2, y3)
)

The user can check out and see how stacked-area works. but does not need to touch it in order to use it. I feel like this is a nice solution until this is built in.

@extua
Copy link
Contributor Author

extua commented Oct 19, 2025

How about we propose an implementation of a new high-level plot type stacked-area like this

I agree, what do you think of this -- dfa2788

@Mc-Zen
Copy link
Member

Mc-Zen commented Oct 19, 2025

Nice. Thank you for this good idea and contribution!

@Mc-Zen Mc-Zen merged commit c9d86e7 into lilaq-project:main Oct 19, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants