The following Pie Chart, drawn by D3.js library:
Using our plugin, named Blazing Charts, I added the following shortcode to this post:
(left-bracket)BlazingChart charttype="d3" source="d3-js-sample-pie" options="pie"(right bracket)
The first parameter specifies which charting library is used. The second parameter is the slug of a Custom Post Type, named Chart Snippets, introduced by that plugin. The third parameter can be a comma-separated list of auxiliary libraries loaded after the main one. For drawing pie charts, D3pie.js should also be loaded.
The source of the script for the drawing is added as plain text to a Chart Snippet. The content of the chart snippet for the above chart is as following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | <div id="d3pieChart"></div> <script> window.onload = function () { var pie = new d3pie("d3pieChart", { "header": { "title": { "text": "Lots of Programming Languages", "fontSize": 24, "font": "open sans" }, "subtitle": { "text": "A full pie chart to show off label collision detection and resolution.", "color": "#999999", "fontSize": 12, "font": "open sans" }, "titleSubtitlePadding": 9 }, "footer": { "color": "#999999", "fontSize": 10, "font": "open sans", "location": "bottom-left" }, "size": { "canvasWidth": 590, "pieOuterRadius": "90%" }, "data": { "sortOrder": "value-desc", "content": [ { "label": "JavaScript", "value": 264131, "color": "#2484c1" }, { "label": "Ruby", "value": 218812, "color": "#0c6197" }, { "label": "Java", "value": 157618, "color": "#4daa4b" }, { "label": "PHP", "value": 114384, "color": "#90c469" }, { "label": "Python", "value": 95002, "color": "#daca61" }, { "label": "C+", "value": 78327, "color": "#e4a14b" }, { "label": "C", "value": 67706, "color": "#e98125" }, { "label": "Objective-C", "value": 36344, "color": "#cb2121" }, { "label": "Shell", "value": 28561, "color": "#830909" }, { "label": "Cobol", "value": 24131, "color": "#923e99" }, { "label": "C#", "value": 100, "color": "#ae83d5" }, { "label": "Coldfusion", "value": 68, "color": "#bf273e" }, { "label": "Fortran", "value": 218812, "color": "#ce2aeb" }, { "label": "Coffeescript", "value": 157618, "color": "#bca44a" }, { "label": "Node", "value": 114384, "color": "#618d1b" }, { "label": "Basic", "value": 95002, "color": "#1ee67b" }, { "label": "Cola", "value": 36344, "color": "#b0ec44" }, { "label": "Perl", "value": 32170, "color": "#a4a0c9" }, { "label": "Dart", "value": 28561, "color": "#322849" }, { "label": "Go", "value": 264131, "color": "#86f71a" }, { "label": "Groovy", "value": 218812, "color": "#d1c87f" }, { "label": "Processing", "value": 157618, "color": "#7d9058" }, { "label": "Smalltalk", "value": 114384, "color": "#44b9b0" }, { "label": "Scala", "value": 95002, "color": "#7c37c0" }, { "label": "Visual Basic", "value": 78327, "color": "#cc9fb1" }, { "label": "Scheme", "value": 67706, "color": "#e65414" }, { "label": "Rust", "value": 36344, "color": "#8b6834" }, { "label": "FoxPro", "value": 32170, "color": "#248838" } ] }, "labels": { "outer": { "pieDistance": 32 }, "inner": { "hideWhenLessThanPercentage": 3 }, "mainLabel": { "fontSize": 11 }, "percentage": { "color": "#ffffff", "decimalPlaces": 0 }, "value": { "color": "#adadad", "fontSize": 11 }, "lines": { "enabled": true }, "truncation": { "enabled": true } }, "effects": { "pullOutSegmentOnClick": { "effect": "linear", "speed": 400, "size": 8 } }, "misc": { "gradient": { "enabled": true, "percentage": 100 } } }); } </script> |
<div id="d3pieChart"></div> <script> window.onload = function () { var pie = new d3pie("d3pieChart", { "header": { "title": { "text": "Lots of Programming Languages", "fontSize": 24, "font": "open sans" }, "subtitle": { "text": "A full pie chart to show off label collision detection and resolution.", "color": "#999999", "fontSize": 12, "font": "open sans" }, "titleSubtitlePadding": 9 }, "footer": { "color": "#999999", "fontSize": 10, "font": "open sans", "location": "bottom-left" }, "size": { "canvasWidth": 590, "pieOuterRadius": "90%" }, "data": { "sortOrder": "value-desc", "content": [ { "label": "JavaScript", "value": 264131, "color": "#2484c1" }, { "label": "Ruby", "value": 218812, "color": "#0c6197" }, { "label": "Java", "value": 157618, "color": "#4daa4b" }, { "label": "PHP", "value": 114384, "color": "#90c469" }, { "label": "Python", "value": 95002, "color": "#daca61" }, { "label": "C+", "value": 78327, "color": "#e4a14b" }, { "label": "C", "value": 67706, "color": "#e98125" }, { "label": "Objective-C", "value": 36344, "color": "#cb2121" }, { "label": "Shell", "value": 28561, "color": "#830909" }, { "label": "Cobol", "value": 24131, "color": "#923e99" }, { "label": "C#", "value": 100, "color": "#ae83d5" }, { "label": "Coldfusion", "value": 68, "color": "#bf273e" }, { "label": "Fortran", "value": 218812, "color": "#ce2aeb" }, { "label": "Coffeescript", "value": 157618, "color": "#bca44a" }, { "label": "Node", "value": 114384, "color": "#618d1b" }, { "label": "Basic", "value": 95002, "color": "#1ee67b" }, { "label": "Cola", "value": 36344, "color": "#b0ec44" }, { "label": "Perl", "value": 32170, "color": "#a4a0c9" }, { "label": "Dart", "value": 28561, "color": "#322849" }, { "label": "Go", "value": 264131, "color": "#86f71a" }, { "label": "Groovy", "value": 218812, "color": "#d1c87f" }, { "label": "Processing", "value": 157618, "color": "#7d9058" }, { "label": "Smalltalk", "value": 114384, "color": "#44b9b0" }, { "label": "Scala", "value": 95002, "color": "#7c37c0" }, { "label": "Visual Basic", "value": 78327, "color": "#cc9fb1" }, { "label": "Scheme", "value": 67706, "color": "#e65414" }, { "label": "Rust", "value": 36344, "color": "#8b6834" }, { "label": "FoxPro", "value": 32170, "color": "#248838" } ] }, "labels": { "outer": { "pieDistance": 32 }, "inner": { "hideWhenLessThanPercentage": 3 }, "mainLabel": { "fontSize": 11 }, "percentage": { "color": "#ffffff", "decimalPlaces": 0 }, "value": { "color": "#adadad", "fontSize": 11 }, "lines": { "enabled": true }, "truncation": { "enabled": true } }, "effects": { "pullOutSegmentOnClick": { "effect": "linear", "speed": 400, "size": 8 } }, "misc": { "gradient": { "enabled": true, "percentage": 100 } } }); } </script>
can you write it as a directive. I’m new to angular js and trying to learn.