PlotKit.Base.txt
3.07 KB
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
{% extends "basex.html" %}
{% load markup %}
{% block pageid %}code{% endblock %}
{% block headers %}
<link href="doc.css" media="screen" rel="stylesheet" type="text/css" />
{% endblock %}
{% block title %}PlotKit.Base{% endblock %}
{% block content %}
<div class="page doc api">
{% filter markdown %}
[PlotKit Home](PlotKit.html) | [>>](PlotKit.Layout.html)
PlotKit Base
============
PlotKit Base contains a number of simple functions that are needed for the rest of the PlotKit libraries.
PlotKit.Base Functions
----------------------
* ``collapse()``
Given an array, it will collapse all the values from the passed array into one big array.
``[[1,2], [3,4], [5,6]] --> [1, 2, 3, 4, 5, 6]``
* ``findPosX(element)``
Returns the X value of the element relative to the document in a browser independent way.
* ``findPosY(element)``
Returns the Y value of the element relative to the document in a browser independent way.
* ``palette(baseColor, fromLevel = -0.2, toLevel = 0.2, increment = 0.1)``
Takes in a base colour and generates a palette of colours based on the intensive levels.
* ``roundInterval(value, precision)``
Rounds a number to a specified precision. __TODO: make more robust__
* ``uniq(array)``
Acts like the UNIX uniq, takes a sorted array and returns a new array that only contains uniq elements.
* ``isFuncLike(obj)`` (PlotKit 0.9+)
Returns true if it is of type ``function``.
* ``usingPrototype()`` (PlotKit 0.9+)
Checks whether the javascript runtime is polluted by prototype.js
* ``items(lst)`` (PlotKit 0.9+)
A version of ``MochiKit.Base.items()`` that is aware of prototype.js
* ``keys(lst)`` (PlotKit 0.9+)
A version of ``MochiKit.Base.keys()`` that is aware of prototype.js
* ``map(fn, lst)`` (PlotKit 0.9+)
A version of ``MochiKit.Base.map()`` that is aware of prototype.js
Preset Styles
=============
Color Schemes
-------------
There are some colour schemes, which are an array of
MochiKit.Color.Colors.
* ``colorScheme()``
A default colour scheme that consists of red, orange, yellow, green, cyan, blue, purple and magenta.
* ``baseDarkPrimaryColors()``
A set of five dark colours.
* ``basePrimaryColors()``
A set of five bright primary colours.
* ``baseBlueColors()``
Three colour set that have a nice professional blue hue.
Office Style
------------
These are base styles that were inspired by charts in Office 12. The
color schemes are fairly similar to those found in screenshots of
charts available online.
* ``officeBaseStyle``
Contains the basic style independent of colours.
* ``officeBlue()``
Blue colors: 
* ``officeRed()``
Red colors: 
* ``officeGreen()``
Green colors: 
* ``officePurple()``
Purple colors: 
* ``officeCyan()``
Cyan colors: 
* ``officeOrange()``
Orange colors: 
* ``officeBlack()``
Black colors: 
Usage
-----
``var layout = PlotKit.Layout("bar", officeOrange());``
{% endfilter %}
</div>
{% endblock %}