Skip to content

Commit 480cd50

Browse files
committed
Recreate docs and update readme info
Fixes #236
1 parent ca2bc42 commit 480cd50

File tree

11 files changed

+230
-160
lines changed

11 files changed

+230
-160
lines changed

.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"root": true,
3+
"extends": ["react-app", "standard"],
4+
"rules": {
5+
"space-before-function-paren": ["error", {
6+
"anonymous": "ignore",
7+
"named": "ignore",
8+
"asyncArrow": "ignore"
9+
}],
10+
"no-unused-vars": "off",
11+
"no-use-before-define": "off",
12+
"@typescript-eslint/no-unused-vars": "error"
13+
}
14+
}

.storybook/main.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
// prettier-ignore
12
module.exports = {
23
"stories": [
34
"../src/**/*.stories.mdx",
45
"../src/**/*.stories.@(js|jsx|ts|tsx)"
56
],
67
"addons": [
78
"@storybook/addon-links",
9+
"@storybook/addon-postcss",
810
"@storybook/addon-essentials"
9-
]
10-
}
11+
],
12+
features: {
13+
postcss: false,
14+
},
15+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ import functionPlot from 'function-plot'
4545
functionPlot(options)
4646
```
4747

48-
[`All the available options are described in the docs`](https://mauriciopoppe.github.io/function-plot/docs/interfaces/_src_types_.functionplotoptions.html)
48+
[`All the available options are described in the docs`](https://mauriciopoppe.github.io/function-plot/functions/functionPlot-1)
4949

5050
## License
5151

52-
2015-2022 MIT © Mauricio Poppe
52+
2015-2023 MIT © Mauricio Poppe
5353

5454

5555
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmauriciopoppe%2Ffunction-plot.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmauriciopoppe%2Ffunction-plot?ref=badge_large)

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
"build:types": "tsc",
2323
"build:site": "cp dist/function-plot.js site/js/function-plot.js",
2424
"start": "webpack-dev-server",
25-
"docs": "typedoc --out site/docs src/index.ts",
25+
"docs": "typedoc --excludeExternals --externalPattern \"**/node_modules/**\" --out site/docs src/index.ts",
2626
"test": "jest",
2727
"storybook": "start-storybook -p 6006",
28-
"build-storybook": "build-storybook",
28+
"build-storybook": "NODE_OPTIONS=--openssl-legacy-provider build-storybook",
2929
"chromatic": "npx chromatic"
3030
},
3131
"files": [
@@ -72,6 +72,7 @@
7272
"@storybook/addon-actions": "^6.5.12",
7373
"@storybook/addon-essentials": "^6.5.12",
7474
"@storybook/addon-links": "^6.5.12",
75+
"@storybook/addon-postcss": "^2.0.0",
7576
"@storybook/react": "^6.5.12",
7677
"@types/d3": "^7.4.0",
7778
"@types/events": "^3.0.0",
@@ -112,12 +113,6 @@
112113
"webpack-cli": "^4.10.0",
113114
"webpack-dev-server": "^4.11.0"
114115
},
115-
"eslintConfig": {
116-
"rules": {
117-
"no-unused-vars": "off",
118-
"@typescript-eslint/no-unused-vars": "error"
119-
}
120-
},
121116
"standardx": {
122117
"parser": "@typescript-eslint/parser",
123118
"plugins": [

src/evaluate.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const evalTypeFn = {
1717
* @param {Object} d An item from `data`
1818
* @returns {Array}
1919
*/
20-
function computeEndpoints (scale: any, d: any): [number, number] {
20+
function computeEndpoints(scale: any, d: any): [number, number] {
2121
const range = d.range || [-Infinity, Infinity]
2222
const start = Math.max(scale.domain()[0], range[0])
2323
const end = Math.min(scale.domain()[1], range[1])
@@ -30,15 +30,12 @@ function computeEndpoints (scale: any, d: any): [number, number] {
3030
*
3131
* @param {Object} chart Chart instance which is orchestrating this sampling operation
3232
* @param {Object} d a.k.a a single item from `data`
33-
* @returns {Array}
33+
* @returns [number, number]
3434
*/
35-
function evaluate (chart: Chart, d: FunctionPlotDatum) {
35+
function evaluate(chart: Chart, d: FunctionPlotDatum) {
3636
const range = computeEndpoints(chart.meta.xScale, d)
3737
const evalFn = evalTypeFn[d.sampler]
38-
const nSamples = d.nSamples || Math.min(
39-
globals.MAX_ITERATIONS,
40-
globals.DEFAULT_ITERATIONS || (chart.meta.width * 2)
41-
)
38+
const nSamples = d.nSamples || Math.min(globals.MAX_ITERATIONS, globals.DEFAULT_ITERATIONS || chart.meta.width * 2)
4239

4340
const data = evalFn(chart, d, range, nSamples)
4441
// NOTE: it's impossible to listen for the first eval event

src/external.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ declare module 'interval-arithmetic-eval' {
2121

2222
export const policies: any
2323
}
24-

src/helpers/eval.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ const samplers = {
1010
function getMathJS(): { compile: any } | null {
1111
if (typeof global === 'object' && 'math' in global) {
1212
// @ts-ignore
13-
return global['math'] as any
13+
return global.math as any
1414
}
1515
if (typeof window === 'object' && 'math' in window) {
1616
// @ts-ignore
17-
return window['math']
17+
return window.math
1818
}
1919
return null
2020
}
2121

22-
let mathJS = getMathJS()
22+
const mathJS = getMathJS()
2323
if (mathJS) {
2424
// override the built-in module with mathjs's compile
2525
samplers.builtIn = mathJS.compile
@@ -48,7 +48,7 @@ function generateEvaluator(samplerName: 'interval' | 'builtIn') {
4848
// eval: expression
4949
// }
5050
//
51-
// othewise throw an error
51+
// otherwise throw an error
5252
if (typeof expression === 'string') {
5353
const compiled = samplers[samplerName](expression)
5454
if (mathJS && samplerName === 'builtIn') {
@@ -88,13 +88,12 @@ function generateEvaluator(samplerName: 'interval' | 'builtIn') {
8888
* - Evaluates the resulting function with the merge of meta.scope and
8989
* `variables`
9090
*
91-
* @param {Object} meta
92-
* @param {String} property
93-
* @param {Object} variables
94-
* @returns {Number|Array} The builtIn evaluator returns a number, the
95-
* interval evaluator an array
91+
* @param meta
92+
* @param property
93+
* @param variables
94+
* @returns The builtIn evaluator returns a number, the interval evaluator an array
9695
*/
97-
function evaluate(meta: any, property: string, variables: any) {
96+
function evaluate(meta: any, property: string, variables: object) {
9897
// e.g.
9998
//
10099
// meta: {

src/helpers/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// const d3 = window.d3
2-
import {select as d3Select, Selection} from 'd3-selection'
1+
import { select as d3Select, Selection } from 'd3-selection'
32
import derivative from './derivative'
43
import secant from './secant'
54

65
import { Chart } from '../index'
76

87
export default function helpers(chart: Chart) {
9-
function helper (selection: Selection<any, any, any, any>) {
8+
function helper(selection: Selection<any, any, any, any>) {
109
selection.each(function () {
1110
const el = d3Select(this)
1211
el.call(derivative(chart))

0 commit comments

Comments
 (0)