From 74c283660ed551d265dde9074f6258842fe7b795 Mon Sep 17 00:00:00 2001 From: Connie Lei <23634958+connielei@users.noreply.github.com> Date: Tue, 8 Jan 2019 10:08:02 -0500 Subject: [PATCH] fixed formatting, removed extra whitespaces (#26251) --- guide/english/svg/index.md | 84 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/guide/english/svg/index.md b/guide/english/svg/index.md index b5dba82f94..919ebe48fa 100644 --- a/guide/english/svg/index.md +++ b/guide/english/svg/index.md @@ -19,13 +19,12 @@ This sample won't display anything, it merely established a viewport. You can ad With a viewport in place you can add basic graphics, text, and path elements. ```svg - + xmlns="http://www.w3.org/2000/svg" > - + SVG Text is browser readable! @@ -68,17 +67,19 @@ Canvas graphics can be drawn onto a element. You can give such an eleme The tag is intended to support different styles of drawing. To get access to an actual drawing interface, we first need to create a context, which is an object whose methods provide the drawing interface. There are currently two widely supported drawing styles: "2d" for two-dimensional graphics and "webgl" for three-dimensional graphics through the OpenGL interface. A context is created through the getContext method on the element. +```html + + + + + ``` -

Before canvas .

-< canvas width ="120" height ="60" > -

After canvas .

-< script > -var canvas = document . querySelector (" canvas ") ; -var context = canvas . getContext ("2 d ") ; -context . fillStyle = " red "; -context . fillRect (10 , 10 , 100 , 50) ; - -``` + ![](http://www.crwflags.com/fotw/images/s/sly@stt.gif) After creating the context object, the example draws a red rectangle 100 @@ -89,39 +90,36 @@ pixels wide and 50 pixels high, with its top-left corner at coordinates The results variable contains an array of objects that represent the survey responses. -``` -var results = [ -{ name : " Satisfied " , count : 1043 , color : " lightblue "} , -{ name : " Neutral " , count : 563 , color : " lightgreen "} , -{ name : " Unsatisfied " , count : 510 , color : " pink "} , -{ name : " No comment " , count : 175 , color : " silver "} -]; +```javascript +var results = [{ name: "Satisfied", count: 1043, color: "lightblue"}, + { name: "Neutral", count: 563, color: "lightgreen"}, + { name: "Unsatisfied", count: 510, color: "pink"}, + { name: "No comment", count: 175, color: "silver"}]; ``` To draw a pie chart, we draw a number of pie slices, each made up of an arc and a pair of lines to the center of that arc. We can compute the angle taken up by each arc by dividing a full circle (2 π ) by the total number of responses and then multiplying that number (the angle per response) by the number of people who picked a given choice. -``` -< canvas width ="200" height ="200" > -< script > -var cx = document . querySelector (" canvas ") . getContext ("2 d ") ; -var total = results . reduce ( function ( sum , choice ) { -return sum + choice . count ; -} , 0) ; - +```html + + ``` This draws the following chart: ![](https://pbs.twimg.com/media/CTDvkA8UwAAdJg5.png)