/
index.html
180 lines (157 loc) · 6.64 KB
/
index.html
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
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Function Plot - 2d function plotter powered by d3</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<!-- Place favicon.ico in the root directory -->
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
<link rel="stylesheet" href="css/normalize.css">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/github.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/languages/javascript.min.js"></script>
<!-- app -->
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser.
Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="header">
<header class="text-center container">
<h1>
<span class="logo">$f(x)$</span> - Function Plot<br/>
</h1>
<span>A 2d function plotter powered by D3</span>
<div class="social-buttons">
<div>
<!--github-->
<iframe src="https://ghbtns.com/github-btn.html?user=mauriciopoppe&repo=function-plot&type=star&count=true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
<!--twitter-->
<a href="https://twitter.com/share" class="twitter-share-button" data-via="mauricio_poppe">Tweet</a>
<script>!function(d,s,id){var
js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>
</div>
</header>
</div>
<div class="container" id="description">
<p>
<b>Function Plot</b> is a plotting library built on top of <a href="https://d3js.org/">D3.js</a>
used to render functions with little configuration (think of it as a clone of Google's
plotting utility: <a
href="https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&es_th=1&ie=UTF-8#q=y+%3D+x+%5E+2">$y = x ^ 2$</a>)
</p>
<p>
The library currently supports interactive line charts and scatterplots,
whenever the graph scale is modified the function is evaluated again with
the new bounds, result: infinite graphs!
</p>
<p class="center-block">
<iframe src="https://codesandbox.io/embed/l6k20jrlm" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
</p>
<p>
<b>Function Plot</b> unlike other plotters that use $n$-equally spaced points joined by line segments
uses <a href="https://github.com/mauriciopoppe/interval-arithmetic">interval-arithmetic</a> to
correctly determine sections of the screen that need to be plotted with a few samples
</p>
<p>
Most naive plotters will have problems plotting functions that oscillate too rapid,
for example $f(x) = sin(e^x)$ oscillates rapidly when $x > 5$, no matter how many times the
function is evaluated we will never be able to render this function correctly
</p>
<p class="center-block" style="width: 600px;">
<span id="description-sin-exp-x-naive"></span>
</p>
<p>
<b>Function Plot</b> will instead evaluate the function using interval math which means that when
a rectangle whose $x$ bounds are $[x_i, x_{i + 1}]$ appears on the screen it's ensured that it
contains all the possible $f(\xi)$ for $\xi \in [x_i, x_{i+1}]$, the result: pixel perfect
representation of curves
</p>
<p class="center-block" style="width: 600px;">
<span id="description-sin-exp-x"></span>
</p>
</div>
<section>
<div class="container">Installation</div>
</section>
<div class="container">
<pre><code>
npm i d3@v3 function-plot
</code></pre>
<pre><code>
window.d3 = require('d3')
const functionPlot = require('function-plot')
functionPlot({
// ..options
})
</code></pre>
<hr/>
<p>The old way:</p>
<pre><code id="old-way">
<script src="https://unpkg.com/d3@3/d3.min.js"></script>
<script src="https://unpkg.com/function-plot@1/dist/function-plot.js"></script>
</code></pre>
</div>
<section><div class="container">Examples</div></section>
<div class="content">
<div id="examples"></div>
</div>
<div class="text-center footer">
<div class="container">
<div class="about">
<div>
Created by <a href="https://twitter.com/mauricio_poppe">Mauricio Poppe</a> $\cdots$
Inspired by <a href="https://metricsgraphicsjs.org/">MetricGraphics</a>
</div>
</div>
</div>
</div>
<!-- includes -->
<script src="//cdnjs.cloudflare.com/ajax/libs/mathjs/1.5.2/math.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.2.0/ZeroClipboard.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/vendor/d3.js"></script>
<!-- app -->
<script src="js/function-plot.js"></script>
<script src="js/site.js"></script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='https://www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showProcessingMessages: false,
messageStyle: 'none',
tex2jax: {
inlineMath: [['$','$']],
displayMath: [['$$','$$']],
processEnvironments: false
},
TeX: {
equationNumbers: {
autoNumber: "AMS"
}
},
'HTML-CSS': {
imageFont: null
}
});
</script>
</body>
</html>