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
- plot a point on top on line chart in chartjs
- Line chart is not being displayed in Chart.js
- Chart.js: Line displayed thinner than defined
- Chart.js - Avoid line to goes to zero and remove dot for this situation
- PHP string data passed to Chart.js not rendering well
- Chart.js plugin annotation line shadow
- chartjs - How to access chart instance in a custom tooltip callback
- chartjs bar chart align the legend to left position
- Change size of bubble radius without changing r value
- How to set lower and upper bound in react react-chartjs-2?
- Chart.js not stretching width as per data
- How to add text inside the doughnut chart using Chart.js version 3.2.1
- How to filter and add multiple datasets using Django and Chart.js
- how to see labels without losing middle text in doughnut chart
- Custom Legend ChartJS not showing the text decoration: line through
- trying to get minIndex and maxIndex from x-axis-0
- How to show bar chart labels clearly using ChartJS?
- How can I hide a chartjs chart?
- Do not rotate scale title at xAxis
- chart js: when all the values passed to data are zeros, nothing is showing
- How to maintain chartjs / ng2-charts gradient on window resize?
- How to mutate VueJS prop?
- return array from ajax
- Mixed chart scatter plot with chart.js
- Add space Between Columns in Bar chart. chartjs
- Display dataset values on bar ChartJs 2.1.6
- Parsing json in jQuery error
- ChartJS: How to dynamically create data arrays
- ChartJS creating var takes each character and outputs undefined
- plot a bar chart.js time series