Skip to main content
wpcrux.com

Back to all posts

How to Customize Horizontal Bar In Chart.js?

Published on
7 min read
How to Customize Horizontal Bar In Chart.js? image

Best Chart.js Customization Tools to Buy in October 2025

1 NELOMO 11.8” X 7.9” Toolbox Reference Card Toolbox Accessories Conversion Chart Card SAE Metric Ruler Standard Metric Conversion Charts Tap Drill Sizes Wrench Conversion Chart

NELOMO 11.8” X 7.9” Toolbox Reference Card Toolbox Accessories Conversion Chart Card SAE Metric Ruler Standard Metric Conversion Charts Tap Drill Sizes Wrench Conversion Chart

  • ALL-IN-ONE REFERENCE: QUICK CONVERSIONS FOR TOOLS & MEASUREMENTS!
  • DURABLE DESIGN: TOUGH, LAMINATED CARD WITHSTANDS TOOL WEAR!
  • PORTABLE & VERSATILE: PERFECT FOR GARAGE AND OUTDOOR PROJECTS!
BUY & SAVE
$5.99
NELOMO 11.8” X 7.9” Toolbox Reference Card Toolbox Accessories Conversion Chart Card SAE Metric Ruler Standard Metric Conversion Charts Tap Drill Sizes Wrench Conversion Chart
2 MORSE CUTTING TOOLS Heavy Duty Large Plastic Wall Chart - Decimal Equivalents, Recommended Drill Sizes for Taps, and Useful Formulas

MORSE CUTTING TOOLS Heavy Duty Large Plastic Wall Chart - Decimal Equivalents, Recommended Drill Sizes for Taps, and Useful Formulas

  • DURABLE .023 HEAVY-DUTY PLASTIC FOR LONG-LASTING USE.
  • EASY-TO-READ TAP DRILL SIZES IN INCH, METRIC, AND PIPE THREADS.
  • CONVENIENT WALL MOUNTING WITH THREE PUNCHED HOLES INCLUDED.
BUY & SAVE
$35.95
MORSE CUTTING TOOLS Heavy Duty Large Plastic Wall Chart - Decimal Equivalents, Recommended Drill Sizes for Taps, and Useful Formulas
3 HIPPOTALE Chores Chart for Kids - Daily Routine Chart for Kids with Checklist & Stickers, Magnetic Kids Chore Chart - Chore Board Visual Schedule for Kids with Autism & Best ADHD Tools for Kids

HIPPOTALE Chores Chart for Kids - Daily Routine Chart for Kids with Checklist & Stickers, Magnetic Kids Chore Chart - Chore Board Visual Schedule for Kids with Autism & Best ADHD Tools for Kids

  • CUSTOMIZE CHORES WITH 120 COLORFUL ACTIVITY AND 12 BLANK CARDS!
  • IDEAL FOR ALL AGES: FUN VISUAL CHARTS FOR KIDS, ADULTS, AND PETS!
  • DURABLE, MAGNETIC, AND PORTABLE FOR EASY ORGANIZATION EVERYWHERE!
BUY & SAVE
$11.98
HIPPOTALE Chores Chart for Kids - Daily Routine Chart for Kids with Checklist & Stickers, Magnetic Kids Chore Chart - Chore Board Visual Schedule for Kids with Autism & Best ADHD Tools for Kids
4 Large Magnetic Reward Chart for Kids - 127 Pre-Written Stickers (Including Potty Training) + 30 Customizable Chores - Behavior, Responsibility & Incentive Routine Star Chart for Fridge (1 Kid Version)

Large Magnetic Reward Chart for Kids - 127 Pre-Written Stickers (Including Potty Training) + 30 Customizable Chores - Behavior, Responsibility & Incentive Routine Star Chart for Fridge (1 Kid Version)

  • CUSTOMIZABLE TASKS WITH 30 DRY-ERASE TAGS FOR ENDLESS FUN!
  • STRONG MAGNETIC STARS REWARD KIDS INSTANTLY, BOOSTING MOTIVATION!
  • DESIGNED BY EXPERTS TO ENHANCE ROUTINES AND PROMOTE INDEPENDENCE!
