Annotation plugin for Chart.js

Overview

chartjs-plugin-annotation.js

GitHub Workflow Status Coverage Status release npm (latest) documentation Awesome

An annotation plugin for Chart.js >= 3.0.0


This plugin needs to be registered. It does not function as inline plugin.


For Chart.js 2.4.0 to 2.9.x support, use version 0.5.7 of this plugin

This plugin draws lines, boxes, points, labels, polygons and ellipses on the chart area.

Annotations work with line, bar, scatter and bubble charts that use linear, logarithmic, time, or category scales. Annotations will not work on any chart that does not have exactly two axes, including pie, radar, and polar area charts.

Example Screenshot

View this example

Documentation

You can find documentation for chartjs-plugin-annotation at www.chartjs.org/chartjs-plugin-annotation.

Contributing

Before submitting an issue or a pull request to the project, please take a moment to look over the contributing guidelines first.

License

Chart.Annotation.js is available under the MIT license.

Comments
  • Annotation event not updating with Chart.js 2.7

    Annotation event not updating with Chart.js 2.7

    It is entirely possible this is a bug with my code and understanding rather than the tool itself as it is very new to me,

    I am using the following code to roughly test the tooltip hover mechanics for an annotation label:

    [{
    type: 'line',
    mode: 'vertical',
    // ..etc.
    onMousemove: function(e) {
        console.log('Annotation', e.type, this);
        console.log(this.options.label.enabled);
        this.options.label.enabled = true;
        console.log(this.options.label.enabled);
    },}]
    

    the console shows the label.enabled property changing from false to true, but the chart doesn't display a change. I have tried linking with this.chartInstance.update() but still doesn't work.

    The JS console error I receive is: Unable to preventDefault inside passive event listener invocation. dispatcher @ chartjs-plugin-annotation.js:261

    I'll attempt to provide demo unless you quickly spot a mistake I'm making.

    bug 
    opened by attack68 30
  • Add LABEL annotation and label node to BOX annotation

    Add LABEL annotation and label node to BOX annotation

    Fixes #26 Fixes #42

    Box annotation

    Creates new label element to enable the label in the box annotation.

    Label annotation

    Creates new LabelAnnotation element to enable to render a text on the chart at a coordinate, calculated by the chart data values.

    Line annotation

    Changes the line annotation in order to use the common methods for labelling and box drawing

    Ellipse annotation

    Removes the inheritance from BOX annotation to maintain the same model for all annotations.

    Others

    Moves common methods to helpers to reduce duplicated code:

    1. getRectCenterPoint, to calculated the center point of a rectangle
    2. getChartPoint, to get the coordinates of a point in the chartArea by xValue and yValue annotation options
    3. getChartRect, to get the rectangle from the chartArea by xMin, xMax, yMin and yMax annotation options

    TODO

    • [x] types definition
    • [X] documentation
    enhancement 
    opened by stockiNail 28
  • How can I show image as annotation label?

    How can I show image as annotation label?

    I'm working on one project and I need to show my flag image and I have checked this library and added annotation, but it does not show image. I have checked documentation, but there is Utils.getImage() function used to get image. I'm using plain html(cdns for both chartjs and this library) and Javascript.

    I get following result: image

    but I want to show flag image.

    My annotation object is like this:

    const annotation = {
                type: 'line',
                borderColor: 'red',
                borderWidth: 2,
                display: (ctx) => ctx.chart.isDatasetVisible(1),
                label: {
                    content: "/assets/flag.png",
                    display: true,
                    content: '',
                    position: 'start'
                },
                scaleID: 'x',
                value: 3.9
            };
    
    
    help wanted 
    opened by nijatmursali 22
  • fixed prevent default

    fixed prevent default

    Avoid 'Unable to preventDefault inside passive event listener invocation.' message. Support compatibility with old browsers

    Closes https://github.com/chartjs/chartjs-plugin-annotation/issues/159 https://github.com/chartjs/chartjs-plugin-annotation/pull/122

    bug chart.js version 2 
    opened by xr0master 18
  • Cannot set properties of undefined (setting 'display') at resolveLabelElementProperties

    Cannot set properties of undefined (setting 'display') at resolveLabelElementProperties

    We seem to be stuck with plugin-annotation v1.3.0 and chartjs v3.7.0 where following example for a line chart with multiple datasets works with multiple annotations.

    https://codepen.io/dbauszus-glx/pen/MWOjGzw

    Upgrading plugin-annotation to v2.0.0 causes following TypeError: Cannot set properties of undefined (setting 'display') at resolveLabelElementProperties.

    Upgrading chartjs to v3.9.1 causes a different TypeError: Cannot read properties of undefined (reading 'lastIndexOf')

    The same error persists with chartjs on v3.9.1 and plugin-aanotation on v2.0.0

    opened by dbauszus-glx 17
  • Enable line annotation using two scales

    Enable line annotation using two scales

    Changes:

    • position: 'start', 'end' or 'center'
    • alternative xScaleID, yScaleID, xMin, yMin, xMax, yMax options for line annotation
    • label hit testing by rotating the point (similar to datalabels plugin)
    • simpler label position adjustment by calculating the parameter t for pointInLine
    enhancement breaking change 
    opened by kurkle 17
  • Introduce ability to annotate a single bar

    Introduce ability to annotate a single bar

    This PR introduces the ability to annotate only a single bar (implementing #101): image

    It also supports horizontal bars: image

    The PR adds two new options to the line annotation:

    • onlyForDataIndex which specifies the data index which should be annotated
    • linePadding which adds a customisable padding to the start and end of the line
    • datasetIndex which specifies on which dataset the data should be annotated
    enhancement chart.js version 2 
    opened by lukasbischof 17
  • Annotation line not drawn

    Annotation line not drawn

    Hi guys,

    I'm completely new and honestly not a developer but I'm trying to integrate a line into our current chart.

    https://noahsbox.com/?fts=0&preview_theme_id=79991996475

    You can find a preview behind this link. I have replaced an image we had with the chart.js but having some difficulties getting the line drawn & a label displayed.

    Have tried it now for quite some time and maybe someone here has more luck. Any help would be much appreciated!

    <script>
      setTimeout(loadChart)
      function loadChart() {
    var ctx = document.getElementById("Price");
    var myChart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: [["Kitchen Box","Standard"]],
            datasets: [{
                label: 'Noahs Box',
                data: [149],
                backgroundColor: [
                    'rgba(30, 56, 79, 1)',
                    'rgba(30, 56, 79, 1)',
                ],
                borderColor: [
                    'rgba(30, 56, 79, 1)',
                    'rgba(30, 56, 79, 1)',
                ],
                borderWidth: 1
            },
         {
                label: 'Amazon',
                data: [198.30],
                backgroundColor: [
                    'rgba(255, 153, 0, 1)',
                    'rgba(255, 153, 0, 1)'
                ],
                borderColor: [
                    'rgba(255, 153, 0, 1)',
                    'rgba(255, 153, 0, 1)'
                ],
                borderWidth: 1
            },
                      {
                label: 'traditional Retailers',
                data: [250],
                backgroundColor: [
                    'rgba(0,91,71, 1)',
                    'rgba(0,91,71, 1)'
                ],
                borderColor: [
                    'rgba(0,91,71, 1)',
                    'rgba(0,91,71, 1)'
                ],
                borderWidth: 1
            }],
        },
        options: {
          responsive: true,
      	  maintainAspectRatio: false,
          legend: {
          	display: true
          },
          animation: {
           		duration: 15000,
            },
          title: {
    			display: false,
           		text: 'Save More When You Bundle',
            	fontColor: '#1E384F',
            	fontSize: 14
            },
          scales: {
            yAxes: [{
              ticks: {
                beginAtZero:true
              }
            }]
          },
        },
         plugins: [{
          deferred: {
            yOffset: '50%', // defer until 50% of the canvas height are inside the viewport
            delay: 1000      // delay of 500 ms after the canvas is considered inside the viewport
          },
           annotation: {
    			// Defines when the annotations are drawn.
    			// This allows positioning of the annotation relative to the other
    			// elements of the graph.
    			//
    			// Should be one of: afterDraw, afterDatasetsDraw, beforeDatasetsDraw
    			// See http://www.chartjs.org/docs/#advanced-usage-creating-plugins
    			drawTime: 'afterDatasetsDraw', // (default)
    
    			// Mouse events to enable on each annotation.
    			// Should be an array of one or more browser-supported mouse events
    			// See https://developer.mozilla.org/en-US/docs/Web/Events
    			events: ['click'],
    
    			// Double-click speed in ms used to distinguish single-clicks from
    			// double-clicks whenever you need to capture both. When listening for
    			// both click and dblclick, click events will be delayed by this
    			// amount.
    			dblClickSpeed: 350, // ms (default)
    
    			// Array of annotation configuration objects
    			// See below for detailed descriptions of the annotation options
    			annotations: [{
    	type: 'line',
    
    	// optional drawTime to control layering, overrides global drawTime setting
    	//drawTime: 'afterDatasetsDraw',
    
    	// optional annotation ID (must be unique)
    	id: 'a-line-1',
    
    	// set to 'vertical' to draw a vertical line
    	mode: 'horizontal',
    
    	// ID of the scale to bind onto
    	scaleID: 'y-axis-0',
    
    	// Data value to draw the line at
    	value: 149,
    
    	// Optional value at which the line draw should end
    	//endValue: 152,
    
    	// Line color
    	borderColor: 'red',
    
    	// Line width
    	borderWidth: 5,
    
    	// Line dash
    	// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
    	//borderDash: [2, 2],
    
    	// Line Dash Offset
    	// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
    	//borderDashOffset: 5,
    
    	label: {
    		// Background color of label, default below
    		backgroundColor: 'rgba(101, 33, 171, 0.5)',
    
    		// Font family of text, inherits from global
    		fontFamily: "sans-serif",
    
    		// Font size of text, inherits from global
    		fontSize: 12,
    
    		// Font style of text, default below
    		fontStyle: "bold",
    
    		// Font color of text, default below
    		fontColor: "#fff",
    
    		// Padding of label to add left/right, default below
    		//xPadding: 6,
    
    		// Padding of label to add top/bottom, default below
    		//yPadding: 6,
    
    		// Radius of label rectangle, default below
    		//cornerRadius: 6,
    
    		// Anchor position of label on line, can be one of: top, bottom, left, right, center. Default below.
    		//position: "center",
    
    		// Adjustment along x-axis (left-right) of label relative to above number (can be negative)
    		// For horizontal lines positioned left or right, negative values move
    		// the label toward the edge, and positive values toward the center.
    		//xAdjust: 0,
    
    		// Adjustment along y-axis (top-bottom) of label relative to above number (can be negative)
    		// For vertical lines positioned top or bottom, negative values move
    		// the label toward the edge, and positive values toward the center.
    		//yAdjust: 0,
    
    		// Whether the label is enabled and should be displayed
    		enabled: true,
    
    		// Text to display in label - default is null. Provide an array to display values on a new line
    		content: "Save 25-50%"
    	},
    
    	// Mouse event handlers - be sure to enable the corresponding events in the
    	// annotation events array or the event handler will not be called.
    	// See https://developer.mozilla.org/en-US/docs/Web/Events for a list of
    	// supported mouse events.
    	onMouseenter: function(e) {},
    	onMouseover: function(e) {},
    	onMouseleave: function(e) {},
    	onMouseout: function(e) {},
    	onMousemove: function(e) {},
    	onMousedown: function(e) {},
    	onMouseup: function(e) {},
    	onClick: function(e) {console.log("Annotation", e.type, this);},
    	onDblclick: function(e) {},
    	onContextmenu: function(e) {},
    	onWheel: function(e) {}
    }]
    		}
           
           
        }]
    }
    );
      } 
    </script>
    
    opened by Bra-Mo 16
  • Hide/Show annotations?

    Hide/Show annotations?

    Hi, is there any way to hide & show the individual annotations with a property? (Rather than removing the object from the annotations array?)

    For example, Chart.JS allows you to define a display: true/false/callback on things like the legend

    Thanks!

    enhancement 
    opened by Techn1x 16
  • Add hoverColor option

    Add hoverColor option

    Discussed here: https://github.com/chartjs/chartjs-plugin-annotation/issues/95

    display is set to true by default. Setting to false will hide either all annotations, or the individual annotation. Hiding the annotation essentially just makes it invisible, so that events will still trigger (useful for hover events, for example)

    enhancement chart.js version 2 
    opened by Techn1x 15
  • Add `beforeDraw` and `afterDraw` hooks to the annotations

    Add `beforeDraw` and `afterDraw` hooks to the annotations

    This PR is adding before/after draw hooks in order to allow the user to apply whatever needed customization on out-of the-box annotations.

    plugins: {
      annotation: {
        annotations: {
          line: {
            type: 'line',
            ....
            beforeDraw(context) {
              console.log('beforeDraw');
              return true;
            },
            afterDraw(context) {
              console.log('afterDraw');
            },
          },
        }
      }
    }
    

    | Hook | Arguments | Return type | Default | Description | :-- | :-- | :-- | :-- | :-- | beforeDraw | context | boolean | annotation.beforeDraw | invoked before the element drawing. If returns false, the element is not drawn. | afterDraw | context | void | annotation.afterDraw | invoked after the element drawing

    Common hooks for all annotations can be set in the annotation plugin options:

    plugins: {
      annotation: {
        beforeDraw(context) {
          console.log('Common beforeDraw');
          return true;
        },
        afterDraw(context) {
          console.log('Common afterDraw');
        },
        annotations: {
          line: {
            type: 'line',
            ....
          },
        }
      }
    }
    

    TODO

    • [x] test cases
    • [x] types
    • [x] documentation
    • [x] samples
    enhancement 
    opened by stockiNail 13
  • Enable centered label drawing for doughnut controllers

    Enable centered label drawing for doughnut controllers

    A prototype. This PR is enabling the possibility to add an inner label in the middle of a doughnut controller. This is leveraging on the already label calculation and drawing used for label annotation. To work properly, it needs also the multi fonts and colors, PR #801 (implemented the code but just for testing if works correctly).

    | image | text |:-|:- |inner2 | inner1

    SAMPLE chart configuration:

    {
      type: 'doughnut',
      data: {
        labels: ['Data1', 'Data2', 'Data3', 'Data4'],
        datasets: [ {
          data: [102, 200, 80, 55],
        }],
      },
      options: {
        aspectRatio: 2,
        plugins: {
          annotation: {
            annotations: {
              innerlabel: {
                type: 'doughnutLabel',
                display: true,
                drawTime: 'afterDraw',
                font: [{size: 24},{size: 16, weight: 'bold'}],
                click(context) {
                  console.log("click", context);
                },
                color: ['blue', 'red'],
                content: ({chart}) => ['Utilization', chart.data.datasets[0].data.length + '%'],
              }
            }
          }
        }
      }
    }
    
    opened by stockiNail 1
  • Maximum Call Stack Size Error on Nuxt with CDN Load.

    Maximum Call Stack Size Error on Nuxt with CDN Load.

    I am in a situation where I can't integrate using npm and only cdn script hosted on private host. I get this error with just adding cdn script in Nuxt.

    Maximum call stack size exceeded
    

    nuxt.config.js

    export default {
      head: {
        script: [
          {
            src: 'https://cdn.jsdelivr.net/npm/chart.js',
          },
          {
            src: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/chartjs-plugin-annotation.js',
          },
        ]
      },
    

    Here is the replicated example for the issue: https://stackblitz.com/edit/pia-scurve-test?file=components/SCurve.vue

    help wanted 
    opened by ariomoklo 3
  • Docs link issue

    Docs link issue

    Hey, I noticed that links in documentation are broken.

    For example:

    in https://www.chartjs.org/chartjs-plugin-annotation/latest/guide/types/box.html#label

    when I click on "Padding":

    image

    I get url hash lost in redirection.

    So instead of https://www.chartjs.org/chartjs-plugin-annotation/latest/guide/options.html#padding (expected)

    I get https://www.chartjs.org/chartjs-plugin-annotation/latest/guide/options.html (actual) - note there is no #padding in the end.

    documentation 
    opened by kranux 1
  • Server Error when using annotation plugin with Chart.js 4.0.1 in NextJS app

    Server Error when using annotation plugin with Chart.js 4.0.1 in NextJS app

    Hey guys,

    First of all, thanks for making this super helpful library!

    I am currently working on a NextJS and have implemented ChartJS v4.0.1. All works well, but when I want to install the annotation plugin and follow the steps of https://www.chartjs.org/chartjs-plugin-annotation/latest/guide/integration.html I get the following error: Schermafbeelding 2022-12-01 om 11 25 58

    My React component is: (only relevant is shown)

    import {useEffect, useState} from "react";
    import {BarElement, CategoryScale, Chart as ChartJS, Legend, LinearScale, Title, Tooltip} from 'chart.js';
    import Annotation from 'chartjs-plugin-annotation';
    import {Bar} from 'react-chartjs-2';
    
    ChartJS.register(
        CategoryScale,
        LinearScale,
        BarElement,
        Title,
        Tooltip,
        Legend,
        Annotation,
    );
    
    .........
    

    Do you guys have any idea how to solve this? Is it an issue because of ChartJS v4?

    Thanks a lot!

    Cheers, Ferre

    bug 
    opened by ferremekelenkamp 12
  • Usage as CDN

    Usage as CDN

    We are trying to use this plugin and ChartJS from a CDN, but we are not able to draw the box, and no errors are reported. My code looks correct, since it works on the demo enviroment, but I paste anyway. Thanks in advance

    HTML Code:

    <html>
      <body>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-annotation/2.0.1/chartjs-plugin-annotation.min.js">
        </script>
        <script src="app.js"></script>
     </body>
    </html>
    

    Config

    plugins: {
            autocolors: false,
            annotation: {
              annotations: {
                box1: {
                  type: 'box',
                  xMin: 1,
                  xMax: 9,
                  yMin: 1,
                  yMax: 4,
                  backgroundColor: 'transparent'
                },
                label1: {
                  type: 'label',
                  xValue: 2,
                  yValue: 4.5,
                  backgroundColor: 'transparent',
                  content: ['Fase latente'],
                  font: {
                    size: 18
                  }
                }
              }
            }
          },
    
    status: needs test case 
    opened by YorozuyaDev 1
Releases(v2.1.1)
  • v2.1.1(Dec 30, 2022)

    Essential Links

    Documentation

    • #823 Fix build status badge in README
    • #821 Remove autocolors plugin from doc going to Chart.js color plugin

    Development

    • #822 Bump to version 2.1.1
    • #824 Remove destroy plugin hook and replaced with afterDestroy
    • #817 Bump decode-uri-component from 0.2.0 to 0.2.2
    • #816 Update GHA versions
    • #812 Bump engine.io and socket.io

    Thanks to @dependabot, @dependabot[bot] and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Nov 17, 2022)

    Essential Links

    Enhancements

    • #749 Enable label on ellipse annotation
    • #740 Enable callout in the label of line annotation

    Bugs Fixed

    • #808 Change CHART.JS dependency to version 4

    Documentation

    • #802 Fix the scales configuration of the basic label sample
    • #799 Add new position option behavior for line label to migration guide 2
    • #793 Add id option documentation to all annotations

    Development

    • #810 Bump minimatch from 3.0.4 to 3.1.2
    • #809 Bump ansi-regex from 4.1.0 to 5.0.1
    • #806 Bump socket.io-parser from 4.0.4 to 4.0.5

    Thanks to @dependabot, @dependabot[bot] and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Aug 19, 2022)

  • v2.0.0(Jul 26, 2022)

    Essential Links

    Breaking Changes

    • #764 Remove label clipping to box annotation size
    • #759 Change and reorder the types definitions
    • #727 Enable line annotation label as label sub-element
    • #630 Move element fallback to plugins.annotation.common
    • #725 Enable box annotation label as label sub-element
    • #723 Require at least chartjs v3.7
    • #720 Reduce visibility of some line annotation element methods
    • #716 Remove dblclick hook to prepare chart redrawing from an event hook
    • #706 Normalize annotations elements to be based on common box model
    • #703 Change enabled to display option in all nodes of annotations
    • #702 Remove x/yPadding options from the label of line annotation
    • #701 Remove cornerRadius option from box and line annotations
    • #659 Enable interaction mode support for events
    • #655 Enable stacked scales and with reverse option support
    • #678 Use scale defined in the chart when x/y ScaleID options are not set

    Enhancements

    • #738 Add z option to all annotations
    • #731 Callout position calculated when label is drawn
    • #725 Enable box annotation label as label sub-element
    • #717 Enable event handlers to indicate chart should be re-drawn
    • #659 Enable interaction mode support for events
    • #655 Enable stacked scales and with reverse option support
    • #678 Use scale defined in the chart when x/y ScaleID options are not set

    Bugs Fixed

    • #742 Use margin option in the callout check for being shown
    • #630 Move element fallback to plugins.annotation.common

    Types

    • #759 Change and reorder the types definitions
    • #737 Add point option to polygon annotation options type
    • #733 Add documentation and type for 'common' plugin option

    Documentation

    • #771 Add API docs
    • #758 Remove animation properties from documentation, not used anymore
    • #760 Add element diagrams to the annotation types guide
    • #752 Update line annotation diagram to describe new element structure
    • #751 Add sample how to select annotations
    • #747 Adds common annotation options section in the documentation
    • #733 Add documentation and type for 'common' plugin option
    • #722 Add JSDoc to exported functions
    • #724 Update min version req in readme
    • #721 Add sample about interaction options
    • #719 Change default interaction options in chart defaults for the samples
    • #715 Move v3-migration.md file in the documentation
    • #709 Add migration guide v2 section to getting started page

    Development

    • #777 Bump to version 2.0.0
    • #756 Bump eventsource from 1.1.0 to 1.1.1
    • #743 Reduce complexity for resolving the label callout position
    • #736 Move interaction object at top level of plugin options
    • #735 Improve usage of rotation option in callout management
    • #734 Change tests configuration using new 'common' plugin option
    • #729 Bump async from 2.6.3 to 2.6.4
    • #723 Require at least chartjs v3.7
    • #712 Bump minimist from 1.2.5 to 1.2.6
    • #711 Replace deprecated String.prototype.substr()

    Thanks to @CommanderRoot, @LeeLenaleee, @dependabot, @dependabot[bot], @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.4.0(Mar 7, 2022)

    Essential Links

    Enhancements

    • #690 Enable rotation support to label of box annotation
    • #679 Add stroke width and color options to label text
    • #672 Enable rotation support to label annotation
    • #668 Enable rotation support to box annotation

    Bugs Fixed

    • #688 Fix the usage where jsDOM is not present
    • #682 Fix callout drawing that happens even if disabled

    Documentation

    • #704 Fix point sample on combined annotations
    • #696 Add inner chart sample
    • #691 Fix wrong sentence in the line annotation documentation
    • #684 Add samples of image and canvas as label content

    Development

    • #708 Bump 1.4.0, update deps, fix some fixtures
    • #705 Remove the assignment used only once
    • #707 Bump karma from 6.3.14 to 6.3.16
    • #700 Bump url-parse from 1.5.7 to 1.5.10
    • #699 Bump prismjs from 1.26.0 to 1.27.0
    • #694 Add dependencies label of PR to development section in release note
    • #693 Bump url-parse from 1.5.4 to 1.5.7
    • #689 Bump follow-redirects from 1.14.7 to 1.14.8
    • #683 Bump karma from 6.3.12 to 6.3.14
    • #667 Move elements management functions to a dedicated file

    Thanks to @dependabot, @dependabot[bot], @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Feb 7, 2022)

    Essential Links

    Bugs Fixed

    • #671 Fix the usage of the backgroundColor callback for applying a gradient on label annotation
    • #670 Fix the usage of the original coordinates for applying a gradient on ellipse
    • #664 Update the warning logic for missing scale

    Documentation

    • #663 Documentation updates

    Development

    • #673 Bump version to 1.3.1

    Thanks to @joshkel and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jan 27, 2022)

    Essential Links

    Enhancements

    • #555 Enable sub elements
    • #608 Add arrows decoration to line annotation
    • #619 Properly consider the border thickness on the annotations' events
    • #600 Enable shadowing on the annotations

    Bugs Fixed

    • #653 Directly assign new element resolved properties
    • #635 Fix auto callout position calculation in label annotation
    • #627 Fix the scale limit update when annotation value is 0
    • #603 Fixes events triggering on the label of a line annotation

    Documentation

    • #654 Fix wrong dataset index in sample
    • #628 Fix the default options values in the documentation
    • #623 Normalize table headers and samples blocks sequence in the documentation
    • #613 Enable the link to label configuration from the guide navigation menu
    • #609 Update labelVisibility sample to demonstrate different approaches
    • #607 Remove `point` node from label annotation sample
    • #606 Sort alphabetically the options definitions in the documentation

    Development

    • #661 Bump version to 1.3.0, update deps
    • #657 Line: change event tests to inRange tests
    • #650 Move events test cases to events.spec
    • #651 Polygon: change event tests to inRange tests
    • #649 Point: change event tests to inRange tests
    • #647 Label fixtures: merge canvas test cases and remove useless point test
    • #648 Label: change event tests to inRange tests
    • #646 Label fixtures: merge similar callout test cases
    • #645 Label fixtures: merge missing scales test cases
    • #644 Add tests for missing and empty label content
    • #643 Label fixtures: merge position tests in vertical and horizontal ones
    • #641 Label fixtures: combine border tests to one file
    • #640 Label fixtures: remove point tests, update padding
    • #639 Remove old test cases
    • #637 Tests: use helper function to fetch elements
    • #638 Chart.js < v3.7 warning instead of exception
    • #634 Box: test borderWidths. Ellipse: change events tests to inRange tests
    • #632 Box: change event tests to inRange tests
    • #633 Remove not used default route for backgroundColor option in label annotation
    • #631 Remove (some) reduntant properties from fixtures
    • #614 Improve event handling adding test cases
    • #617 Remove `readValueToProps` function of options helpers
    • #616 Add specific test cases for ellipse annotation event handling
    • #622 Add test cases to test one or both missing scales
    • #612 Sort shadow color default options alphabetically
    • #605 Remove renaming the imports from chartjs.helpers of callback function
    • #604 Add JSDoc to `labelIsVisible` method of line annotation
    • #599 Use PI constant of Chartjs helpers instead of Math.PI
    • #598 Normalize border style setting

    Thanks to @joshkel, @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Dec 29, 2021)

    Essential Links

    Bugs Fixed

    • #595 Fix dynamically showing/hiding line label
    • #591 Properly consider the line thickness in the intersect calculation
    • #583 Fix events catching on rotated ellipse annotations
    • #582 Remove undefined event listeners from state if disabled at runtime

    Types

    • #586 new annotation types added to ElementOptionsByType

    Documentation

    • #587 Add borderJoinStyle round to the road signals sample
    • #584 Change `var` to `const` in the samples

    Development

    • #592 Bump version to 1.2.2, update deps
    • #578 Fix complexity and duplicated code on scale management
    • #571 Store drawable elements to the state
    • #570 Sort default options alphabetically
    • #574 Move scale management functions to a dedicated file

    Thanks to @elitastic, @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Dec 17, 2021)

    Essential Links

    Bugs Fixed

    • #575 Workaround for array syntax bug with Chart.js<v3.7
    • #569 Fix Typescript < v4.1 compile error

    Development

    • #576 Bump version to 1.2.1
    • #564 Chore/remove old samples

    Thanks to @LeeLenaleee, @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Dec 14, 2021)

    Essential Links

    • #558 Remove `point` node from label annotation
    • #521 Add pointStyle and rotation to point options (label and point annotations)
    • #525 Updates README with new features
    • #507 Add callout and point nodes to the label annotation
    • #501 Add borderCapStyle and borderJoinStyle options to BoxAnnotation

    Enhancements

    • #554 Enable label `position` as percentage of the size
    • #551 Add `xAdjust` and `yAdjust` options to point and polygon annotations
    • #534 Enable HTMLCanvasElement as label content
    • #527 Add point positioning by box options for point, polygon and label annotations
    • #528 Use the context of element for events dispatching
    • #523 Add clip option
    • #503 Add POLYGON annotation
    • #506 Enable label padding as object
    • #502 Add LABEL annotation and label node to BOX annotation

    Bugs Fixed

    • #560 Fix `animations` option type and add missing documentation
    • #547 Make a consistent implementations of `inRange` in all annotations
    • #550 Fix `isBoundToPoint` function implementation
    • #541 Enable label annotation animations
    • #530 Log warning when unknown annotation type is used
    • #526 Log a warning instead of throwing when non-existing scale id is used
    • #518 Throw error when non-existing scale id is used

    Types

    • #560 Fix `animations` option type and add missing documentation
    • #517 Add missing options to types definition

    Documentation

    • #560 Fix `animations` option type and add missing documentation
    • #548 Disclosure box sample is made responsive
    • #538 Add samples to the documentation
    • #536 Add note about clip option usage and events catching
    • #518 Throw error when non-existing scale id is used
    • #505 Fix line annotation documentation
    • #499 Fix broken 'View this example' link
    • #500 Add border* options documentation and types for the label in the line annotation

    Development

    • #561 Bump version to 1.2.0, update dependencies
    • #544 Resolve circulare dependencies
    • #519 Move annotation types handling to types/index.js

    Thanks to @Marcel0024, @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Nov 16, 2021)

    Essential Links

    Enhancements

    • #456 Add rotation support for ellipse annotations
    • #457 Per corner cornerRadius for box and line label
    • #459 Add border support for line label
    • #451 Pass event instance to listeners

    Bugs Fixed

    • #485 Fix type for CoreAnnotationOptions.borderDash
    • #475 Use font.lineHeight instead of font.size for labelling in line annotation
    • #458 Hide line-annotations completely outside chartArea

    Types

    • #485 Fix type for CoreAnnotationOptions.borderDash
    • #471 Typings for default settings on element
    • #453 LabelOptions.width and .height are optional
    • #448 Add missing animations prop to options interface.

    Documentation

    • #476 Fix the point annotation documentation guide
    • #460 docs: typo YMax -> yMax
    • #455 Prevent error when removing data in point sample
    • #447 Change important note part to title of the block
    • #440 Update types of config
    • #436 Move readme example from codepen to docs

    Development

    • #486 Bump version to 1.1.0, update deps
    • #454 Prevent infinity in line example, unused utils

    Thanks to @LeeLenaleee, @elitastic, @kurkle, @multipolygon, @philfontaine and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Jun 1, 2021)

    Essential Links

    Bugs Fixed

    • #428 Fixes for line mouse events
    • #424 Add missing `adjustScaleRange` to AnnotationOptions

    Types

    • #424 Add missing `adjustScaleRange` to AnnotationOptions

    Development

    • #429 Bump to 1.0.2, update deps, remove next tag

    Thanks to @jbelien, @joshkel and @kurkle

    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Apr 25, 2021)

    Essential Links

    • #419 Add adjustScaleRange options

    Bugs Fixed

    • #414 Fix drawing of lines with points out of chartArea
    • #403 Restrict mouse events to where the line actually is

    Types

    • #404 Update LabelPosition type to match v1.0.0

    Documentation

    • #415 Add warning about registration to Getting Started
    • #406 Update installation instructions

    Development

    • #420 Bump version to 1.0.1

    Thanks to @joshkel, @kurkle and @tlserver

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Apr 14, 2021)

    Essential Links

    Enhancements

    • #386 Enables textAlign option to line label

    Bugs Fixed

    • #393 Update option typings, fix `type`
    • #385 Depend on chart.js v3.0.1
    • #378 Skip annotations outside chartArea

    Types

    • #393 Update option typings, fix `type`
    • #376 Type fixes

    Documentation

    • #390 Add sample on bar chart
    • #382 Add ellipse sample
    • #380 Update vuepress-theme-chartjs
    • #377 Add note about registering
    • #376 Type fixes

    Development

    • #394 Bump version to 1.0.0
    • #384 Depend on chart.js v3.0.0
    • #383 Add point example
    • #381 Add version information to charts in documentation
    • #379 Update dependencies

    Thanks to @joshkel, @kurkle and @stockiNail

    Included changes from pre-releases

    • https://github.com/chartjs/chartjs-plugin-annotation/releases/tag/v1.0.0-rc
    • https://github.com/chartjs/chartjs-plugin-annotation/releases/tag/v1.0.0-beta.4
    • https://github.com/chartjs/chartjs-plugin-annotation/releases/tag/v1.0.0-beta.3
    • https://github.com/chartjs/chartjs-plugin-annotation/releases/tag/v1.0.0-beta.2
    • https://github.com/chartjs/chartjs-plugin-annotation/releases/tag/v1.0.0-beta
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-rc(Mar 25, 2021)

    Essential Links

    Breaking Changes

    • #366 Add custom scriptable context

    Enhancements

    • #367 Update for Chart.js v3.0.0-rc.3
    • #366 Add custom scriptable context
    • #349 Add scriptable test cases for annotation elements

    Bugs Fixed

    • #370 Resolve element options to concrete values
    • #354 Use the new isolated key for animations
    • #342 Do not draw box border when width is 0
    • #345 Fallback label.drawTime to element.drawTime

    Documentation

    • #371 Migrate to vuepress-theme-chartjs
    • #369 Fix banner on docs
    • #363 Docs using VuePress
    • #362 Link to samples from sub pages
    • #356 Interactive online samples using VuePress
    • #355 Update url text
    • #353 Add badges to readme
    • #352 Deploy as chartjs-ci user
    • #351 Need to run from docs folder
    • #350 Fix documentation GitHub actions
    • #347 Documentation Website

    Development

    • #372 Bump version to 1.0.0-rc
    • #341 Update badges

    Thanks to @LeeLenaleee, @etimberg, @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta.4(Mar 7, 2021)

    Essential Links

    Enhancements

    • #331 Chart.js beta.13 compatibility

    Bugs Fixed

    • #335 Use annotation defaults when resolving options

    Development

    • #340 Bump version to 1.0.0-beta.4

    Thanks to @kurkle and @santam85

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta.3(Feb 5, 2021)

    Essential Links

    Breaking Changes

    • #317 Moves color option out of font namespace
    • #311 Auto register/unregister annotation types
    • #305 Enable line annotation using two scales

    Enhancements

    • #330 Enables the label content to be an Image.
    • #329 Enables borderDash and borderDashOffset options to all annotations
    • #327 Internal options merged, resolved and stored into the state
    • #325 Applies element defaults before resolving element properties
    • #311 Auto register/unregister annotation types
    • #305 Enable line annotation using two scales
    • #303 beforeDraw hook added

    Bugs Fixed

    • #323 Adjust scale range method using options instead of elements
    • #322 Ignores no-display elements during events management
    • #307 Only parse string values for scale
    • #300 Initialize always all elements even if do not show

    Types

    • #328 Chart.js beta.10 update
    • #308 types modified to support beforeDraw hook
    • #301 Consistently export all types
    • #299 Fix PointAnnotationOptions
    • #297 TypeScript type fixes

    Development

    • #310 Update deps, bump version

    Thanks to @elitastic, @joshkel, @kurkle and @stockiNail

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta.2(Jan 5, 2021)

  • v1.0.0-beta(Jan 4, 2021)

    Essential Links

    Breaking Changes

    • #256 Add context to display callback (#255)
    • #248 Remove annotations array, using an object instead and min/max on value and endValue options
    • #239 Align event hooks with to datalabels plugin

    Enhancements

    • #282 Maintain the label always inside the chartArea, whatever rotation has been set
    • #275 Implement a separate labelDrawTime option
    • #267 Adds cornerRadius options to box annotation
    • #277 Update for Chart.js 3.0.0-beta.7
    • #263 Adds ellipse, triangle and point annotations
    • #256 Add context to display callback (#255)
    • #254 Enable Auto rotation of labels (#250)
    • #248 Remove annotations array, using an object instead and min/max on value and endValue options
    • #246 `display` setting for annotation
    • #239 Align event hooks with to datalabels plugin
    • #229 Chart.js v3 compatibility
    • #178 Add rotation option for line labels
    • #129 allow multiple lines of text in the line label
    • #116 move configure step to draw time, to support render call
    • #107 eslint fixes

    Bugs Fixed

    • #290 Enables display options (#289)
    • #281 Add returns elements in `resyncElements`
    • #270 Line labels position options (not center) don't work
    • #266 Fixes events catching on rotated line labels
    • #274 Various fixes
    • #248 Remove annotations array, using an object instead and min/max on value and endValue options
    • #241 Fix destroying annotations and beforeDatasetsDraw
    • #237 Fix some issues detected by inspecting samples
    • #173 Added PLUGIN ID because missing
    • #152 Fix getting chart borders for box size setting
    • #109 Pass the index of value datapoint to getPixelValue
    • #130 Read plugin options from plugins.annotation

    Types

    • #261 Add initial types

    Documentation

    • #224 `enabled: true` in the README.md
    • #197 update vulnerability package reference in sample.

    Development

    • #279 calculateLabelPosition cleanup
    • #253 Chart.js v3.0.0-beta.5 compatibility

    Thanks to @ShineSmile, @Svetomechc, @aoifef, @benmccann, @extend1994, @holmari, @joshkel, @kurkle, @mafatekhov, @philippemilink, @stockiNail, @strixy and @veggiesaurus

    Source code(tar.gz)
    Source code(zip)
  • v0.5.7(Oct 19, 2017)

  • v0.5.6(Oct 18, 2017)

    New Features

    • Added Codepen screenshot (#6)
    • Added Bower support, H/T @oscarotero

    Issues Fixed

    • Fixed a strict Javascript error (#76), H/T @jonathanlurie
    • Fixed a README.md error, H/T @dscush
    Source code(tar.gz)
    Source code(zip)
  • v0.5.5(May 20, 2017)

  • v0.5.4(May 20, 2017)

    Issues Fixed

    • Fixed hidden label when using position: "top" on vertical line label (#55) - thanks @buejoh
    • Fixed support for category, logarithmic, time, and linear scales with non-numeric values (#3, #35, #47, #68) - thanks @yusufozturk
    • Fixed a Javascript error when the plugin is included on a page with a non-supported pie, radar, or polar area chart (#49, #63, #66) - thanks @yusufozturk
    • Fixed a Javascript error in environments that send events as null (#53) - thanks @yusufozturk

    Breaking Changes

    • Default annotation.drawTime option changed from afterDraw to afterDatasetsDraw (#51)
    Source code(tar.gz)
    Source code(zip)
  • v0.5.3(May 20, 2017)

  • v0.5.2(Dec 3, 2016)

    New Features

    • Added support for mouse hover events (mouseover, mouseenter, mouseleave, mouseout) (#44)
    • Numerous internal API improvements (#45)
    • Added a dblClickSpeed option
    • Annotations may have user-specified id

    Issues Fixed

    • Fixed a canvas corruption bug when line labels are toggled (#45, 4bb9f921ddde3393f09730ca898592e7c4b55ee9)
    • Fixed a Webpack complaint when bundling this package

    Dependencies

    • Requires Chart.js >= 2.4.0
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Dec 3, 2016)

    New Features

    • Ability to capture mouse click events on annotations (supports mousemove, mousedown, mouseup, click, dblclick, contextmenu, and wheel events)
    Source code(tar.gz)
    Source code(zip)
  • v0.4.3(Nov 29, 2016)

  • v0.4.2(Nov 28, 2016)

    Issues Fixed

    • Annotations spill out of chart area (#38, resolves #23)
    • Annotation scales do not adjust to include annotation values (#39, resolves #23)
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Nov 21, 2016)

    Breaking Changes

    • chartInstance._annotationObjects was renamed to chartInstance.annotations

    This release includes a significant amount of internal refactoring. Any other plugins or code that relied on accessing internal properties may have to be updated to work correctly with this release.

    Issues Fixed

    • Annotations should refresh on config change (#37, resolves #36)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Nov 15, 2016)

Owner
Chart.js
Simple, clean and engaging charts for designers and developers
Chart.js
Chart.js plugin to defer initial chart updates

Chart.js plugin to defer initial chart updates until the user scrolls and the canvas appears inside the viewport, and thus trigger the initial chart a

Chart.js 97 Nov 9, 2022
A Simple Dashboard Chart in Laravel Nova using Chart JS

A Simple Dashboard Chart in Laravel Nova using Chart JS. Starting create your own dashboard with Chart JS Integration can save your time and help you maintain consistency across standard elements such as Bar, Stacked, Line, Area, Doughnut and Pie Chart.

Kuncoro Wicaksono 177 Jan 4, 2023
Bar Funnel Chart extension for Chart.js

Chart.BarFunnel.js Provides a Bar Funnel Chart for use with Chart.js Documentation To create a Bar Funnel Chart, include Chart.BarFunnel.js after Char

Chart.js 58 Nov 24, 2022
TradeX-chart is a trade chart written in plain (vanilla) JavaScript with minimal dependencies

TradeX-chart is a trade chart written in plain (vanilla) JavaScript with minimal dependencies; use it with any framework or backend.

null 24 Dec 12, 2022
Zoom and pan plugin for Chart.js

chartjs-plugin-zoom A zoom and pan plugin for Chart.js >= 3.0.0 For Chart.js 2.6.0 to 2.9.x support, use version 0.7.7 of this plugin. Panning can be

Chart.js 510 Jan 2, 2023
Chart.js plugin for more styling options

chartjs-plugin-style Chart.js plugin for more styling options This plugin requires Chart.js 2.6.0 or later. Installation You can download the latest v

Akihiko Kusanagi 57 Oct 27, 2022
Chart.js plugin for live streaming data

chartjs-plugin-streaming Chart.js plugin for live streaming data chartjs-plugin-streaming 2.x requires Chart.js 3.0.0 or later. If you need Chart.js 2

Akihiko Kusanagi 401 Dec 27, 2022
Chart.js plugin to create charts with a hand-drawn, sketchy, appearance

chartjs-plugin-rough Chart.js plugin to create charts with a hand-drawn, sketchy, appearance Version 0.2 requires Chart.js 2.7.0 or later, and Rough.j

Akihiko Kusanagi 73 Dec 1, 2022
Chart.js plugin to calculate and draw statistical linear, exponential, power, logarithmic, and polynomial regressions.

chartjs-plugin-regression Chart.js plugin to calculate and draw statistical linear, exponential, power, logarithmic, and polynomial regressions using

Wilfredo Pomier 14 Dec 18, 2022
Draggable data points plugin for Chart.js

chartjs-plugin-dragdata.js Now compatible with Chart.js v3 ?? Looking for a version compatible to Chart.js < 2.9.x? Then visit the v2 branch! A plugin

Christoph Pahmeyer 196 Dec 18, 2022
Chart.js plugin for Prometheus data loading

Welcome to chartjs-plugin-datasource-prometheus ?? A Prometheus datasource for ChartJS. Dependencies: requires chart.js 2.7 or later. requires moment.

Samuel Berthe 77 Dec 6, 2022
Chart.js plugin to display labels on data elements

Overview Highly customizable Chart.js plugin that displays labels on data for any type of charts. Requires Chart.js 3.x. Documentation Introduction Ge

Chart.js 753 Dec 24, 2022
Redefined chart library built with React and D3

Recharts Introduction Recharts is a Redefined chart library built with React and D3. The main purpose of this library is to help you to write charts i

recharts 19.4k Jan 2, 2023
:bar_chart: A D3-based reusable chart library

c3 c3 is a D3-based reusable chart library that enables deeper integration of charts into web applications. Follow the link for more information: http

C3.js 9.2k Jan 2, 2023
GPL version of Javascript Gantt Chart

dhtmlxGantt Getting started | Features | Follow us | License | Useful links dhtmlxGantt is an open source JavaScript Gantt chart that helps you illust

null 952 Dec 29, 2022
🍞📊 Beautiful chart for data visualization.

?? ?? Spread your data on TOAST UI Chart. TOAST UI Chart is Beautiful Statistical Data Visualization library. ?? Packages The functionality of TOAST U

NHN 5.2k Jan 2, 2023
:bar_chart: Re-usable, easy interface JavaScript chart library based on D3.js

billboard.js is a re-usable, easy interface JavaScript chart library, based on D3 v4+. The name "billboard" comes from the famous billboard chart whic

NAVER 5.4k Jan 1, 2023
:bar_chart: A library of modular chart components built on D3

Plottable Plottable is a library of chart components for creating flexible, custom charts for websites. It is built on top of D3.js and provides highe

Palantir Technologies 2.9k Dec 31, 2022
Chart image and QR code web API

QuickChart QuickChart is a service that generates images of charts from a URL. Because these charts are simple images, they are very easy to embed in

Ian Webster 1.3k Dec 25, 2022