Skip to content


You can register handlers for various events. There are pointer events (click, pointermove), animation events (begin, update, complete), and rendering events that are called before rendering the chart elements. Handlers can be registered/unregistered with the on, off method pair.

We are registering a handler for the click event which will show an alert block with information about the clicked chart element.

Info - How to setup Vizzu

In HTML, create a placeholder element that will contain the rendered chart.

  <div id="myVizzu">

In JavaScript, initialize and configure the chart:

import Vizzu from ''
import data from ''

let chart = new Vizzu('myVizzu')

await chart.initializing

    data: data,
    config: {
        channels: {
            y: {
                set: ['Popularity', 'Kinds']
            x: {
                set: ['Genres']
            color: {
                set: ['Kinds']
            label: {
                set: ['Popularity']

function clickHandler(event) {

chart.on('click', clickHandler);

Unregistering the previously registered handler.'click', clickHandler);

Here we override the axis label color for Jazz to red and all others to gray.

function labelDrawHandler(event) {
    event.renderingContext.fillStyle =
        ( === 'Jazz') ? 'red' : 'gray';

chart.on('plot-axis-label-draw', labelDrawHandler);

Unregistering the previously registered handler.'plot-axis-label-draw', labelDrawHandler);

The default behaviour of all events can be blocked by calling the event's preventDefault method. Here we block the drawing of the Vizzu logo in the bottom right corner of the chart.

function logoDrawHandler(event) {

chart.on('logo-draw', logoDrawHandler);

Unregistering the previously registered handler.'logo-draw', logoDrawHandler);

You can also add a background image to the chart using the preventDefault method.

const image = new Image();

function backgroundImageHandler(event) {
    event.renderingContext.drawImage(image, 0, 0,
        event.detail.rect.size.x, event.detail.rect.size.y);

image.src = 'data:image/gif;base64,R0lGODlhAwACAPIAAJLf6q/i7M/r8un0+PT6+/n8/QAAAAAAACH5BAQAAAAALAAAAAADAAIAAAMEWBMkkAA7';
image.onload = () => {
    chart.on('background-draw', backgroundImageHandler);

Unregistering the previously registered handler.'background-draw', backgroundImageHandler);