duckduckgo/zeroclickinfo-spice — pull request #560 by bradcater (2014-04-21 16:57:20+00:00)
Title: Ddg traffic stats

This is a status report and a list of questions seemingly unique to this particular plugin as much as it is a pull request with the intention of merging back into master.

**What does your instant answer do?**
This IA shows the DDG traffic graph currently found at [https://duckduckgo.com/traffic.html](https://duckduckgo.com/traffic.html).

**What problem does your instant answer solve (Why is it better than organic links)?**
When looking for DDG traffic stats, a graph is more descriptive than text contained in a link.

**What is the data source for your instant answer? (Provide a link if possible)**
DDG's traffic data is found at [https://duckduckgo.com/traffic_data/direct.csv](https://duckduckgo.com/traffic_data/direct.csv).

**Why did you choose this data source?**
This is the only available data source for this information.

**Are there any other alternative (better) data sources?**
Not to my knowledge

**What are some example queries that trigger this instant answer?**
ddg search traffic
duckduckgo traffic

**Which communities will this instant answer be especially useful for? (gamers, book lovers, etc)**
This is primarily of interest to the DuckDuckHack community.

**Is this instant answer connected to a DuckDuckHack [instant answer idea](https://duck.co/ideas)?**
No

**Which existing instant answers will this one supersede/overlap with?**
None

**Are you having any problems? Do you need our help with anything?**
Testing this IA locally requires the pull request for [p5-app-duckpan](https://github.com/duckduckgo/p5-app-duckpan) discussed [here](https://github.com/duckduckgo/p5-app-duckpan/pull/50#issuecomment-40939891).

This IA requires a `jsonp` request from the client to [http://whateverorigin.org](http://whateverorigin.org) to get around the browser's Same-Origin policy, though in production, this proxy request should be omitted since DDG hosts both the search page and the endpoint. It's not possible to use a typical Spice call from the server to the CSV endpoint because passing CSV data to the javascript handler raises an Unexpected Token error. Having an API endpoint that returns JSON rather than CSV data on [https://duckduckgo.com](https://duckduckgo.com) would allow a more typical use of a Spice IA with a server-side API call.

Since the Dygraph is sized via the `style` attribute of the `div`, responsive design is not possible. It is possible to detect a `resize` event using jQuery, and we could use this to trigger drawing a new graph of the appropriate size. I have not seen this done in any other IAs, so I'm not sure if it is the best method or not.

There's no API to retrieve the graph annotations, so these might fall out-of-date.

The "More at DuckDuckGo" link is not relevant since it links back to the search page.

**\*\*Note:** Please attach a screenshot for new instant answer pull requests, and for pull requests which modify the look/design of existing instant answers.
![annotations_closed](https://cloud.githubusercontent.com/assets/48050/2756359/a1827808-c975-11e3-8c5a-753c4f03a96e.png)
![annotations_opened](https://cloud.githubusercontent.com/assets/48050/2756360/a4756a0c-c975-11e3-846c-5eab5ad3ba36.png)

##Checklist
Please place an 'X' where appropriate.

```
[X] Added metadata and attribution information
[X] Wrote test file and added to t/ directory
[] Verified that instant answer adheres to design guidelines(https://github.com/duckduckgo/duckduckgo-documentation/blob/master/duckduckhack/styleguides/design_styleguide.md)
[] Tested cross-browser compatability

Please let us know which browsers/devices you've tested on:
- Windows 8
[] Google Chrome
[] Firefox
[] Opera
[] IE 10

- Windows 7
[] Google Chrome
[] Firefox
[] Opera
[] IE 8
[] IE 9
[] IE 10

- Windows XP
[] IE 7
[] IE 8

- Mac OSX
[] Google Chrome
[] Firefox
[] Opera
[] Safari

- iOS (iPhone)
[] Safari Mobile
[] Google Chrome
[] Opera

- iOS (iPad)
[] Safari Mobile
[] Google Chrome
[] Opera

- Android
[] Firefox
[] Native Browser
[] Google Chrome
[] Opera