1 {% extends "basex.html" %}
3 {% block pageid %}code{% endblock %}
5 <link href="doc.css" media="screen" rel="stylesheet" type="text/css" />
7 {% block title %}PlotKit.Base{% endblock %}
10 <div class="page doc api">
12 [PlotKit Home](PlotKit.html) | [>>](PlotKit.Layout.html)
17 PlotKit Base contains a number of simple functions that are needed for the rest of the PlotKit libraries.
19 PlotKit.Base Functions
20 ----------------------
24 Given an array, it will collapse all the values from the passed array into one big array.
26 ``[[1,2], [3,4], [5,6]] --> [1, 2, 3, 4, 5, 6]``
28 * ``findPosX(element)``
30 Returns the X value of the element relative to the document in a browser independent way.
32 * ``findPosY(element)``
34 Returns the Y value of the element relative to the document in a browser independent way.
36 * ``palette(baseColor, fromLevel = -0.2, toLevel = 0.2, increment = 0.1)``
38 Takes in a base colour and generates a palette of colours based on the intensive levels.
40 * ``roundInterval(value, precision)``
42 Rounds a number to a specified precision. __TODO: make more robust__
46 Acts like the UNIX uniq, takes a sorted array and returns a new array that only contains uniq elements.
48 * ``isFuncLike(obj)`` (PlotKit 0.9+)
50 Returns true if it is of type ``function``.
52 * ``usingPrototype()`` (PlotKit 0.9+)
54 Checks whether the javascript runtime is polluted by prototype.js
56 * ``items(lst)`` (PlotKit 0.9+)
58 A version of ``MochiKit.Base.items()`` that is aware of prototype.js
60 * ``keys(lst)`` (PlotKit 0.9+)
62 A version of ``MochiKit.Base.keys()`` that is aware of prototype.js
64 * ``map(fn, lst)`` (PlotKit 0.9+)
66 A version of ``MochiKit.Base.map()`` that is aware of prototype.js
74 There are some colour schemes, which are an array of
75 MochiKit.Color.Colors.
79 A default colour scheme that consists of red, orange, yellow, green, cyan, blue, purple and magenta.
81 * ``baseDarkPrimaryColors()``
83 A set of five dark colours.
85 * ``basePrimaryColors()``
87 A set of five bright primary colours.
89 * ``baseBlueColors()``
91 Three colour set that have a nice professional blue hue.
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.
100 * ``officeBaseStyle``
102 Contains the basic style independent of colours.
106 Blue colors: ![bluecolors](blue.png)
110 Red colors: ![redcolors](red.png)
114 Green colors: ![greencolors](green.png)
118 Purple colors: ![purplecolors](purple.png)
122 Cyan colors: ![cyancolors](cyan.png)
126 Orange colors: ![orangecolors](orange.png)
130 Black colors: ![blackcolors](black.png)
135 ``var layout = PlotKit.Layout("bar", officeOrange());``