├── LICENSE ├── README.md ├── dev └── simpleD3.html ├── docs ├── example.js ├── images │ ├── logo.png │ └── logo.svg ├── reference.html └── release-notes.html ├── index.html ├── peek.css ├── peek.js └── require ├── d3.min.js ├── fonts ├── DroidSansMono.woff ├── OpenSans.woff ├── OpenSansBold.woff ├── OpenSansBoldItalic.woff └── OpenSansItalic.woff ├── framework.icons.js ├── framework.min.css ├── framework.min.js ├── highlight.min.css ├── highlight.min.js └── textures.min.js /LICENSE: -------------------------------------------------------------------------------- 1 | Peek is licensed under the MIT license 2 | -------------------------------------- 3 | 4 | Copyright (c) 2015 Mark Macdonald 5 | 6 | Peek includes third-party libraries (see below). 7 | 8 | MIT licensed: 9 | ------------- 10 | 11 | Webknife: Copyright (c) 2015 The Webknife Project, (http://mtmacdonald.github.io/webknife) 12 | 13 | Webknife includes third-party libraries attributed here: https://github.com/mtmacdonald/webknife/blob/master/LICENSE 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy 16 | of this software and associated documentation files (the "Software"), to deal 17 | in the Software without restriction, including without limitation the rights 18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | copies of the Software, and to permit persons to whom the Software is 20 | furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | 33 | BSD licensed: 34 | ------------- 35 | 36 | d3.js: Copyright (c) 2010-2015, Michael Bostock (http://d3js.org) 37 | 38 | Redistribution and use in source and binary forms, with or without 39 | modification, are permitted provided that the following conditions are met: 40 | 41 | * Redistributions of source code must retain the above copyright notice, this 42 | list of conditions and the following disclaimer. 43 | 44 | * Redistributions in binary form must reproduce the above copyright notice, 45 | this list of conditions and the following disclaimer in the documentation 46 | and/or other materials provided with the distribution. 47 | 48 | * The name Michael Bostock may not be used to endorse or promote products 49 | derived from this software without specific prior written permission. 50 | 51 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 52 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 53 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 54 | DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, 55 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 56 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 58 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 59 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 60 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | peek 2 | ==== 3 | 4 | Charts based on D3 5 | -------------------------------------------------------------------------------- /dev/simpleD3.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /docs/example.js: -------------------------------------------------------------------------------- 1 | /*! Peek.js (c) 2015 Mark Macdonald | http://mtmacdonald.github.io/peek/LICENSE */ 2 | 3 | /* 4 | Example input data for Peek.js 5 | */ 6 | 7 | var timeData = [ 8 | { 9 | "label": "Foo", 10 | "units": "kg", 11 | "group" : "A", 12 | "color": "#69A9CA", 13 | "values": [ 14 | { 15 | x : "2014-03-01 00:00:00", 16 | y : 3 17 | }, 18 | { 19 | x : "2014-03-02 00:00:00", 20 | y : 1.43 21 | }, 22 | { 23 | x : "2014-03-03 00:00:00", 24 | y : 0.38 25 | }, 26 | { 27 | x : "2014-03-04 00:00:00", 28 | y : 3.5 29 | }, 30 | { 31 | x : "2014-03-05 00:00:00", 32 | y : 2.0 33 | } 34 | ] 35 | }, 36 | { 37 | "label": "Foo", 38 | "units": "kg", 39 | "group" : "B", 40 | "color": "#8583C2", 41 | "values": [ 42 | { 43 | x : "2014-03-01 00:00:00", 44 | y : 2 45 | }, 46 | { 47 | x : "2014-03-02 00:00:00", 48 | y : 4.5 49 | }, 50 | { 51 | x : "2014-03-03 00:00:00", 52 | y : 6 53 | }, 54 | { 55 | x : "2014-03-04 00:00:00", 56 | y : 1.1 57 | }, 58 | { 59 | x : "2014-03-05 00:00:00", 60 | y : 0.8 61 | } 62 | ] 63 | }, 64 | { 65 | "label": "Foo", 66 | "units": "kg", 67 | "group" : "C", 68 | "color": "#67D1B8", 69 | "values": [ 70 | { 71 | x : "2014-03-01 00:00:00", 72 | y : 2 73 | }, 74 | { 75 | x : "2014-03-02 00:00:00", 76 | y : 4.5 77 | }, 78 | { 79 | x : "2014-03-03 00:00:00", 80 | y : 6 81 | }, 82 | { 83 | x : "2014-03-04 00:00:00", 84 | y : 1.1 85 | }, 86 | { 87 | x : "2014-03-05 00:00:00", 88 | y : 0.8 89 | } 90 | ] 91 | }, 92 | { 93 | "label": "Bar", 94 | "units": "m/s", 95 | "group" : "A", 96 | "color": "#C76842", 97 | "values": [ 98 | { 99 | x : "2014-03-01 00:00:00", 100 | y : 2 101 | }, 102 | { 103 | x : "2014-03-02 00:00:00", 104 | y : 4.4 105 | }, 106 | { 107 | x : "2014-03-03 00:00:00", 108 | y : 0.8 109 | }, 110 | { 111 | x : "2014-03-04 00:00:00", 112 | y : 2.24 113 | }, 114 | { 115 | x : "2014-03-05 00:00:00", 116 | y : 2.0 117 | } 118 | ] 119 | }, 120 | { 121 | "label": "Bar", 122 | "units": "m/s", 123 | "group" : "B", 124 | "color": "#C06472", 125 | "values": [ 126 | { 127 | x : "2014-03-01 00:00:00", 128 | y : 4.2 129 | }, 130 | { 131 | x : "2014-03-02 00:00:00", 132 | y : 2.4 133 | }, 134 | { 135 | x : "2014-03-03 00:00:00", 136 | y : 0.6 137 | }, 138 | { 139 | x : "2014-03-04 00:00:00", 140 | y : 5.1 141 | }, 142 | { 143 | x : "2014-03-05 00:00:00", 144 | y : 9.0 145 | } 146 | ] 147 | }, 148 | { 149 | "label": "Bar", 150 | "units": "m/s", 151 | "group" : "C", 152 | "color": "#C99336", 153 | "values": [ 154 | { 155 | x : "2014-03-01 00:00:00", 156 | y : 5 157 | }, 158 | { 159 | x : "2014-03-02 00:00:00", 160 | y : 1.5 161 | }, 162 | { 163 | x : "2014-03-03 00:00:00", 164 | y : 7 165 | }, 166 | { 167 | x : "2014-03-04 00:00:00", 168 | y : 2.1 169 | }, 170 | { 171 | x : "2014-03-05 00:00:00", 172 | y : 5.8 173 | } 174 | ] 175 | }, 176 | { 177 | "label": "Baz", 178 | "units": "l", 179 | "group" : "A", 180 | "color": "#68843C", 181 | "values": [ 182 | { 183 | x : "2014-03-01 00:00:00", 184 | y : 1 185 | }, 186 | { 187 | x : "2014-03-02 00:00:00", 188 | y : 3.2 189 | }, 190 | { 191 | x : "2014-03-03 00:00:00", 192 | y : 3.6 193 | }, 194 | { 195 | x : "2014-03-04 00:00:00", 196 | y : 1.9 197 | }, 198 | { 199 | x : "2014-03-05 00:00:00", 200 | y : 3.1 201 | } 202 | ] 203 | }, 204 | { 205 | "label": "Baz", 206 | "units": "l", 207 | "group" : "B", 208 | "color": "#84D747", 209 | "values": [ 210 | { 211 | x : "2014-03-01 00:00:00", 212 | y : 3.2 213 | }, 214 | { 215 | x : "2014-03-02 00:00:00", 216 | y : 2.2 217 | }, 218 | { 219 | x : "2014-03-03 00:00:00", 220 | y : 4.6 221 | }, 222 | { 223 | x : "2014-03-04 00:00:00", 224 | y : 5.1 225 | }, 226 | { 227 | x : "2014-03-05 00:00:00", 228 | y : 0.1 229 | } 230 | ] 231 | }, 232 | { 233 | "label": "Baz", 234 | "units": "l", 235 | "group" : "C", 236 | "color": "#6C7970", 237 | "values": [ 238 | { 239 | x : "2014-03-01 00:00:00", 240 | y : 1 241 | }, 242 | { 243 | x : "2014-03-02 00:00:00", 244 | y : 2.5 245 | }, 246 | { 247 | x : "2014-03-03 00:00:00", 248 | y : 5 249 | }, 250 | { 251 | x : "2014-03-04 00:00:00", 252 | y : 3.1 253 | }, 254 | { 255 | x : "2014-03-05 00:00:00", 256 | y : 1.8 257 | } 258 | ] 259 | }, 260 | ]; 261 | 262 | var horizontalBarData = [ 263 | { 264 | "label": "Foo", 265 | "units" : "", 266 | "color": "#69A9CA", 267 | "value": 80, 268 | }, 269 | { 270 | "label": "Bar", 271 | "units" : "", 272 | "color": "#C76842", 273 | "value": 50, 274 | }, 275 | { 276 | "label": "Baz", 277 | "units" : "", 278 | "color": "#68843C", 279 | "value": 30, 280 | }, 281 | { 282 | "label": "Qux", 283 | "units" : "", 284 | "color": "#8583C2", 285 | "value": 2, 286 | }, 287 | ]; 288 | 289 | var radialData = [ 290 | { 291 | "label": "Foo", 292 | "units" : "", 293 | "color": "#69A9CA", 294 | "value": 50, 295 | }, 296 | { 297 | "label": "Bar", 298 | "units" : "", 299 | "color": "#C76842", 300 | "value": 25, 301 | }, 302 | { 303 | "label": "Baz", 304 | "units" : "", 305 | "color": "#68843C", 306 | "value": 25, 307 | }, 308 | ]; 309 | 310 | function getFirstGroupData() { 311 | var data = JSON.parse(JSON.stringify(timeData)); //clone 312 | var firstGroupName = data[0].group; 313 | var i = data.length; 314 | while (i--) { //iterate data in reverse to allow safe deletion 315 | if (data[i].group !== firstGroupName) { 316 | data.splice(i, 1); 317 | } 318 | } 319 | return data; 320 | } 321 | 322 | function getFirstGroupDataWithScale() { 323 | var data = getFirstGroupData(); 324 | data.forEach(function (series, i) { 325 | if (i === 0) { 326 | series.dualScale = true; 327 | } 328 | }); 329 | return data; 330 | } 331 | 332 | function getFirstGroupDataWithTexture() { 333 | var data = getFirstGroupData(); 334 | data.forEach(function (series) { 335 | series.texture = 'diagonal'; 336 | }); 337 | return data; 338 | } 339 | 340 | function getFirstGroupFirstSeriesData() { 341 | var data = JSON.parse(JSON.stringify(timeData)); //clone 342 | data.splice(1, data.length); 343 | return data; 344 | } 345 | 346 | function getAllGroupsLastSeriesData() { 347 | var data = JSON.parse(JSON.stringify(timeData)); //clone 348 | var alreadyIncluded = []; 349 | var i = data.length; 350 | while (i--) { //iterate data in reverse to allow safe deletion 351 | if (!(alreadyIncluded.indexOf(data[i].group) > -1)) { 352 | alreadyIncluded.push(data[i].group); 353 | } else { 354 | data.splice(i, 1); 355 | } 356 | } 357 | return data; 358 | } 359 | 360 | function getLinearData() { 361 | var data = getFirstGroupData(); 362 | //instead of a time scale, return a linear x-scale with values 1-5 363 | data.forEach(function (series, i) { 364 | var xVal = 1; 365 | for (var point in series.values) { 366 | if (series.values.hasOwnProperty(point)) { 367 | series.values[point].x = xVal; 368 | ++xVal; 369 | } 370 | } 371 | }); 372 | return data; 373 | } 374 | 375 | function getOrdinalData() { 376 | var data = getFirstGroupData(); 377 | //instead of a time scale, return an ordinal x-scale with values A-E 378 | data.forEach(function (series, i) { 379 | var xVal = 1; 380 | for (var point in series.values) { 381 | if (series.values.hasOwnProperty(point)) { 382 | if (xVal === 1) { 383 | series.values[point].x = 'A'; 384 | } else if (xVal === 2) { 385 | series.values[point].x = 'B'; 386 | } else if (xVal === 3) { 387 | series.values[point].x = 'C'; 388 | } else if (xVal === 4) { 389 | series.values[point].x = 'D'; 390 | } else if (xVal === 5) { 391 | series.values[point].x = 'E'; 392 | } 393 | ++xVal; 394 | } 395 | } 396 | }); 397 | return data; 398 | } -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtmacdonald/peek/d4e1bb4ae3c803991b945eb640daefb65a097a2a/docs/images/logo.png -------------------------------------------------------------------------------- /docs/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 62 | -------------------------------------------------------------------------------- /docs/reference.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |Peek supports the following chart types:
116 | 117 |See the example data for the input JSON format. The time-series charts are interchangeable 141 | (a common data format can be used with all chart types). 142 |
143 | 144 |176 | Dual y-axes with series belonging to one of two scales. Note: only line and scatter charts support dual y-axes. 177 |
178 |203 | See the D3.js documentation 204 | and this example for a list of interpolation types. 205 |
206 |The horizontal bar chart features a flexible height, which expands automatically as more rows are added to the data input.
603 | 604 |258 | Peek is a an object-oriented chart library for web applications, based on D3.js. 259 |
260 | 261 |The benefits of D3.js, but with easier, configurable, reusable chart objects.
265 |Supports scatter, line, area, bar, pie, and donut charts in multiple orientations and configurations.
269 |Display and compare multiple data series with stacked and grouped charts.
273 |Scales and axis tick labels are handled automatically, with input data maxima detection.
277 |Optional best-fit curves and line smoothing with 281 | D3 line interpolation.
282 |Standardised data inputs allow the same dataset to easily be displayed in multiple chart types. 286 |
287 |Support for configurable chart titles, axis labels, and legends.
291 |Optionally show data points, with interactive tooltips for displaying values.
295 |Peek provides an HTML5, CSS3 and JavaScript chart library for any modern web application.
299 | 300 |Peek is server-side agnostic and will work with any backend framework.
305 | 306 |310 | Download or clone a copy of the library. 311 |
312 |316 | Copy and paste from the examples. 317 |
318 |322 | Attach to any webpage, and publish. 323 |
324 |The key point is to attach the library CSS and JavaScript files:
328 | 329 |<link rel="stylesheet" href="peek.css" type="text/css" />
330 |
331 | <script src="require/d3.min.js"></script>
332 | <script src="peek.js"></script>
333 |
334 |
335 | The best way to get an overview is to look at the examples. 341 | 342 |
User classes are accessed directy. Internal classes are only accessed indirectly, as a child members of a user class.
345 | 346 |Legends, titles, and labels (except axis tick labels) are rendered as HTML elements, not SVG elements. This is 372 | primarily because HTML elements handle text overflow better. The chart topology, with CSS class names, is shown below: 373 |
374 | 375 |