diff --git a/src/components/RangeChart.vue b/src/components/RangeChart.vue new file mode 100644 index 0000000..25fc305 --- /dev/null +++ b/src/components/RangeChart.vue @@ -0,0 +1,110 @@ + + + diff --git a/src/pages/Editor.vue b/src/pages/Editor.vue index 2bd48dc..849a485 100644 --- a/src/pages/Editor.vue +++ b/src/pages/Editor.vue @@ -1,21 +1,21 @@ + + diff --git a/src/support/page.ts b/src/support/page.ts index cb2336e..3b55eed 100644 --- a/src/support/page.ts +++ b/src/support/page.ts @@ -128,6 +128,25 @@ export class MathPage { .filter(x => x.isFunctionDeclaration()) } + /** Look up a function statement by name, if it exists. */ + getFunctionByName(name: string): MathStatement|undefined { + for ( const fn of this.functions() ) { + const node = fn.parse() as math.FunctionAssignmentNode + if ( node.name === name ) { + return fn + } + } + } + + /** Look up a function statement by name, if it exists. */ + getFunctionByNameOrFail(name: string): MathStatement { + const fn = this.getFunctionByName(name) + if ( !fn ) { + throw new Error('Unable to find function with name: ' + name) + } + return fn + } + /** Evaluate the current state of the page and get the result. */ evaluate(): EvaluationResult { const evaluations: Record = {} diff --git a/src/support/types.ts b/src/support/types.ts index 533e3aa..004c1ce 100644 --- a/src/support/types.ts +++ b/src/support/types.ts @@ -111,3 +111,16 @@ export class ImageBox { } +export class ChartBox { + // eslint-disable-next-line max-params + constructor( + public fnName: string, + public minX: number, + public maxX: number, + public stepX: number = 1, + public x: number = 0, + public y: number = 0, + ) {} +} + +