Conversation
See comments in pull request for details; specifically some external JS libraries need to load before IA can be run.
@devkmem thanks a lot for contributing, we really appreciate it! I really wish you would have reached out to us though to have this idea approved before you started working on it. Did you happen to notice that part of the documentation? If not its OK, it's our fault and we need to make it more clear! The reason why is because an IA like this requires some planning and discussion on our end. Especially when you start using custom templates and 3rd party JS libs. I'll need to show this to the team and discuss it further before we can move ahead with this. Can you explain the purpose of the 3 different libs and also give me their minified sizes? Thanks again! |
Thanks; there is actually some coordination going on; loop internally and PM me for details.
function-plot.min.js (uglifyjs-ed function-plot "bundle.js"): 162049 bytes Re purpose, they are the guts of http://maurizzzio.github.io/function-plot/ Please note re the 'problems' section above, this is not a production request. It is an MVP (Minimum Viable Product) built for early evaluation. Best. |
"use strict"; | ||
|
||
/* | ||
$.getScript("http://localhost:5000/share/spice/graphical_calculator/js/d3/3.5.6/d3.js") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use DDG.get_asset_path()
(https://duck.co/duckduckhack/spice_js_api#getassetpathspicename-asset) to load these libs.
That way you won't need to mess with DuckPAN or anything else :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect; thanks.
👍 |
* Staged async loading of scripts after initial pass on math parsing; * Sets "current" scripts in top share/spice/graphical_calculator dir, with versioned copies in /js subdir. Use hard links to avoid redundant copies; * Issues remain with some operator evaluations (e.g, pow (^)); author has been notified; * Local testing requires a patch to DuckPAN/Web.pm to strip appended query string from script file names. We are evaluating this situation.
Added ajaxSetup({ cache: true }) to prevent jQuery from appending the query string "?_={timestamp}" upon loading URLs
New parser and function-plot build addresses various test cases that were failing. See t/graphical_calculator.t.
* Fixed title ellipsis (trimming title display on long equations); * Uncovered new interval arithmetic error on plot line display; * Added test case
Closing this. Code is in https://github.com/duckduckgo/zeroclickinfo-spice/tree/ideas/graphical-calc if anyone wants to finish it! |
Spice Pull Request Template
Using this template will help us better understand your Instant Answer and assist you when necessary. Simply copy and paste the markdown below into the description of your GitHub pull request and complete as appropriate.
What does your Instant Answer do?
Graphical calculator for displaying equations entered as search queries.
What problem does your Instant Answer solve (Why is it better than organic links)?
Displays the equation graph on the DDG search results page without the need to select and load a separate page.
What is the data source for your Instant Answer? (Provide a link if possible)
http://maurizzzio.github.io/function-plot/
https://github.com/maurizzzio/function-plot
Why did you choose this data source?
Used as an example from mathjs.org
Are there any other alternative (better) data sources?
Hard to answer if there is anything "better;" this is the best I have found
What are some example queries that trigger this Instant Answer?
Please see t/GraphicalCalculator.t for 23 examples, plus counter-examples.
Note: see problems below.
Which communities will this Instant Answer be especially useful for? (gamers, book lovers, etc)
General math oriented.
Is this Instant Answer connected to a DuckDuckHack Instant Answer idea?
https://duck.co/ideas/idea/4683/graphing-feature
https://duck.co/ideas/idea/114/display-graph-for-function
https://duck.co/ideas/idea/5865/plot-a-graph
Which existing Instant Answers will this one supersede/overlap with?
None; it should be compatible and complementary with a non-graphical calculator
Are you having any problems? Do you need our help with anything?
For local development I hacked perl5/lib/perl5/App/DuckPAN/Web.pm. After line 436 insert:
What are the terms of use for the API? Will DuckDuckGo need specific authorization (e.g. an API key)? Are there any costs associated with API usage?
No APIs are used. License on math.js is Apache 2; license on d3 is BSD; license on function-plot is MIT.
Where did you hear about DuckDuckHack? (For first time contributors)
Web.
What does the Instant Answer look like? (Provide a screenshot for new or updated Instant Answers)
Checklist
Please place an 'X' where appropriate.