score:1
I'm not sure about the offset
working as you expect. Note that even on the first graph, the yaxis is not doing that padding.
I'd look into suggestedMin
and suggestedMax
as shown below:
var options, ctx;
options = {
type: 'line',
data: {
labels: [0, 1, 2],
datasets: [{
data: [0, 1, 0]
}]
},
options: {
scales: {
xAxes: [{
offset: true
}],
yAxes: [{
offset: true
}]
}
}
}
ctx = document.getElementById('chart1').getContext('2d');
new Chart(ctx, options);
options = {
type: 'scatter',
data: {
datasets: [{
data: [{
x: 0,
y: 0
}, {
x: 1,
y: 1
}, {
x: 2,
y: 0
}]
}]
},
options: {
scales: {
xAxes: [{
display: true,
ticks: {
suggestedMin: -1, // minimum will be -1, unless there is a lower value.
suggestedMax: 3
}
}],
yAxes: [{
display: true,
ticks: {
suggestedMin: -1, // minimum will be -1, unless there is a lower value.
suggestedMax: 2
}
}]
}
}
}
ctx = document.getElementById('chart2').getContext('2d');
new Chart(ctx, options);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.js"></script>
<body>
<canvas id="chart1" height="100"></canvas>
</body>
<body>
<canvas id="chart2" height="100"></canvas>
</body>
Source: stackoverflow.com
Related Query
- How to offset axes in a scatter plot?
- How do you plot scatter graph with chart.js
- How to create a scatter plot where x-axis represents a day by hours with datetime object? chartJS
- how to add color to each data in chartjs scatter plot
- How to add text inside scatter plot using Chart.js?
- How to run Chart.js samples using source code
- How to use two Y axes in Chart.js v2?
- how to plot multiple time series in chartjs where each time series has different times
- How to add an offset to a dataset in Chart js
- chartjs: How to plot multi-line chart with irregular intervals
- time scatter plot w/ chart.js
- Using Chart.Js to plot a scatter plot from an Array
- How to set ticks on axes dynamically with chart.js?
- Mixed chart scatter plot with chart.js
- Show image instead a point in a ChartJS scatter plot
- How to add ChartJS code in Html2Pdf to view image
- How to plot dates in Chart.js
- How to include many datapoints to plot in chart.js
- ChartJs Force scatter plot to be square shaped
- How do I force Chart.js axes min and max with react-chartjs-2?
- How to access or get value of specific graph on chart plot by click event?
- Chart.js: how to listen to hover/click events outside of plot area?
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- How to skip x Axes labels in ChartJS
- How to plot a line chart in ChartJS?
- How to update a react-chartjs-2 plot using useState()
- How to add null value rows into pandas dataframe for missing years in a multi-line chart plot
- How to use same data / labels on two y axes in Chart.js
- How do I remove cartesian axes from chart js?
- Flask with Chart JS Scatter Plot struggle
More Query from same tag
- Unable to get Line Chart tooltip on ChartJS
- How to send data to chart js using angular
- Unable to see the lines in chart.js
- react-chartjs-2 Line Chart not updating with State
- Issues getting JSON string for chart.js data
- Not able to see values on bar chart
- how to align count text center in horizontal bar in the Chart.js?
- How to create an array of objects dynamically in javascript for a pie chart
- Chart.js v3.60 - Add % symbol to the end of the tooltip label on a doughnut chart?
- Chart.js dynamic updates with data from database
- How to displays item names from the database using a monthly or yearly chart PHP MySQL
- I'm getting the error "TypeError: Cannot read property 'extend' of undefined" when trying to import chartjs-plugin-datalabels
- How to destroy a canvas using Id and add new canvas to the same id
- Chart.js: Disable Y-Axis, when graph is disabled via Legend
- How can I make my backgroundColor in Chart.js match up with a reversed order y axis?
- Combine multiple columns values to one label in chart.js
- Chart JS not re rendering in Laravel Livewire
- Chart.js: evenly distribute ticks when using maxTicksLimit
- pan on chart.js also zoom on line charts
- Bootstrap Card Render Problem in Google Chrome
- Chartjs tick color different at zero
- Charts.js Pie Chart
- how to remove duplicate data set labels in chartjs
- Facing difficulty in opening a dialog from onClick event on a pie chart in angular 8 (using chart.js)
- How to give break line in data label
- High and low points on chart getting cut off
- automatic legend translation on chart.js
- Parsing json in jQuery error
- How to update Chart.js based on dropdown list?
- Chart.js line chart not showing in Google Chrome canvas(only in Microsoft Edge)