BUY & SAVE
$39.95
Large Magnetic Reward Chart for Kids - 127 Pre-Written Stickers (Including Potty Training) + 30 Customizable Chores - Behavior, Responsibility & Incentive Routine Star Chart for Fridge (1 Kid Version)
5 Pajean 253 Pcs Student Behavior Pocket Chart for Classroom Behavior Management Resources Track Reward Bulletin Board Customizable Class Jobs for Home Preschool Daycare Back to School Teacher Supplies

Pajean 253 Pcs Student Behavior Pocket Chart for Classroom Behavior Management Resources Track Reward Bulletin Board Customizable Class Jobs for Home Preschool Daycare Back to School Teacher Supplies

  • VIBRANT VISUALS ENHANCE ENGAGEMENT, REINFORCING POSITIVE BEHAVIOR!

  • COMPREHENSIVE SET MEETS ALL YOUR CLASSROOM MANAGEMENT NEEDS!

  • DURABLE, WATERPROOF CARDS ENSURE LONG-LASTING CLASSROOM DECOR!

BUY & SAVE
$24.99 $28.99
Save 14%
Pajean 253 Pcs Student Behavior Pocket Chart for Classroom Behavior Management Resources Track Reward Bulletin Board Customizable Class Jobs for Home Preschool Daycare Back to School Teacher Supplies
6 CRAFTYCOO Magnetic Checklist Chore Board with Chore Sticker Book, Chores Chart for Kids, Set of 2 Magnetic Customizable Chore Charts with Insert Paper and 212 Stickers, Chore Chart for Multiple Kids

CRAFTYCOO Magnetic Checklist Chore Board with Chore Sticker Book, Chores Chart for Kids, Set of 2 Magnetic Customizable Chore Charts with Insert Paper and 212 Stickers, Chore Chart for Multiple Kids

  • ENGAGING VISUALS: 212 COLORFUL STICKERS SPARK EXCITEMENT IN KIDS!

  • VERSATILE USE: FUNCTIONS AS A CHORE CHART, TO-DO LIST, OR VISUAL SCHEDULE.

  • EASY TRACKING: SMOOTH BUTTONS SIMPLIFY CHORES FOR KIDS AND ADULTS!

BUY & SAVE
$13.99
CRAFTYCOO Magnetic Checklist Chore Board with Chore Sticker Book, Chores Chart for Kids, Set of 2 Magnetic Customizable Chore Charts with Insert Paper and 212 Stickers, Chore Chart for Multiple Kids
7 BOHEMIABY Objectives Board for Classroom, Learning Targets Display Pocket Chart, Dry Erase Reusable Attendance Chart, Customizable Objectives, Objectives Pocket Chart for Teacher Student(Black)

BOHEMIABY Objectives Board for Classroom, Learning Targets Display Pocket Chart, Dry Erase Reusable Attendance Chart, Customizable Objectives, Objectives Pocket Chart for Teacher Student(Black)

  • STREAMLINE LEARNING: HELP STUDENTS SET AND ACHIEVE GOALS EFFORTLESSLY.

  • CUSTOMIZABLE & REUSABLE: ADJUSTABLE TARGETS FOR DIVERSE CLASSROOM NEEDS.

  • DURABLE DESIGN: HIGH-QUALITY MATERIALS WITHSTAND DAILY CLASSROOM USE.

BUY & SAVE
$16.99
BOHEMIABY Objectives Board for Classroom, Learning Targets Display Pocket Chart, Dry Erase Reusable Attendance Chart, Customizable Objectives, Objectives Pocket Chart for Teacher Student(Black)
8 Behavior Chart for Kids, Full Sized Wall Hanging Behavior Clip Chart, Classroom and Household Behavior Management Tool, Completely Customizable, Teaching Supplies Suitable for School, Home or Daycare

