View on GitHub

reading-notes

Assorted topics

Chart.js API

// For example:  
   var myLineChart = new Chart(ctx, config);
// Destroys a specific chart instance   myLineChart.destroy();

myLineChart.data.datasets[0].data[2] = 50;
// Would update the first dataset’s value of ‘March’ to be 50 myLineChart.update();
// Calling update now animates the position of March from 90 to 50.

A mode string can be provided to indicate transition configuration should be used. Core calls this method using any of ‘active’, ‘hide’, ‘reset’, ‘resize’, ‘show’ or undefined. ‘none’ is also a supported mode for skipping animations for single update. Please see animations docs for more details.

Example:

 myChart.update('active');
myLineChart.reset();
const chart = Chart.getChart("canvas-id");

img

Chart.js

  1. creat chart

img

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

For support using Chart.js, please post questions with the chartjs tag on Stack Overflow .

#License Chart.js is available under the MIT license .

Documentation is copyright © 2014-2021 Chart.js contributors.

The source

Canvas API

The Canvas API provides a means for drawing graphics via JavaScript and the HTML element. Among other things, it can be used for animation, game graphics, data visualization, photo manipulation, and real-time video processing.

The Canvas API largely focuses on 2D graphics. The WebGL API, which also uses the element, draws hardware-accelerated 2D and 3D graphics.

Basic example This simple example draws a green rectangle onto a canvas.

  1. HTML
    <canvas id="canvas"></canvas>
  2. JavaScript

    The Document.getElementById()
    method gets a reference to the HTML <canvas> element.
    Next, the HTMLCanvasElement.getContext() method
    gets that element’s context—the thing onto which the drawing will be rendered.

The actual drawing is done using the CanvasRenderingContext2D interface. The fillStyle property makes the rectangle green. The fillRect() method places its top-left corner at (10, 10), and gives it a size of 150 units wide by 100 tall.

const canvas = document.getElementById('canvas');
  const ctx = canvas.getContext('2d');
 ctx.fillStyle = 'green';
   ctx.fillRect(10, 10, 150, 100); 

* Drawing shapes* img

Drawing Text img