I want to draw minor gridlines in the chart drawn by the following below to get the result similar to x-axis in following image (except instead of tick value shown in simple number instead of power i.e. instead 10^0 it should show 1 and instead of 10^1 it should show 10 and so on. Image is os meant to show just the gridlines on x-axis):
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<title>Chart</title>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=Edge'>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-colorschemes"></script>
<style>
body { margin: 0; padding: 0; }
#container { width: 100%; }
</style>
</head>
<body>
<div id='container'>
<canvas id='myChart'></canvas>
</div>
<script>
Chart.defaults.global.animation.duration = 1000;
Chart.defaults.global.animation.easing = 'linear';
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['10','2000','30000','50000','60000','700000',],
datasets: [
{label: 'ABC' ,
fill: true ,
data: [
{ x: '10', y: 2 },
{ x: '2000', y: 4 },
{ x: '30000', y: 7 },
{ x: '50000', y: 8 },
{ x: '60000', y: 8.5 },
{ x: '700000', y: 9 }
],
borderWidth: 1},
]
},
options: {
aspectRatio: 1.6,
title: {
display: true,
position: 'top',
text: 'Ref Data'
},
legend: {
display: true,
position: 'right',
},
scales: {
yAxes: [{
id: 'first-y-Axis',
display: true,
scaleLabel: {
display: true,
labelString: 'Demo y-axis'
}
}],
xAxes: [{
id: 'first-x-Axis',
display: true,
type: 'logarithmic',
scaleLabel: {
display: true,
labelString: 'Demo x-axis'
},
ticks: {
//min: 0 ,
//max: 700000
callback: function (value, index, values) {
if (Math.log10(value) % 1 === 0) { return value; }
}
}
}]
},
plugins: {
colorschemes: {
scheme: 'brewer.Paired12'
}
}
}
});
</script>
</body>
</html>
Similar solution is also discussed in the post linked here but the code used in that post is very complex and I am unable to understand and make it work in my code as I don't know much about JavaScript. Just trying to make this graph for ine application. I'll thankful if someone here can modify my code or help me modify the code to get minor gridlines like the image or in the post linked above (except minor gridlines are created for y-axis in the post but I want for x-axis).
Best Regards
ticks
callback
returns""
(an empty string), for those ticks that don't have a label. The code in that post was about styling the minor lines and filtering the occasional unwanted grid line at such values as 15 or 150.