Behavior Chart for Kids, Full Sized Wall Hanging Behavior Clip Chart, Classroom and Household Behavior Management Tool, Completely Customizable, Teaching Supplies Suitable for School, Home or Daycare

  • PROFESSIONAL QUALITY: BRIGHT COLORS AND DURABLE LAMINATION FOR LASTING USE.

  • TIME-SAVING DESIGN: READY-TO-USE CHARTS WITH EASY ASSEMBLY AND SETUP.

  • CUSTOMIZABLE OPTIONS: DOUBLE-SIDED CARDS FOR PERSONALIZED BEHAVIOR TRACKING.

BUY & SAVE
$19.99 $24.95
Save 20%
Behavior Chart for Kids, Full Sized Wall Hanging Behavior Clip Chart, Classroom and Household Behavior Management Tool, Completely Customizable, Teaching Supplies Suitable for School, Home or Daycare
+
ONE MORE?

To customize the horizontal bar in Chart.js, you can follow these steps:

  1. Start by including the Chart.js library in your HTML file. You can either download it and include the script locally or use a CDN. Here's an example of including it via CDN:
  1. Create a canvas element in your HTML where the chart will be rendered. Give it an id or class for easy identification:

  1. In your JavaScript code, select the canvas element and create a new Chart instance with the desired configuration options. In this case, we will be customizing a horizontal bar chart:

