iamsjy17 / Plotta.js

Javascript Functional Graph Library
MIT License
23 stars 5 forks source link

Allow semantics functions #11

Open ashemetov opened 4 years ago

ashemetov commented 4 years ago

Ticket #5 suggested to implement support for semantics functions. This is definitely a good suggestion, but instead of embedding parser into plotta I would suggest to provide a sample how to integrate with math.js. Here is a sample:

    const parser = math.parser();

    function fn(x) {
        parser.set('x', x);
        return parser.evaluate(fn_str);
    }

    custom_fn.plotter.DeleteLine('pc_fn');
    custom_fn.plotter.AddLine({
        id: 'pc_fn',

... func: fn, ... });

iamsjy17 commented 4 years ago

Very good opinion. Thank you for your suggestion.

I actually have planned to include a parser, but as you say, I'll consider adding examples that utilize other libraries.