score:0
I ran into this Chart.js bug, too.
A very recent fix is shown here.
You'd have to manually edit your Chart.js file src/controllers/controller.line.js
(For Angular 2, this file path will be located inside directory node_modules/chart.js/
.)
Or just wait for the next Chart.js release which will most likely contain the fix.
An alternative workaround is described in comment 1 of this bug ticket: https://github.com/chartjs/Chart.js/issues/4202
score:0
The options.layout.padding.top
solution didn't work for me (just added padding AFTER the line cut), so I extracted the high/low values from my data and used the suggestedMin
and suggestedMax
config params like this:
var suggestedMin = {MIN};
var suggestedMax = {MAX};
options: {
scales: {
yAxes: [{
ticks: {
suggestedMin: suggestedMin - 1,
suggestedMax: suggestedMax + 1,
}
}]
}
}
score:0
I had my data values stored in array. So I set my max and min values like this:
var _array = [1,3,2];
var suggestedMax = Math.max.apply(Math,_array); // 3
var suggestedMin = Math.min.apply(Math,_array); // 1
And than you can set
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: false,
suggestedMin: suggestedMin - 1,
suggestedMax: suggestedMax + 1,
}
}]
}
}
And it works, thank you.
score:0
This issue has been fixed in the Chart.js library. Just update it and you'll be fine.
score:1
I found this while making line graphs that had the legend displayed at the top. The only work around I found was to move the legend to the bottom
options: {
legend: {
position: 'bottom',
},
}
score:5
I used hardcode, just wide draw area at top and bottom. This code based on original Chart.canvasHelpers.clipArea.
const WIDE_CLIP = {top: 2, bottom: 4};
Chart.canvasHelpers.clipArea = function(ctx, clipArea) {
ctx.save();
ctx.beginPath();
ctx.rect(
clipArea.left,
clipArea.top - WIDE_CLIP.top,
clipArea.right - clipArea.left,
clipArea.bottom - clipArea.top + WIDE_CLIP.bottom
);
ctx.clip();
};
score:26
Edit/Update: As mentioned in the comments, the 5px value can more accurately be just half of whatever your line width value is, I belive default is 2px so in that case you would just want padding: { top: 1 }
There a layout.padding attribute you can set either in options or global. I had this same problem and set
options: {
layout: {
padding: {
top: 5
}
},
...
}
worked fine for me to not cut off the line http://www.chartjs.org/docs/#chart-configuration-layout-configuration
Source: stackoverflow.com
Related Query
- ChartJS Line chart cut off at the top and bottom
- Chart.js line chart is cut off at the top?
- How to get rid of the line on top of every point on a line chart (Chart.js)
- Chart js legend are being cut off if the bar height is equal to port height - chart js
- Data Labels are getting cut off on the top
- Remove the vertical line in the chart js line chart
- Moving vertical line when hovering over the chart using chart.js
- How do I prevent the scale labels from being cut off in chartjs?
- How to prevent first/last bars from being cut off in a chart with time scale
- line graph spot in the top middle of the bar graph
- Show X axis on top and bottom in line chart rendered with Chart.js 2.4.0
- 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?
- Rotate 90 degrees clockwise the scaleLabel (no ticks or labels) on a Chart.js line chart
- How to start the line graph from the left Y axis in a line/bar mixed chart (Chart.js)?
- Chart.js - Color specific parts of the background in a line chart
- Chart JS display Data Value on the top of the Bar
- Add a custom label to the top or bottom of a stacked bar chart
- How to show data values in top of bar chart and line chart in chart.js 3
- In Stacked horizontal bar chart how to remove the vertical line in Chart.js?
- High and low points on chart getting cut off
- Points cut at half at the edges of top and bottom, at chartjs
- How to change the label and grid line position on a timeseries chart in Chart.js 3?
- Having problems getting a line chart in Chartsjs to go *up* to 1, with bkg fill *under* the chart line
- Chart.js -> line chart -> multiple points with the same X
- How to change the chart line or area colors according to the user need?
- How to stop axis label from being cut off in chart JS?
- 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?
- increase the label size of a line chart in chart.js
More Query from same tag
- How to hide tooltip for selected datasets? - Chart.js v2.8
- Unable to Construct Stacked Vue-ChartJS Line Plot
- How to add labels for only some of the data point?
- Change 'points' on a line chart to donuts using Chart.js
- Laravel DB select statement. Query returns column name as result rather than values
- How to send data from struts2 to a javascript function to draw a chart
- Chart.js is not showing data
- Chart.js v3 after using of zoom plugin instance persist in memory
- Chart js: Update line chart having two data sets
- Combine multiple columns values to one label in chart.js
- Chart.js pie chart overflowing div
- react-chartjs error Cannot read property 'Chart' of undefined
- Remove Angularjs-Chart border and reduce chart arc thickness
- I want to show the value of label inside the pie graph. (vue-chartjs / pieceLabel)
- mysql sum query for chartjs
- How to change width of the chart using Chart.js
- Chartjs disable legend click does not work when condition is not evaluated
- ReactJS - Labeling multi dimension array with chartJS-2
- Chart JS - Make chart scrollable if too much data
- Chart.js dataset controller 'null' when chart drawn
- Chart.js v2: How to make tooltips always appear on line chart?
- Mapping issue on Chart Js Bar Chart
- How to set 3 axis in google chart (V-Axis Left as Qty, V-Axis Right as Series Column and H-Axis as TimeOrder)?
- How to display label on side of doughnut in chart js
- Chart.js multiTooltip labels
- Streaming Real-time data with react and chartjs-plugin-streaming paused
- first and last value is not displaying in chart.js used with django
- update chart data called through ajax via PHP, MySQL
- React/Chartjs change data with a button
- How can i add multiple dataset in chart.js package in Laravel