yorkshireinteractive / chartist-bar-labels

A simple Chartist plugin to put labels on top of bar charts
http://yorkshireinteractive.github.io/chartist-bar-labels/
14 stars 2 forks source link

Positioning the numbers directly above the bars #11

Closed s22-tech closed 1 year ago

s22-tech commented 1 year ago

Does anyone know how to position the values directly above the vertical bars instead of being printed in the middle of them? I can get them to print above the bars, but they're all at the same level - not right above each bar. Hopefully that makes sense.

JellyBool commented 1 year ago

Try initiate your plugins like below:

 Chartist.plugins.ctBarLabels({
                        position: {
                            y: function (data) {
                                return data.y2 - 5 // Change this number to set the 'margin' pixel above your bar.
                            }
                        },
                        labelOffset: {
                            y: 5
                        }
                    })
s22-tech commented 1 year ago

Thank you.