| 1 | {% extends "basex.html" %} |
| 2 | {% load markup %} |
| 3 | {% block pageid %}code{% endblock %} |
| 4 | {% block headers %} |
| 5 | <link href="doc.css" media="screen" rel="stylesheet" type="text/css" /> |
| 6 | {% endblock %} |
| 7 | {% block title %}PlotKit.Base{% endblock %} |
| 8 | |
| 9 | {% block content %} |
| 10 | <div class="page doc api"> |
| 11 | {% filter markdown %} |
| 12 | [PlotKit Home](PlotKit.html) | [>>](PlotKit.Layout.html) |
| 13 | |
| 14 | PlotKit Base |
| 15 | ============ |
| 16 | |
| 17 | PlotKit Base contains a number of simple functions that are needed for the rest of the PlotKit libraries. |
| 18 | |
| 19 | PlotKit.Base Functions |
| 20 | ---------------------- |
| 21 | |
| 22 | * ``collapse()`` |
| 23 | |
| 24 | Given an array, it will collapse all the values from the passed array into one big array. |
| 25 | |
| 26 | ``[[1,2], [3,4], [5,6]] --> [1, 2, 3, 4, 5, 6]`` |
| 27 | |
| 28 | * ``findPosX(element)`` |
| 29 | |
| 30 | Returns the X value of the element relative to the document in a browser independent way. |
| 31 | |
| 32 | * ``findPosY(element)`` |
| 33 | |
| 34 | Returns the Y value of the element relative to the document in a browser independent way. |
| 35 | |
| 36 | * ``palette(baseColor, fromLevel = -0.2, toLevel = 0.2, increment = 0.1)`` |
| 37 | |
| 38 | Takes in a base colour and generates a palette of colours based on the intensive levels. |
| 39 | |
| 40 | * ``roundInterval(value, precision)`` |
| 41 | |
| 42 | Rounds a number to a specified precision. __TODO: make more robust__ |
| 43 | |
| 44 | * ``uniq(array)`` |
| 45 | |
| 46 | Acts like the UNIX uniq, takes a sorted array and returns a new array that only contains uniq elements. |
| 47 | |
| 48 | * ``isFuncLike(obj)`` (PlotKit 0.9+) |
| 49 | |
| 50 | Returns true if it is of type ``function``. |
| 51 | |
| 52 | * ``usingPrototype()`` (PlotKit 0.9+) |
| 53 | |
| 54 | Checks whether the javascript runtime is polluted by prototype.js |
| 55 | |
| 56 | * ``items(lst)`` (PlotKit 0.9+) |
| 57 | |
| 58 | A version of ``MochiKit.Base.items()`` that is aware of prototype.js |
| 59 | |
| 60 | * ``keys(lst)`` (PlotKit 0.9+) |
| 61 | |
| 62 | A version of ``MochiKit.Base.keys()`` that is aware of prototype.js |
| 63 | |
| 64 | * ``map(fn, lst)`` (PlotKit 0.9+) |
| 65 | |
| 66 | A version of ``MochiKit.Base.map()`` that is aware of prototype.js |
| 67 | |
| 68 | Preset Styles |
| 69 | ============= |
| 70 | |
| 71 | Color Schemes |
| 72 | ------------- |
| 73 | |
| 74 | There are some colour schemes, which are an array of |
| 75 | MochiKit.Color.Colors. |
| 76 | |
| 77 | * ``colorScheme()`` |
| 78 | |
| 79 | A default colour scheme that consists of red, orange, yellow, green, cyan, blue, purple and magenta. |
| 80 | |
| 81 | * ``baseDarkPrimaryColors()`` |
| 82 | |
| 83 | A set of five dark colours. |
| 84 | |
| 85 | * ``basePrimaryColors()`` |
| 86 | |
| 87 | A set of five bright primary colours. |
| 88 | |
| 89 | * ``baseBlueColors()`` |
| 90 | |
| 91 | Three colour set that have a nice professional blue hue. |
| 92 | |
| 93 | Office Style |
| 94 | ------------ |
| 95 | |
| 96 | These are base styles that were inspired by charts in Office 12. The |
| 97 | color schemes are fairly similar to those found in screenshots of |
| 98 | charts available online. |
| 99 | |
| 100 | * ``officeBaseStyle`` |
| 101 | |
| 102 | Contains the basic style independent of colours. |
| 103 | |
| 104 | * ``officeBlue()`` |
| 105 | |
| 106 | Blue colors: ![bluecolors](blue.png) |
| 107 | |
| 108 | * ``officeRed()`` |
| 109 | |
| 110 | Red colors: ![redcolors](red.png) |
| 111 | |
| 112 | * ``officeGreen()`` |
| 113 | |
| 114 | Green colors: ![greencolors](green.png) |
| 115 | |
| 116 | * ``officePurple()`` |
| 117 | |
| 118 | Purple colors: ![purplecolors](purple.png) |
| 119 | |
| 120 | * ``officeCyan()`` |
| 121 | |
| 122 | Cyan colors: ![cyancolors](cyan.png) |
| 123 | |
| 124 | * ``officeOrange()`` |
| 125 | |
| 126 | Orange colors: ![orangecolors](orange.png) |
| 127 | |
| 128 | * ``officeBlack()`` |
| 129 | |
| 130 | Black colors: ![blackcolors](black.png) |
| 131 | |
| 132 | Usage |
| 133 | ----- |
| 134 | |
| 135 | ``var layout = PlotKit.Layout("bar", officeOrange());`` |
| 136 | |
| 137 | {% endfilter %} |
| 138 | </div> |
| 139 | {% endblock %} |