Chart.js, Canvas
EASILY CREATE STUNNING ANIMATED CHARTS WITH CHART.JS
A great way to get started with charts is with Chart.js, a JavaScript plugin that uses HTML5’s canvas element to draw the graph onto the page.
Setting up:
globalAlpha = transparencyValue .
Line styles :There are several properties which allow us to style lines.
- lineWidth = value: Sets the width of lines drawn in the future.
- lineCap = type :Sets the appearance of the ends of lines.
- lineJoin = type :Sets the appearance of the “corners” where lines meet.
- miterLimit = value : Establishes a limit on the miter when two lines join at a sharp angle, to let you control how thick the junction becomes.
- getLineDash() :Returns the current line dash pattern array containing an even number of non-negative numbers.
- setLineDash(segments) :Sets the current line dash pattern.
- lineDashOffset = value :Specifies where to start a dash array on a line.
Drawing text
The canvas rendering context provides two methods to render text:
1- fillText(text, x, y [, maxWidth]) :Fills a given text at the given (x,y) position. Optionally with a maximum width to draw.
2- strokeText(text, x, y [, maxWidth]) :Strokes a given text at the given (x,y) position. Optionally with a maximum width to draw.
Styling text
we are already making use of the font property to make the text a bit larger than the default size. There are some more properties which let you adjust the way the text gets displayed on the canvas:
- font = value:The current text style being used when drawing text. This string uses the same syntax as the CSS font property. The default font is 10px sans-serif.
- textAlign = value:Text alignment setting. Possible values: start, end, left, right or center. The default value is start.
- textBaseline = value:Baseline alignment setting. Possible values: top, hanging, middle, alphabetic, ideographic, bottom. The default value is alphabetic.
- direction = value: Directionality. Possible values: ltr, rtl, inherit. The default value is inherit.