From 0a0325617534fab66b144da57b705154e696d435 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Mon, 18 Dec 2023 00:23:28 -0500 Subject: [PATCH] docs: use webWorkers in public docs. --- site/index.html | 25 ++++++++++++++----------- site/js/site.js | 20 +++++++++++--------- site/partials/examples.html | 6 +++--- site/playground.html | 8 +++----- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/site/index.html b/site/index.html index 8172647f..85210e4e 100644 --- a/site/index.html +++ b/site/index.html @@ -96,6 +96,19 @@

+
+
Playground
+
+ +

+ +

+
Installation & API
@@ -109,7 +122,7 @@


       import functionPlot from 'function-plot'
       functionPlot({
-        // ..options
+        // ..options below
       })
     
@@ -124,18 +137,8 @@

Check out the docs generated with TypeDocs API Docs

- -

- -

-
Examples
diff --git a/site/js/site.js b/site/js/site.js index e942a7b5..a14a69fd 100644 --- a/site/js/site.js +++ b/site/js/site.js @@ -1,8 +1,8 @@ -'use strict' -$(document).on('markupLoaded', function () { - var functionPlot = window.functionPlot - var a, b, c - var f, fp +document.addEventListener('markupLoaded', function () { + const functionPlot = window.functionPlot + let a, b, c + + functionPlot.withWebWorkers(8) functionPlot({ target: '#description-sample', @@ -47,7 +47,9 @@ $(document).on('markupLoaded', function () { }, data: [ { - fn: 'sin(exp(x))' + fn: 'sin(exp(x))', + nSamples: 5000, + sampler: 'asyncInterval' } ] }) @@ -253,7 +255,7 @@ $(document).on('markupLoaded', function () { * type of axis to `log` inside the `xAxis` option, note how this * change affects the way the functions are sampled */ - var instance = functionPlot({ + functionPlot({ target: '#logarithmic', xAxis: { type: 'log', @@ -573,7 +575,7 @@ $(document).on('markupLoaded', function () { * * */ - var options = { + const options = { target: '#quadratic-update', data: [ { @@ -581,7 +583,7 @@ $(document).on('markupLoaded', function () { } ] } - $('#update').click(function () { + document.querySelector('#update').addEventListener('click', function () { if (!options.title) { // add a title, a tip and change the function to y = x * x options.title = 'hello world' diff --git a/site/partials/examples.html b/site/partials/examples.html index 13310bf7..314d7451 100644 --- a/site/partials/examples.html +++ b/site/partials/examples.html @@ -149,7 +149,7 @@ })

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 -change affects the way the functions are sampled

var instance = functionPlot({
+change affects the way the functions are sampled

functionPlot({
   target: '#logarithmic',
   xAxis: {
     type: 'log',
@@ -390,7 +390,7 @@
 b.addLink(a, c)
 c.addLink(a, b)

Update

To update a graphic one needs to call functionPlot on the same target -element with any object that is configured properly

var options = {
+element with any object that is configured properly

const options = {
   target: '#quadratic-update',
   data: [
     {
@@ -398,7 +398,7 @@
     }
   ]
 }
-$('#update').click(function () {
+document.querySelector('#update').addEventListener('click', function () {
   if (!options.title) {
     // add a title, a tip and change the function to y = x * x
     options.title = 'hello world'
diff --git a/site/playground.html b/site/playground.html
index 67cdef02..a7d996cd 100644
--- a/site/playground.html
+++ b/site/playground.html
@@ -20,12 +20,10 @@
 functionPlot.withWebWorkers(8)
 functionPlot({
   target: '#playground',
-  width: window.innerWidth,
-  height: window.innerHeight,
+  // width: window.innerWidth,
+  // height: window.innerHeight,
   data: [
-    { fn: 'x^2', nSamples: 5000, sampler: 'asyncInterval' },
-    { fn: 'sin(x)', nSamples: 5000, sampler: 'asyncInterval' },
-    { fn: '1/x', nSamples: 5000, sampler: 'asyncInterval' },
+    { fn: 'sin(exp(x))', nSamples: 5000, sampler: 'asyncInterval' },
   ]
 })