Contributing

    • Before opening a PR for major additions or changes, please discuss the expected API and/or implementation by filing an issue (opens new window) or asking about it in the #dev channel. This will save you development time by getting feedback upfront and make review faster by giving the maintainers more context and details.
    • Check that your code will pass tests and code standards. npm test will run both the linter and tests for you.
    • Add unit tests and document new functionality (in the test/ and docs/ directories respectively).
    • Avoid breaking changes unless there is an upcoming major release, which is infrequent. We encourage people to write plugins for most new advanced features, and care a lot about backwards compatibility.
    • We strongly prefer new methods to be added as private whenever possible. A method can be made private either by making a top-level function outside of a class or by prefixing it with _ and adding @private JSDoc if inside a class. Public APIs take considerable time to review and become locked once implemented as we have limited ability to change them without breaking backwards compatibility. Private APIs allow the flexibility to address unforeseen cases.

    Active committers and contributors are invited to introduce yourself and request commit access to this project. We have a very active Slack community that you can join here (opens new window). If you think you can help, we’d love to have you!

    Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:

    This will install the local development dependencies for Chart.js.

    The following commands are now available from the repository root:

    We use to manage the docs which are contained as Markdown files in the docs directory. You can run the doc server locally using these commands:

    Image-Based Tests

    Some display-related functionality is difficult to test via typical Jasmine units. For this reason, we introduced image-based tests ( and #5777Contributing - 图6 (opens new window)) to assert that a chart is drawn pixel-for-pixel matching an expected image.

    Generated charts in image-based tests should be as minimal as possible and focus only on the tested feature to prevent failure if another feature breaks (e.g. disable the title and legend when testing scales).

    You can create a new image-based test by following the steps below:

    • Create a JS file () or JSON file (exampleContributing - 图8 (opens new window)) that defines chart config and generation options.
    • Add this file in test/fixtures/{spec.name}/{feature-name}.json.
    • Run npm run dev.
    • Click the “Debug” button (top/right): a test should fail with the associated canvas visible.
    • Right click on the chart and “Save image as…” making sure not to activate the tooltip or any hover functionality
    • Refresh the browser page (CTRL+R): test should now pass
    • Verify test relevancy by changing the feature values slightly in the JSON file.

    When a test fails, the expected and actual images are shown. If you’d like to see the images even when the tests pass, set "debug": true in the JSON file.

    Please report these on the GitHub page - at . Please do not use issues for support requests. For help using Chart.js, please take a look at the chartjs (opens new window) tag on Stack Overflow.

    Well structured, detailed bug reports are hugely valuable for the project.

    Guidelines for reporting bugs:

    • Check the issue search to see if it has already been reported
    • Please include a demonstration of the bug on a website such as , JS Fiddle (opens new window), or . (Template (opens new window)). If filing a bug against master, you may reference the latest code via (changing the filename to point at the file you need as appropriate). Do not rely on these files for production purposes as they may be removed at any time.