Skip to main content
freelanceshack.com

Back to all posts

How to Enable Zooming And Panning In Chart.js?

Published on
5 min read
How to Enable Zooming And Panning In Chart.js? image

Best Tools for Chart.js Interaction 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: CONVERT UNITS, TAP SIZES, AND MORE-NO CALCULATOR NEEDED!

  • DURABLE & LONG-LASTING: LAMINATED FOR PROTECTION AGAINST WEAR AND TEAR.

  • PORTABLE & CONVENIENT: PERFECT FOR BOTH GARAGE WORK 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 Plastic Pocket Chart (3-Pack) – Machinist Reference for Decimal Equivalents, Recommended Drill Sizes for Taps, and Useful Formulas

Morse Plastic Pocket Chart (3-Pack) – Machinist Reference for Decimal Equivalents, Recommended Drill Sizes for Taps, and Useful Formulas

  • DURABLE PLASTIC CHARTS: LONG-LASTING AND EASY TO CARRY ANYWHERE.
  • ALWAYS WITHIN REACH: KEEP ONE IN YOUR POCKET, TOOLBOX, AND DESK.
  • INSTANT ACCESS: SKIP THE HANDBOOK WITH QUICK-REFERENCE VISUALS.
BUY & SAVE
$16.99
Morse Plastic Pocket Chart (3-Pack) – Machinist Reference for Decimal Equivalents, Recommended Drill Sizes for Taps, and Useful Formulas
3 Multiplication Chart Pop It - Multiplication Game Board, 12x12 Times Table Math Game Board for Kids Learning, Educational Multiplication Machine Toy

Multiplication Chart Pop It - Multiplication Game Board, 12x12 Times Table Math Game Board for Kids Learning, Educational Multiplication Machine Toy

  • TRANSFORM MATH PRACTICE INTO A FUN, INTERACTIVE GAME FOR KIDS!
  • BOOST LEARNING WITH VISUAL AIDS AND ENGAGE YOUNG MINDS EFFECTIVELY.
  • PERFECT FOR ADHD; COMBINES FIDGETING AND MATH FOR FOCUSED LEARNING!
BUY & SAVE
$11.99
Multiplication Chart Pop It - Multiplication Game Board, 12x12 Times Table Math Game Board for Kids Learning, Educational Multiplication Machine Toy
4 JimKing Creative Color Wheel, Paint Mixing Learning Guide, Art Class Teaching Tool for Makeup Painting Tattoo,Blending Board Chart Color Mixed Guide Hardboard(9.25inch)

JimKing Creative Color Wheel, Paint Mixing Learning Guide, Art Class Teaching Tool for Makeup Painting Tattoo,Blending Board Chart Color Mixed Guide Hardboard(9.25inch)

  • SIMPLIFIES COLOR CHOICES WITH TWO-SIDED ROTATING WHEEL DESIGN.
  • IDEAL FOR ALL ARTISTS AND A PERFECT GIFT FOR CREATIVE ENTHUSIASTS!
  • DURABLE UV-COATED COVER PROTECTS COLORS FROM FADING AND MOISTURE.
BUY & SAVE
$4.99
JimKing Creative Color Wheel, Paint Mixing Learning Guide, Art Class Teaching Tool for Makeup Painting Tattoo,Blending Board Chart Color Mixed Guide Hardboard(9.25inch)
5 Fuyoooo 3 Pcs Communication Boards for Non Verbal Adults 11.81 x 8.27 Inches Colorful Picture Symbol Communication Cards Speech Therapy Tools for Autism Aphasia Stroke Patients Hospital Care Home Use

Fuyoooo 3 Pcs Communication Boards for Non Verbal Adults 11.81 x 8.27 Inches Colorful Picture Symbol Communication Cards Speech Therapy Tools for Autism Aphasia Stroke Patients Hospital Care Home Use

  • CONVENIENT TRIPLE PACK: THREE BOARDS FOR VALUE AND EASY ACCESS ANYWHERE.

  • DIVERSE SYMBOLS: TAILORED DESIGNS HELP NON-VERBAL ADULTS EXPRESS NEEDS.

  • PORTABLE SIZE: LIGHTWEIGHT AND COMPACT FOR COMMUNICATION ON-THE-GO.

BUY & SAVE
$8.99 $9.99
Save 10%
Fuyoooo 3 Pcs Communication Boards for Non Verbal Adults 11.81 x 8.27 Inches Colorful Picture Symbol Communication Cards Speech Therapy Tools for Autism Aphasia Stroke Patients Hospital Care Home Use
6 Chivertion 36 Pcs I Need Help Mini Flip Charts Star Classroom Management Need Tools Behavior Self Assessment Cards for Teachers School Educational and Learning Activities Supplies(Classic Style)

Chivertion 36 Pcs I Need Help Mini Flip Charts Star Classroom Management Need Tools Behavior Self Assessment Cards for Teachers School Educational and Learning Activities Supplies(Classic Style)

  • EMPOWER SELF-EXPRESSION: COLOR-CODED CARDS HELP STUDENTS COMMUNICATE NEEDS.

  • ENHANCED CLASSROOM MANAGEMENT: SIMPLIFIES MONITORING STUDENT STATUS DISCREETLY.

  • DURABLE & COMPACT DESIGN: LIGHTWEIGHT AND STANDS EASILY ON DESKS FOR VISIBILITY.

BUY & SAVE
$12.99 $13.99
Save 7%
Chivertion 36 Pcs I Need Help Mini Flip Charts Star Classroom Management Need Tools Behavior Self Assessment Cards for Teachers School Educational and Learning Activities Supplies(Classic Style)
7 Eamay Small Group Management Pocket Chart with 84 Cards to Keep Small Groups Organized and On Task, Classroom Jobs Pocket Chart and Teacher Must Haves (BLACK)

