Skip to content

PrimeFaces chart element cannot be made responsive #2640

Closed Answered by SkylerMime
SkylerMime asked this question in PrimeFaces
Discussion options

You must be logged in to vote

That was the first thing I tried, but unfortunately p:chart renders as two elements (a canvas inside a div), and the style attributes get passed to the canvas instead of to the div, where they need to be in order for the chart to be responsive.

Source:

<p:chart style="position: relative; height:40vh; width:80vw" />

Renders as:

<div id="j_idt5" class="ui-chart">
  <canvas id="j_idt5_canvas" role="img" style="position: relative; height: 114px; width: 430px; display: block; box-sizing: border-box; touch-action: auto; user-select: none;" width="430" height="114"></canvas>
</div>

But I would need it to render something like this (from the documentation):

<div class="chart-container" style="pos…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@SkylerMime
Comment options

Answer selected by melloware
@melloware
Comment options

@SkylerMime
Comment options

@SkylerMime
Comment options

@melloware
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
2 participants