diff --git a/site/js/site.js b/site/js/site.js index 1837bd4..450a219 100644 --- a/site/js/site.js +++ b/site/js/site.js @@ -6,7 +6,7 @@ function onSiteDependenciesLoaded() { functionPlot({ target: '#description-sample', - yAxis: { domain: [-1, 9] }, + y: { domain: [-1, 9] }, tip: { renderer: function () {} }, @@ -24,8 +24,8 @@ function onSiteDependenciesLoaded() { functionPlot({ target: '#description-sin-exp-x-naive', - yAxis: { domain: [-4, 4] }, - xAxis: { domain: [-2, 6] }, + y: { domain: [-4, 4] }, + x: { domain: [-2, 6] }, tip: { renderer: function () {} }, @@ -40,8 +40,8 @@ function onSiteDependenciesLoaded() { functionPlot({ target: '#description-sin-exp-x', - yAxis: { domain: [-4, 4] }, - xAxis: { domain: [-2, 6] }, + y: { domain: [-4, 4] }, + x: { domain: [-2, 6] }, tip: { renderer: function () {} }, @@ -88,12 +88,12 @@ function onSiteDependenciesLoaded() { * - `title`: the title of the graph * - `width`: width of the graph * - `height`: height of the graph - * - `xAxis`: + * - `x`: * - `type`: the type of scale for this axis, possible values `linear|log` * (default value: `'linear'`) * - `label`: x axis label * - `domain`: x axis possible values (see examples below) - * - `yAxis`: same options as `xAxis` + * - `y`: same options as `x` * - `disableZoom`: true to disable translation/scaling on the graph */ functionPlot({ @@ -102,11 +102,11 @@ function onSiteDependenciesLoaded() { width: 580, height: 400, disableZoom: true, - xAxis: { + x: { label: 'x - axis', domain: [-6, 6] }, - yAxis: { + y: { label: 'y - axis' }, data: [ @@ -123,10 +123,10 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#grid', - xAxis: { + x: { label: 'real' }, - yAxis: { + y: { label: 'imaginary' }, grid: true, @@ -151,8 +151,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#domain', - yAxis: { domain: [-1, 1] }, - xAxis: { domain: [8, 24] }, + y: { domain: [-1, 1] }, + x: { domain: [8, 24] }, data: [ { fn: 'sin(x)' @@ -204,7 +204,7 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#annotations', - yAxis: { domain: [-1, 9] }, + y: { domain: [-1, 9] }, data: [ { fn: 'x^2' @@ -238,7 +238,7 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#closed', - xAxis: { domain: [-2, 12] }, + x: { domain: [-2, 12] }, data: [ { fn: '3 + sin(x)', @@ -252,16 +252,16 @@ function onSiteDependenciesLoaded() { * ### Logarithmic scales * * The type of each axis can be configured to be logarithmic by specifying the - * type of axis to `log` inside the `xAxis` option, note how this + * type of axis to `log` inside the `x` option, note how this * change affects the way the functions are sampled */ functionPlot({ target: '#logarithmic', - xAxis: { + x: { type: 'log', domain: [0.01, 1] }, - yAxis: { + y: { domain: [-100, 100] }, grid: true, @@ -391,8 +391,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#secant', - yAxis: { domain: [-1, 9] }, - xAxis: { domain: [-3, 3] }, + y: { domain: [-1, 9] }, + x: { domain: [-3, 3] }, data: [ { fn: 'x^2', @@ -448,7 +448,7 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#derivative', - yAxis: { domain: [-1, 9] }, + y: { domain: [-1, 9] }, data: [ { fn: 'x^2', @@ -469,7 +469,7 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#derivative-update', - yAxis: { domain: [-1, 9] }, + y: { domain: [-1, 9] }, data: [ { fn: 'x^2', @@ -520,13 +520,13 @@ function onSiteDependenciesLoaded() { a = functionPlot({ target: '#linked-a', height: 250, - xAxis: { domain: [-10, 10] }, + x: { domain: [-10, 10] }, data: [{ fn: 'x * x' }] }) b = functionPlot({ target: '#linked-b', height: 250, - xAxis: { domain: [-10, 10] }, + x: { domain: [-10, 10] }, data: [{ fn: '2 * x' }] }) a.addLink(b) @@ -546,19 +546,19 @@ function onSiteDependenciesLoaded() { a = functionPlot({ target: '#linked-a-multiple', height: 250, - xAxis: { domain: [-10, 10] }, + x: { domain: [-10, 10] }, data: [{ fn: 'x * x' }] }) b = functionPlot({ target: '#linked-b-multiple', height: 250, - xAxis: { domain: [-10, 10] }, + x: { domain: [-10, 10] }, data: [{ fn: '2 * x' }] }) c = functionPlot({ target: '#linked-c-multiple', height: 250, - xAxis: { domain: [-10, 10] }, + x: { domain: [-10, 10] }, data: [{ fn: '2' }] }) a.addLink(b, c) @@ -675,8 +675,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#circle-explicit', - yAxis: { domain: [-1.897959183, 1.897959183] }, - xAxis: { domain: [-3, 3] }, + y: { domain: [-1.897959183, 1.897959183] }, + x: { domain: [-3, 3] }, data: [{ fn: 'sqrt(1 - x * x)' }, { fn: '-sqrt(1 - x * x)' }] }) @@ -708,8 +708,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#parametric-circle', - yAxis: { domain: [-1.897959183, 1.897959183] }, - xAxis: { domain: [-3, 3] }, + y: { domain: [-1.897959183, 1.897959183] }, + x: { domain: [-3, 3] }, data: [ { x: 'cos(t)', @@ -734,8 +734,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#butterfly-curve', - yAxis: { domain: [-4.428571429, 4.428571429] }, - xAxis: { domain: [-7, 7] }, + y: { domain: [-4.428571429, 4.428571429] }, + x: { domain: [-7, 7] }, data: [ { x: 'sin(t) * (exp(cos(t)) - 2 cos(4t) - sin(t/12)^5)', @@ -774,8 +774,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#polar-circle', - yAxis: { domain: [-1.897959183, 1.897959183] }, - xAxis: { domain: [-3, 3] }, + y: { domain: [-1.897959183, 1.897959183] }, + x: { domain: [-3, 3] }, data: [ { r: 'r0 * cos(theta - gamma) + sqrt(a^2 - r0^2 * (sin(theta - gamma))^2)', @@ -801,8 +801,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#polar-complex', - yAxis: { domain: [-1.897959183, 1.897959183] }, - xAxis: { domain: [-3, 3] }, + y: { domain: [-1.897959183, 1.897959183] }, + x: { domain: [-3, 3] }, data: [ { r: '2 * sin(4 theta)', @@ -838,8 +838,8 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#circle-implicit', - yAxis: { domain: [-1.897959183, 1.897959183] }, - xAxis: { domain: [-3, 3] }, + y: { domain: [-1.897959183, 1.897959183] }, + x: { domain: [-3, 3] }, data: [ { fn: 'x * x + y * y - 1', @@ -863,7 +863,7 @@ function onSiteDependenciesLoaded() { functionPlot({ target: '#implicit-complex', yAxis: { domain: [-3.795918366, 3.795918366] }, - xAxis: { domain: [-6, 6] }, + x: { domain: [-6, 6] }, disableZoom: true, data: [ { @@ -928,7 +928,7 @@ function onSiteDependenciesLoaded() { */ functionPlot({ target: '#vector', - xAxis: { domain: [-3, 8] }, + x: { domain: [-3, 8] }, grid: true, data: [ { diff --git a/site/partials/examples.html b/site/partials/examples.html index 7bcb875..9c98f57 100644 --- a/site/partials/examples.html +++ b/site/partials/examples.html @@ -23,12 +23,12 @@
title
: the title of the graphwidth
: width of the graphheight
: height of the graphxAxis
:x
:type
: the type of scale for this axis, possible values linear|log
(default value: 'linear'
)label
: x axis labeldomain
: x axis possible values (see examples below)yAxis
: same options as xAxis
y
: same options as x
disableZoom
: true to disable translation/scaling on the graphfunctionPlot({
title: 'y = x * x',
@@ -36,11 +36,11 @@
width: 580,
height: 400,
disableZoom: true,
- xAxis: {
+ x: {
label: 'x - axis',
domain: [-6, 6]
},
- yAxis: {
+ y: {
label: 'y - axis'
},
data: [
@@ -51,10 +51,10 @@
})
functionPlot({
target: '#grid',
- xAxis: {
+ x: {
label: 'real'
},
- yAxis: {
+ y: {
label: 'imaginary'
},
grid: true,
@@ -72,8 +72,8 @@
NOTE: The origin is at the center of the graph by default so $yDiff$ is split in half and distributed
evenly to the $\pm y$ axis
functionPlot({
target: '#domain',
- yAxis: { domain: [-1, 1] },
- xAxis: { domain: [8, 24] },
+ y: { domain: [-1, 1] },
+ x: { domain: [8, 24] },
data: [
{
fn: 'sin(x)'
@@ -109,7 +109,7 @@
NOTE: either x
or y
need to be set on the object, setting both of them
will raise an exception
functionPlot({
target: '#annotations',
- yAxis: { domain: [-1, 9] },
+ y: { domain: [-1, 9] },
data: [
{
fn: 'x^2'
@@ -138,7 +138,7 @@
closed
: true to render a closed path, y0
will always be 0 and y1
will be $fn(x)$
functionPlot({
target: '#closed',
- xAxis: { domain: [-2, 12] },
+ x: { domain: [-2, 12] },
data: [
{
fn: '3 + sin(x)',
@@ -148,14 +148,14 @@
]
})
The type of each axis can be configured to be logarithmic by specifying the
-type of axis to log
inside the xAxis
option, note how this
+type of axis to log
inside the x
option, note how this
change affects the way the functions are sampled
functionPlot({
target: '#logarithmic',
- xAxis: {
+ x: {
type: 'log',
domain: [0.01, 1]
},
- yAxis: {
+ y: {
domain: [-100, 100]
},
grid: true,
@@ -252,8 +252,8 @@
position of the mouse
functionPlot({
target: '#secant',
- yAxis: { domain: [-1, 9] },
- xAxis: { domain: [-3, 3] },
+ y: { domain: [-1, 9] },
+ x: { domain: [-3, 3] },
data: [
{
fn: 'x^2',
@@ -297,7 +297,7 @@
position of the mouse
functionPlot({
target: '#derivative',
- yAxis: { domain: [-1, 9] },
+ y: { domain: [-1, 9] },
data: [
{
fn: 'x^2',
@@ -312,7 +312,7 @@
inside the canvas (let $x_0$ be the mouse's abscissa then the tangent line to the point
$(x_0, f(x_0))$ is computed whenever the position of the mouse changes)
functionPlot({
target: '#derivative-update',
- yAxis: { domain: [-1, 9] },
+ y: { domain: [-1, 9] },
data: [
{
fn: 'x^2',
@@ -351,13 +351,13 @@
performed on b
a = functionPlot({
target: '#linked-a',
height: 250,
- xAxis: { domain: [-10, 10] },
+ x: { domain: [-10, 10] },
data: [{ fn: 'x * x' }]
})
b = functionPlot({
target: '#linked-b',
height: 250,
- xAxis: { domain: [-10, 10] },
+ x: { domain: [-10, 10] },
data: [{ fn: '2 * x' }]
})
a.addLink(b)
a = functionPlot({
target: '#linked-a-multiple',
height: 250,
- xAxis: { domain: [-10, 10] },
+ x: { domain: [-10, 10] },
data: [{ fn: 'x * x' }]
})
b = functionPlot({
target: '#linked-b-multiple',
height: 250,
- xAxis: { domain: [-10, 10] },
+ x: { domain: [-10, 10] },
data: [{ fn: '2 * x' }]
})
c = functionPlot({
target: '#linked-c-multiple',
height: 250,
- xAxis: { domain: [-10, 10] },
+ x: { domain: [-10, 10] },
data: [{ fn: '2' }]
})
a.addLink(b, c)
@@ -467,8 +467,8 @@
y = \sqrt{1 - x^2} \quad and \quad y = -\sqrt{1 - x^2}
$$
functionPlot({
target: '#circle-explicit',
- yAxis: { domain: [-1.897959183, 1.897959183] },
- xAxis: { domain: [-3, 3] },
+ y: { domain: [-1.897959183, 1.897959183] },
+ x: { domain: [-3, 3] },
data: [{ fn: 'sqrt(1 - x * x)' }, { fn: '-sqrt(1 - x * x)' }]
})
The original equation of the circle $x^2 + y^2 = 1$ can be parametrized as
@@ -491,8 +491,8 @@ instead of rectangles generated by the interval-arithmetic sampler setgraphType: 'polyline'
which uses the normal single point evaluationfunctionPlot({
target: '#parametric-circle',
- yAxis: { domain: [-1.897959183, 1.897959183] },
- xAxis: { domain: [-3, 3] },
+ y: { domain: [-1.897959183, 1.897959183] },
+ x: { domain: [-3, 3] },
data: [
{
x: 'cos(t)',
@@ -509,8 +509,8 @@
y = cos(t)(e^{cos(t)} - 2cos(4t) - sin(\tfrac{t}{12})^5)
$$
functionPlot({
target: '#butterfly-curve',
- yAxis: { domain: [-4.428571429, 4.428571429] },
- xAxis: { domain: [-7, 7] },
+ y: { domain: [-4.428571429, 4.428571429] },
+ x: { domain: [-7, 7] },
data: [
{
x: 'sin(t) * (exp(cos(t)) - 2 cos(4t) - sin(t/12)^5)',
@@ -540,8 +540,8 @@
instead of rectangles generated by the interval-arithmetic sampler set
graphType: 'polyline'
which uses the normal single point evaluation
functionPlot({
target: '#polar-circle',
- yAxis: { domain: [-1.897959183, 1.897959183] },
- xAxis: { domain: [-3, 3] },
+ y: { domain: [-1.897959183, 1.897959183] },
+ x: { domain: [-3, 3] },
data: [
{
r: 'r0 * cos(theta - gamma) + sqrt(a^2 - r0^2 * (sin(theta - gamma))^2)',
@@ -560,8 +560,8 @@
r = 2 sin(4 \theta)
$$
functionPlot({
target: '#polar-complex',
- yAxis: { domain: [-1.897959183, 1.897959183] },
- xAxis: { domain: [-3, 3] },
+ y: { domain: [-1.897959183, 1.897959183] },
+ x: { domain: [-3, 3] },
data: [
{
r: '2 * sin(4 theta)',
@@ -587,8 +587,8 @@
NOTE: implicit functions can only be rendered with interval-arithmetic
functionPlot({
target: '#circle-implicit',
- yAxis: { domain: [-1.897959183, 1.897959183] },
- xAxis: { domain: [-3, 3] },
+ y: { domain: [-1.897959183, 1.897959183] },
+ x: { domain: [-3, 3] },
data: [
{
fn: 'x * x + y * y - 1',
@@ -604,7 +604,7 @@
of functions, however for a finite region of the plane a finite number of functions suffice
functionPlot({
target: '#implicit-complex',
yAxis: { domain: [-3.795918366, 3.795918366] },
- xAxis: { domain: [-6, 6] },
+ x: { domain: [-6, 6] },
disableZoom: true,
data: [
{
@@ -658,7 +658,7 @@
graphType: 'polyline'
to render a nice segment from offset
to offset + vector
functionPlot({
target: '#vector',
- xAxis: { domain: [-3, 8] },
+ x: { domain: [-3, 8] },
grid: true,
data: [
{
diff --git a/site/playground.html b/site/playground.html
index 60376a6..1d4cb17 100644
--- a/site/playground.html
+++ b/site/playground.html
@@ -12,10 +12,17 @@
color: black;
font-size: 14px;
}
+ #playground-wrapper {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
-
+
+
+
Grid
Set
grid: true
in the options sent to function plot