Eamay Small Group Management Pocket Chart with 84 Cards to Keep Small Groups Organized and On Task, Classroom Jobs Pocket Chart and Teacher Must Haves (BLACK)

  • ORGANIZE SMALL GROUPS EFFICIENTLY WITH EASY-TO-MOVE NAME CARDS.
  • DURABLE DESIGN WITH HIGH-QUALITY MATERIALS FOR LONG-LASTING USE.
  • INCLUDES EVERYTHING NEEDED FOR CUSTOMIZED GROUP MANAGEMENT SUPPORT.
BUY & SAVE
$18.99
Eamay Small Group Management Pocket Chart with 84 Cards to Keep Small Groups Organized and On Task, Classroom Jobs Pocket Chart and Teacher Must Haves (BLACK)
+
ONE MORE?

To enable zooming and panning in Chart.js, you need to use the Chart.js plugin called 'chartjs-plugin-zoom'. This plugin allows users to zoom in and out on the chart by scrolling up and down, as well as panning by dragging the chart area. To enable this functionality, you first need to include the plugin in your HTML file. Then, in your Chart.js configuration options, you can add the 'plugins' property and specify 'zoom' as one of the plugins. This will activate the zooming and panning feature for your chart, allowing users to manipulate the view of the data easily.

How to enable keyboard shortcuts for zooming and panning in Chart.js?

To enable keyboard shortcuts for zooming and panning in Chart.js, you can use the built-in plugins available in Chart.js. Here are the steps to enable keyboard shortcuts for zooming and panning:

  1. Add the zoom plugin to your Chart.js configuration:

import Chart from 'chart.js'; import 'chartjs-plugin-zoom';

// Enable zoom plugin Chart.register(ChartZoom);

  1. Add the pan and zoom options to your chart configuration:

const config = { type: 'line', data: { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'My Dataset', data: [10, 20, 30, 40, 50, 60, 70], borderWidth: 1 }] }, options: { plugins: { zoom: { zoom: { wheel: { enabled: true }, pinch: { enabled: true }, mode: 'xy' }, pan: { enabled: true, mode: 'xy' } } } } };

  1. Create a new Chart instance with the configured options:

new Chart(ctx, config);

Now, you should be able to use keyboard shortcuts for zooming and panning in your Chart.js chart. You can customize the keyboard shortcuts and behavior by modifying the zoom and pan options in the chart configuration.

How to implement zoom and pan functionality in Chart.js?

To implement zoom and pan functionality in Chart.js, you can use the chartjs-plugin-zoom plugin. Here's how you can do it:

  1. First, install the plugin using npm:

npm install chartjs-plugin-zoom --save

  1. Once the plugin is installed, you can include it in your Chart.js configuration options like this:

options: { zoom: { enabled: true, mode: 'xy' }, pan: { enabled: true, mode: 'xy' } }

  1. You can specify the mode option as 'x', 'y', or 'xy' to enable zooming or panning on specific axes.
  2. Additionally, you can listen to the zoom and pan events to perform additional actions when zooming or panning occurs:

var chart = new Chart(ctx, { type: 'line', data: data, options: { zoom: { onZoom: function(event) { // Do something on zoom event }, }, pan: { onPan: function(event) { // Do something on pan event }, }, } });

With these steps, you can enable zoom and pan functionality in Chart.js using the chartjs-plugin-zoom plugin.

What are the default zoom and pan settings in Chart.js?

The default zoom and pan settings in Chart.js are as follows:

  • Zoom: enabled (allows users to zoom in and out on the chart by scrolling or dragging)
  • Pan: enabled (allows users to click and drag to move the chart within its container)

These settings can be customized or disabled using the options available in Chart.js.

How to adjust zoom levels in Chart.js?

To adjust zoom levels in Chart.js, you can use the zoomEnabled and zoomType properties in the options object of your chart configuration.

Here's an example of how to enable zooming with a rectangular selection in a line chart:

var chartConfig = { type: 'line', data: { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'My Dataset', data: [10, 20, 30, 40, 50, 60, 70] }] }, options: { pan: { enabled: true, mode: 'xy' }, zoom: { enabled: true, mode: 'xy' } } };

var myChart = new Chart(document.getElementById('myChart'), chartConfig);

In this example, we have set zoomEnabled to true and zoomType to 'xy'. This allows users to zoom in and out on both the x and y axes by selecting a rectangular area on the chart.

You can further customize the zoom behavior by changing the mode property to 'x', 'y', or 'xy', depending on whether you want to zoom in one direction or both directions.

You can also adjust the sensitivity of the zooming by setting the panSpeed and zoomSpeed properties in the options object.

Overall, by using the zoomEnabled and zoomType properties along with the appropriate options, you can easily adjust zoom levels in Chart.js to provide a better user experience for your users.

How to restrict zoom and pan in Chart.js?

To restrict zoom and pan in Chart.js, you can disable the zoom and pan interactions by setting the appropriate options in the chart configuration. Here's how you can do it:

  1. Disable zooming: To disable zooming in Chart.js, you can set the zoom options to false in the chart configuration. This will prevent users from zooming in and out of the chart.

options: { interaction: { mode: 'index', intersect: false, }, plugins: { zoom: { zoom: { wheel: { enabled: false }, pinch: { enabled: false }, mode: 'none', } } } }

  1. Disable panning: To disable panning in Chart.js, you can set the pan options to false in the chart configuration. This will prevent users from dragging the chart to pan around.

options: { plugins: { zoom: { pan: { enabled: false } } } }

By setting these options in the chart configuration, you can restrict zooming and panning in Chart.js.