Code Monkey home page Code Monkey logo

Comments (16)

KennethChiu123 avatar KennethChiu123 commented on May 5, 2024 25

try
<Line data={data} width={200} height={200} options={{ maintainAspectRatio: false ,responsive:false }} />

from react-chartjs-2.

alexisthual avatar alexisthual commented on May 5, 2024 6

This still is an ongoing issue for me.
I used maintainAspectRatio: false in the options while trying to specify the height and width of a Line chart. The height works correctly but the width won't change. I had to put this Line in a div that has the appropriate width.

return (
    <div style={{width: '400px'}}>
        <Line
            data={data}
            options={options}
            height={200}
            width={400}
        />
    </div>
)

from react-chartjs-2.

DimaXu avatar DimaXu commented on May 5, 2024

It should not be committed as an issue.

from react-chartjs-2.

iarry avatar iarry commented on May 5, 2024

What was the fix here? I'm having the same issue.

from react-chartjs-2.

gor181 avatar gor181 commented on May 5, 2024

hey @iarry

have you tried https://github.com/gor181/react-chartjs-2#custom-size ?

Cheers,

from react-chartjs-2.

iarry avatar iarry commented on May 5, 2024

Yep, I set maintainAspectRatio: false. I can make the graph grow larger, but it won't go below 497px x 200px

from react-chartjs-2.

iarry avatar iarry commented on May 5, 2024

I managed to change the width and height with CSS on the canvas, but it needed !important tags.

from react-chartjs-2.

huyvohcmc avatar huyvohcmc commented on May 5, 2024

Did anybody find a way to fix this issue? I mean by passing the width and height directly as props?

<Pie
	data={data}
	width={100}
	height={50}
	options={{
		maintainAspectRatio: false
	}}
/>

doesn't work at all. The canvas width and height is always 678 and 948.

from react-chartjs-2.

solaomosola avatar solaomosola commented on May 5, 2024

I have the same issue, using Pie.

from react-chartjs-2.

MikeRoberts2008 avatar MikeRoberts2008 commented on May 5, 2024

I'm having this same issue, the height is respected but the width is ignored:

<Line data={data} width={200} height={200} options={{ maintainAspectRatio: false }} />

from react-chartjs-2.

nhuthan avatar nhuthan commented on May 5, 2024

I have same issue, using doughnut

from react-chartjs-2.

jayaramsurya avatar jayaramsurya commented on May 5, 2024

when i decrease the width the screen , the graph width can't change but height will change . I tired many solution nothing works

from react-chartjs-2.

cention-sany avatar cention-sany commented on May 5, 2024

May be this can help #334 (comment)

from react-chartjs-2.

DPTeamMember avatar DPTeamMember commented on May 5, 2024

@KennethChiu123

<Line data={data} width={200} height={200} options={{ maintainAspectRatio: false }} />
This worked for me. responsive:false was not necessary for me.

Thank you.

from react-chartjs-2.

alex-drocks avatar alex-drocks commented on May 5, 2024

data={data} width={200} height={200} options={{ maintainAspectRatio: false ,responsive:false }}

This solution worked for me but also this:
<Bar data={data} width={1900} height={900} options={{maintainAspectRatio: true, responsive: true}}/>

from react-chartjs-2.

shubhamsharma2k avatar shubhamsharma2k commented on May 5, 2024

This is the solution https://react-chartjs-2.js.org/faq/maintain-aspect-ratio/

from react-chartjs-2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.