-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
207 lines (200 loc) · 13.3 KB
/
index.html
File metadata and controls
207 lines (200 loc) · 13.3 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
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Scatterplot</title>
<link href="css/project.css" rel="stylesheet" type="text/css" />
<link href="css/scatterplot.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<h1>Scatterplot.js <small>(v1.1.1)</small></h1>
<h3>A jQuery plugin for creating 2D <a href="http://en.wikipedia.org/wiki/Scatter_plot" target="_blank">scatter plot</a> graphs and charts.</h3>
<hr/>
<section>
<h2>Installation</h2>
<p>Download <span class="code inline-code">scatterplot.min.js</span> and <span class="code inline-code">scatterplot.css</span> from <a href="https://github.com/pwoidke/Scatterplot-js" target="_blank">GitHub</a>. Add these files to your site by adding the following references in your HTML file:</p>
<div class="code">
<link href="scatterplot.css" rel="stylesheet" type="text/css" /><br/>
<script src="scatterplot.min.js"></script>
</div>
</section>
<section>
<h2>Usage</h2>
<p>Create a HTML element to act as your graph and child elements to act as points:</p>
<div class="code">
<div id="scatterplot"><br/>
<span class="indent"><span id="point"></span></span><br/>
</div>
</div>
<article>
<h3>With no configuration (default):</h3>
<div class="code">
$(document).ready(function () {<br/>
<span class="indent">$('#scatterplot').scatter();</span><br/>
<span class="indent">$('#point').plot();</span><br/>
});
</div>
<div class="demo">
<div id="scatterplot">
<span id="point"></span>
</div>
</div>
</article>
<article>
<h3>With settings (static):</h3>
<div class="code">
$(document).ready(function () {<br/>
<span class="indent">$('#scatterplot').scatter({ height: 500, width: 500, xLabel: 'X-Axis Label', yLabel: 'Y-Axis Label', rows: 4, columns: 5, subsections: 5 });</span><br/>
<span class="indent">$('#point1').plot({ xPos: 100, yPos: 100, color: 'red' });</span><br/>
<span class="indent">$('#point2').plot({ xPos: 320, yPos: 145, radius: 30, color: 'blue' });</span><br/>
<span class="indent">$('#point3').plot({ xPos: 460, yPos: 410, radius: 10, color: 'green' });</span><br/>
});
</div>
<div class="demo">
<div id="scatterplotStatic">
<span id="point1S"></span>
<span id="point2S"></span>
<span id="point3S"></span>
</div>
</div>
</article>
<article>
<h3>With settings (responsive):</h3>
<div class="code">
$(document).ready(function () {<br/>
<span class="indent">$('#scatterplot').scatter({ height: 500, width: '50%', xLabel: 'X-Axis Label', yLabel: 'Y-Axis Label', rows: 5, columns: 5, subsections: 5, responsive: true, xUnits: ["0%", "20%", "40%", "60%", "80%", "100%"], yUnits: [0, 10, 20, 30, 40, 50] });</span><br/>
<span class="indent">$('#point1').plot({ xPos: '10%', yPos: '10%', color: 'red' });</span><br/>
<span class="indent">$('#point2').plot({ xPos: '60%', yPos: '40%', radius: 30, color: 'blue' });</span><br/>
<span class="indent">$('#point3').plot({ xPos: '90%', yPos: '75%', radius: 10, color: 'green' });</span><br/>
});
</div>
<div class="demo">
<div id="scatterplotResponsive">
<span id="point1R"></span>
<span id="point2R"></span>
<span id="point3R"></span>
</div>
</div>
</article>
<article>
<h3>Plotting By Class (Static):</h3>
<h4>HTML:</h4>
<div class="code">
<div id="scatterplot"><br/>
<span class="indent"><span class="point" style="left: 100px; bottom: 100px;"></span></span><br/>
<span class="indent"><span class="point" style="left: 300px; bottom: 250px; background-color: blue;"></span></span><br/>
<span class="indent"><span class="point" style="left: 400px; bottom: 450px; background-color: green; width: 15px;"></span></span><br/>
</div>
</div>
<h4>Javascript:</h4>
<div class="code">
$(document).ready(function () {<br/>
<span class="indent">$('#scatterplot').scatter({ height: 500, width: 500, xLabel: 'X-Axis', yLabel: 'Y-Axis', rows: 5, columns: 5, subsections: 5 });</span><br/>
<span class="indent">$('.point').plot();</span><br/>
});
</div>
<div class="demo">
<div id="scatterplotStaticClass">
<span class="pointSC" style="left: 100px; bottom: 100px;"></span>
<span class="pointSC" style="left: 300px; bottom: 250px; background-color: blue;"></span>
<span class="pointSC" style="left: 400px; bottom: 450px; background-color: green; width: 15px;"></span>
</div>
</div>
</article>
<article>
<h3>Plotting By Class (Responsive):</h3>
<h4>HTML:</h4>
<div class="code">
<div id="scatterplot"><br/>
<span class="indent"><span class="point" style="left: 20%; bottom: 20%;"></span></span><br/>
<span class="indent"><span class="point" style="left: 50%; bottom: 50%; background-color: #f00ff0;"></span></span><br/>
<span class="indent"><span class="point" style="left: 70%; bottom: 80%; background-color: blue; width: 15px;"></span></span><br/>
</div>
</div>
<h4>Javascript:</h4>
<div class="code">
$(document).ready(function () {<br/>
<span class="indent">$('#scatterplot').scatter({ height: 500, width: 500, xLabel: 'X-Axis', yLabel: 'Y-Axis', rows: 5, columns: 5, subsections: 5, responsive: true });</span><br/>
<span class="indent">$('.point').plot();</span><br/>
});
</div>
<div class="demo">
<div id="scatterplotResponsiveClass">
<span class="pointRC" style="left: 20%; bottom: 20%;"></span>
<span class="pointRC" style="left: 50%; bottom: 50%; background-color: #f00ff0;"></span>
<span class="pointRC" style="left: 70%; bottom: 80%; background-color: blue; width: 15px;"></span>
</div>
</div>
</article>
</section>
<section>
<h2>Settings</h2>
<h3>Javascript</h3>
<div class="code">
$('#scatterplot').scatter({<br/>
<span class="indent block block-left">height: 300,</span><span class="indent block block-right comment">// Height of the graph (ex: 500, '50%')</span></span><br/>
<span class="indent block block-left">width: 300,</span><span class="indent block block-right comment">// Width of the graph (ex: 500, '50%')</span></span><br/>
<span class="indent block block-left">xLabel: '',</span><span class="indent block block-right comment">// Text of label for X-axis</span></span><br/>
<span class="indent block block-left">yLabel: '',</span><span class="indent block block-right comment">// Text of label for Y-axis</span></span><br/>
<span class="indent block block-left">rows: 1,</span><span class="indent block block-right comment">// Number of rows in graph</span></span><br/>
<span class="indent block block-left">columns: 1,</span><span class="indent block block-right comment">// Number of columns in graph</span></span><br/>
<span class="indent block block-left">subsections: 1,</span><span class="indent block block-right comment">// Number of subsections for each row/column</span></span><br/>
<span class="indent block block-left">color: '#CCC',</span><span class="indent block block-right comment">// Background color of graph</span></span><br/>
<span class="indent block block-left">responsive: false,</span><span class="indent block block-right comment">// Set whether graph is responsive (position of labels, units, lines, points set to percentages)</span></span><br/>
<span class="indent block block-left">xUnits: [],</span><span class="indent block block-right comment">// Array of units for X-axis (will be evenly spaced from bottom-left corner to bottom-right corner) (ex: ["0%", "20%", "40%", "60%", "80%", "100%"], [0, 10, 20, 30, 40, 50])</span></span><br/>
<span class="indent block block-left">yUnits: []</span><span class="indent block block-right comment">// Array of units for Y-axis (will be evenly spaced from bottom-left corner to bottom-right corner) (ex: ["0%", "20%", "40%", "60%", "80%", "100%"], [0, 10, 20, 30, 40, 50])</span></span><br/>
});
</div>
<h3>CSS</h3>
<p>When creating points, the position, background color, and width can be set using inline styling:</p>
<div class="code">
<span id="point" style="left: 100px; bottom: 100px; background-color: red; width: 30px;"></span><br/>
<span id="point" style="left: 50%; bottom: 50%; background-color: #FFFF00; width: 2em;"></span><br/>
<span id="point" style="left: 25%; bottom: 50px; background-color: rgba(255, 255, 0, .5); width: 10%;"></span>
</div>
</section>
<section>
<h2>TODOs</h2>
<ul>
<li>Improve documentation</li>
<li>Clean up and optimize code</li>
<li><del>Create functionality for plotting an array of points</del></li>
</ul>
</section>
<section>
<h2> Issues</h2>
<ul>
<li>Graph <span class="code inline-code">background-position</span> (used for subsections) not aligned correctly for responsive graphs (Chrome)</li>
<li>Graph <span class="code inline-code">background-image</span> (used for subsections) does not work for responsive graphs (IE)</li>
<li>Points shift slightly when resizing responsive graphs (All browsers)</li>
</ul>
</section>
<section>
<h2>License</h2>
<p>Copyright 2013 <a href="http://paulwoidke.com/" target="_blank">Paul Woidke</a></p>
<p>Licensed under the <a href="http://opensource.org/licenses/MIT" target="_blank">MIT License</a></p>
</section>
</div>
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/scatterplot.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#scatterplot').scatter();
$('#point').plot();
$('#scatterplotStatic').scatter({ height: 500, width: 500, xLabel: 'X-Axis Label', yLabel: 'Y-Axis Label', rows: 4, columns: 5, subsections: 5 });
$('#point1S').plot({ xPos: 100, yPos: 100, color: 'red' });
$('#point2S').plot({ xPos: 320, yPos: 145, radius: 30, color: 'blue' });
$('#point3S').plot({ xPos: 460, yPos: 410, radius: 10, color: 'green' });
$('#scatterplotResponsive').scatter({ height: 500, width: '50%', xLabel: 'X-Axis Label', yLabel: 'Y-Axis Label', rows: 5, columns: 5, subsections: 5, responsive: true, xUnits: ["0%", "20%", "40%", "60%", "80%", "100%"], yUnits: [0, 10, 20, 30, 40, 50] });
$('#point1R').plot({ xPos: '10%', yPos: '10%', color: 'red' });
$('#point2R').plot({ xPos: '60%', yPos: '40%', radius: 30, color: 'blue' });
$('#point3R').plot({ xPos: '90%', yPos: '75%', radius: 10, color: 'green' });
$('#scatterplotStaticClass').scatter({ height: 500, width: 500, xLabel: 'X-Axis', yLabel: 'Y-Axis', rows: 5, columns: 5, subsections: 5 });
$('.pointSC').plot();
$('#scatterplotResponsiveClass').scatter({ height: 500, width: '50%', xLabel: 'X-Axis', yLabel: 'Y-Axis', rows: 5, columns: 5, subsections: 5, responsive: true });
$('.pointRC').plot();
});
</script>
</body>
</html>