const ctx = document.getElementById('myChart').getContext('2d'); const myChart = new Chart(ctx, { type: 'horizontalBar', data: { // Specify your data here }, options: { // Customize the chart visuals and behavior here } });

  1. Customize the chart's visuals and behavior by modifying the options object. Here are some common customization options: Axes: You can customize the x-axis and y-axis by modifying the scales property. For example, you can change the axis labels, font size, ticks, etc. Colors: Customize the colors of the bars, axis lines, grid lines, tooltips, etc. It can be done under the options property, usually with backgroundColor or borderColor. Bar thickness and spacing: Adjust the thickness of bars and the spacing between them using the barThickness and barPercentage options. Tooltips: Customize the appearance and content of tooltips using the tooltips property. You can modify their background color, font size, border color, etc. Animation: Define animation options such as duration, easing, and how the chart should animate.

These are just a few examples of customization options available in Chart.js. You can refer to the official Chart.js documentation for more detailed information on customizing horizontal bar charts.

How to format the value displayed on horizontal bars in chart.js?

To format the value displayed on horizontal bars in Chart.js, you can use the options object to define a custom tooltips callback function. This function will allow you to format the value to your desired format.

Here's an example of how you can format the value displayed on horizontal bars:

var ctx = document.getElementById('myChart').getContext('2d');

var myChart = new Chart(ctx, { type: 'horizontalBar', data: { labels: ['Value 1', 'Value 2', 'Value 3'], datasets: [{ label: 'Data', data: [10, 20, 30], backgroundColor: 'rgba(0, 123, 255, 0.5)', borderColor: 'rgba(0, 123, 255, 1)', borderWidth: 1 }] }, options: { tooltips: { callbacks: {
label: function(tooltipItem, data) { var value = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; return '$' + value; // format value to display '$' before the value } } }, scales: { xAxes: [{ ticks: { beginAtZero: true } }] } } });

In the above example, the tooltips callback function is defined as label. Inside this function, the value is accessed using data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]. The value is then formatted by concatenating '$' before the actual value.

You can adjust the formatting as per your requirement, such as adding decimal places, specifying units, or any other desired formatting.

How to add tooltips to horizontal bars in chart.js?

To add tooltips to horizontal bars in Chart.js, you can use the tooltips configuration option provided by the library.

Here is an example of how you can customize tooltips for a horizontal bar chart in Chart.js:

var ctx = document.getElementById('myChart').getContext('2d'); var myChart = new Chart(ctx, { type: 'horizontalBar', data: { labels: ['Label 1', 'Label 2', 'Label 3'], datasets: [{ data: [10, 20, 30], backgroundColor: ['red', 'green', 'blue'] }] }, options: { tooltips: { callbacks: { title: function(tooltipItem, data) { return data.labels[tooltipItem[0].index]; }, label: function(tooltipItem, data) { return 'Value: ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; } } } } });

In the above code:

  1. Initialize your chart by creating a new instance of Chart and pass the context of the canvas element (ctx).
  2. Set the type property to 'horizontalBar' to create a horizontal bar chart.
  3. Specify the data needed for your chart, including labels and datasets. In this example, we set three labels and provide corresponding data and background colors.
  4. Customize the tooltips using the options object. Inside the tooltips object, you can modify various aspects of the tooltips' appearance and behavior.
  5. Use the callbacks property to define custom functions for generating the tooltip's title and label. In this example, the title function returns the label of the bar, and the label function returns the value of the bar.

By utilizing the tooltips configuration, you can easily modify the tooltips' content and appearance as per your requirements.

How to adjust the spacing between bars in a grouped horizontal bar chart in chart.js?

To adjust the spacing between bars in a grouped horizontal bar chart in Chart.js, you can use the barPercentage and categoryPercentage options.

The barPercentage option allows you to adjust the width of the bars relative to the available space in the chart. It represents the width as a decimal number between 0 and 1, where 1 represents the full available space. By default, the value is set to 0.9.

The categoryPercentage option allows you to adjust the spacing between groups of bars. It represents the percentage as a decimal number between 0 and 1, where 1 represents the full available space. By default, the value is set to 0.8.

Here's an example of how to adjust the spacing between bars in a grouped horizontal bar chart:

var ctx = document.getElementById('myChart').getContext('2d'); var myChart = new Chart(ctx, { type: 'horizontalBar', data: { labels: ['Group 1', 'Group 2', 'Group 3'], datasets: [ { label: 'Bar 1', data: [10, 20, 30], backgroundColor: 'rgba(255, 99, 132, 0.5)' }, { label: 'Bar 2', data: [15, 25, 35], backgroundColor: 'rgba(54, 162, 235, 0.5)' } ] }, options: { scales: { xAxes: [{ ticks: { beginAtZero: true }, gridLines: { display: true } }], yAxes: [{ gridLines: { display: false } }] }, responsive: true, maintainAspectRatio: false, barPercentage: 0.6, // Adjust the width of the bars categoryPercentage: 0.7 // Adjust the spacing between groups of bars } });

In this example, the barPercentage is set to 0.6 to make the bars slightly narrower, and the categoryPercentage is set to 0.7 to increase the spacing between groups of bars. You can adjust these values according to your preference.

How to create a horizontal bar race chart in chart.js?

To create a horizontal bar race chart in Chart.js, you will need to follow these steps:

  1. Include the Chart.js library in your HTML file:
  1. Create a canvas element in your HTML file to hold the chart:

  1. Write JavaScript code to create and update the horizontal bar race chart:

// Get the canvas element var ctx = document.getElementById('horizontalBarRaceChart').getContext('2d');

// Create initial data for the chart var data = { labels: ['Bar 1', 'Bar 2', 'Bar 3', 'Bar 4'], datasets: [{ data: [10, 20, 30, 40], backgroundColor: 'rgba(0, 123, 255, 0.7)', borderColor: 'rgba(0, 123, 255, 0.7)', borderWidth: 1 }] };

// Create initial options for the chart var options = { responsive: true, maintainAspectRatio: false, scales: { xAxes: [{ ticks: { beginAtZero: true } }] } };

// Create the chart var chart = new Chart(ctx, { type: 'horizontalBar', data: data, options: options });

// Function to update the chart's data and animation function updateChartData() { // Update the data for the chart chart.data.datasets[0].data = [50, 30, 70, 90];

// Update the bar color chart.data.datasets[0].backgroundColor = 'rgba(0, 255, 0, 0.7)';

// Update the bar border color chart.data.datasets[0].borderColor = 'rgba(0, 255, 0, 0.7)';

// Update the chart chart.update(); }

// Call the updateChartData() function to update the chart's data and animation updateChartData();

  1. Customize and update the chart as needed using the updateChartData() function. You can modify the data, bar colors, border colors, labels, and any other aspects of the chart within this function.

That's it! You have now created a horizontal bar race chart using Chart.js.