About 4,470,000 results
Open links in new tab
  1. How to Set Height and Width of a Chart in Chart.js

    Aug 1, 2024 · we can use .resize(width, height) method to resize our chart by invoking it using the two parameters as height and the width. Syntax: function resize() {myChart.resize(600, 450);}; Example: The below code example uses the resize() method to set height and width of the chart in chart.js. HTML

  2. javascript - Set height of chart in Chart.js - Stack Overflow

    Jan 31, 2017 · var canvas = document.getElementById(id); canvas.width = window.innerWidth; canvas.height = window.innerHeight / 2.5; var ctx = canvas.getContext('2d'); Set the width and the height before you create the chart, adjust the height as you wish.

  3. javascript - Width and Height in Chart.js - Stack Overflow

    Feb 22, 2019 · There are many ways to specify the canvas' height and width. But what's the difference between the two methods you tried? Well, the full explanation can be found here Canvas is stretched when using CSS but normal with "width" / "height" properties.

  4. Line Chart | Chart.js

    Apr 15, 2025 · Line charts can be configured into stacked area charts by changing the settings on the y-axis to enable stacking. Stacked area charts can be used to show how one data trend is made up of a number of smaller pieces.

  5. Chart.js Line Chart - GeeksforGeeks

    Dec 13, 2023 · Chart.js line chart is a visual representation of data points connected by straight lines, depicting trends or patterns in a dataset over time or categories. Syntax: let myBarChart = new Chart(ctx, { type: 'line', data: data, options: options });

  6. Responsive Charts | Chart.js

    Apr 15, 2025 · Chart.js provides a few options to enable responsiveness and control the resize behavior of charts by detecting when the canvas display size changes and update the render size accordingly. Namespace: options. Resizes the chart canvas when …

  7. Setting Height & Width of JS Charts | JavaScript Chart Tips

    Oct 17, 2024 · You can specify the required height or width of your JavaScript chart using the height() and width() methods right inside the chart’s JS code. In Detail. For instance, add the following line of code to set the height of your JS chart as 50% with the help of the corresponding methods from the JavaScript API: chart.height("50%");

  8. Step-by-step guide | Chart.js

    Apr 15, 2025 · Artworks’ width and height are equally important so we’d like to make the chart width equal to its height as well. By default, Chart.js charts have the aspect ratio of either 1 (for all radial charts, e.g., a doughnut chart) or 2 (for all the rest).

  9. javascript - Charts.js sets canvas width/height to 0 and displays ...

    When I make the call to "new Chart" my canvas height and width are set to 0 as I can see in the inspector. When I comment out this call my canvas has the proper width/height and displays as one would expect.

  10. [Chartjs]-Width and Height in Chart.js - TheCodersCamp

    Oct 1, 2023 · let line_chart = document.getElementById("line-chart"); new Chart(line_chart, { type: 'scatter', data: { datasets: [{ label: 'Sample Data', data: [{ x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 3 }] }], }, options: { responsive:true, } });

  11. Some results have been removed
Refresh