score:10
Accepted answer
you where almost there, in v3 by default line charts dont fill so you will need to set fill: true
example
var ctx = document.getelementbyid('chart').getcontext('2d');
var gradient = ctx.createlineargradient(0, 0, 0, 300);
gradient.addcolorstop(0, 'rgba(224, 195, 155, 1)');
gradient.addcolorstop(1, 'rgba(100, 100, 0,0)');
var mychart = new chart(ctx, {
type: 'line',
data: {
labels: ['red', 'blue', 'yellow', 'green', 'purple', 'orange'],
datasets: [{
backgroundcolor: gradient,
label: 'numbers',
fill: true,
data: [12, 19, 3, 5, 2, 3],
}]
},
options: {
scales: {
y: {
beginatzero: true
}
},
tension: 0.3
}
});
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.3.2/dist/chart.min.js"></script>
<canvas id="chart" width="800" height="400"></canvas>
Source: stackoverflow.com
Related Query
- How to create a gradient fill line chart in latest Chart JS version (3.3.2)?
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- How to add gradient background to Line Chart [vue-chart.js]
- How to add area with break on line chart with fill color
- How do I create stacked chart with Chart.js version 2.0.0-beta
- how can i use chart.js to create a chart that has one time series line and one linear line on it at the same time?
- How to create a line chart indicating which month a user wrote more or less blogs?
- How to create a line on a chart using chartjs-plugin-annotation
- How to bind data from Controler to chartjs line chart to create it as dynamic?
- how to create line chart using chart.js in angular 2+
- Chart.js - How to set a line chart dataset as disabled on load
- create a multi line chart using Chart.js
- How to add an on click event to my Line chart using Chart.js
- Chart.js how to show cursor pointer for labels & legends in line chart
- How to display Line Chart dataset point labels with Chart.js?
- chart js how to fill legend box with colour
- How to create datasets dynamically for chart.js Line chart?
- How to add second Y-axis for Bar and Line chart in Chart.js?
- How to create stacked bar chart using react-chartjs-2?
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- How to display value of only one datapoint in line chart
- How to align Chart.JS line chart labels to the center
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How can I remove extra whitespace from the bottom of a line chart in chart.js?
- How can I create a time series line graph in chart.js?
- How to create single value Doughnut or Pie chart using Chart.js?
- how to create multiple chart on one component vue
- (Vue, ChartJS) Create gradient background for chart from child component canvas context
- How to draw Horizontal line on Bar Chart Chartjs
- how to set chart.js grid color for line chart
More Query from same tag
- Chart.js - How to display all bars as different datasets(same behaviour as doughnut)
- Missing Tooltip for some data points using chartjs
- Can't generate multi-axis combo chart (bar/line) using chart.js 2.7
- Chart.js: Display Custom Tooltips, always visible on stacked bar-chart
- Chart.JS Not Formatting Y-Axis-1 Properly
- Chart.js animations when updating chart data
- In Chart.js, how do I hide certain axis labels from a stacked bar chart?
- Setting max, min and stepSize values in a Chart.js graph
- Custom text in tooltip and legend: ChartJs
- Multiple add in multiple sql request?
- Chart.js More than 1 charts on same web page
- Problem creating scatter graph using chart.js
- Catch event of show and hide dataset at chart.js
- ChartJS, add new dataset
- in line chart, line is going beyond height when I remove y axis
- Chart js data decimation not working, parsing issue
- Need Clarity on Chartjs - Asp.NetMVC or Vue-ChartJS -Asp.Net MVC
- Chart.js Currency Tooltip
- ChartJS line chart x = y not rendering astraight line
- Import data from Excel and use in Chart.js
- Show highest value untop of a bars when dataset is stacked (chartjs)
- How can I fasten up the Chart.js graph generation from JQuery over PHP and mySQL?
- Chart.js stacked line chart with differently styled sections
- reset the zoom to the initial in chart.js?
- vue-chart.js : Data available as computed properties, but not showing in chart
- Chartjs backgroundColor for line chart does not appear in Vue app
- Chart.js Clipping on Top of Line Graph
- Chart.js - access yAxes properties
- Multi-colored legend stacked bar chart Chartjs
- Is there anyway to remove the dots for points from angularjs charts