I have used following graph config to render graph:
{
type: 'horizontalBar',
indexAxis: 'y',
barThickness: 12,
scales: {
x: {
suggestedMax: 6,
suggestedMin: 0,
grid: {
display: false,
drawBorder: false,
},
ticks: {
stepSize: 2,
callback: function (value, index, ticks) {
return value ? value + 'h' : value;
},
}
},
y: {
type: 'category',
grid: {
drawBorder: false,
borderDash: [4, 3],
color: "#C2C8CD",
drawTicks: false,
offset: false,
},
ticks: {
}
}
}
What I'm getting using above configuration.

what I want:
Kindly help to render this graph using react-chartjs-2.

If what you want to achieve is to have the grid lines pass just under each bar, that is not a standard feature, since the grid lines pass either through the middle of the bar (with
offset: false) or through the middle of the space between bars.You can use
chartjs-plugin-annotationto draw annotation lines instead of grid lines; short of that I can think of two ways to do that: one using a trick, the other hacky.The trick is to add an empty dataset after your actual dataset. That will allocate an empty space on y axis for a bar of this dataset under each of the real bars. You'll also have to make some adjustments: set
options.scales.y.ticks.alignto'end'(or set a matching value foroptions.scales.y.ticks.labelOffset, see the docs) to correctly align the tick labels; disable (filter out) the legend entry for the phantom dataset; adjust theyposition of thexscale.Here's a set of options doing that - I used comments to remove wrong or superfluous options from your post:
The hacky solution would be based on a plugin that moves the bars so they are on top of the grid line; that move can be done in the
beforeDatasetDrawhook, but care should be taken such that each bar is moved moved only once, while thebeforeDatasetDrawhandler might be called several times.