From: Dan Vanderkam Date: Tue, 8 Dec 2009 20:34:52 +0000 (-0800) Subject: merge X-Git-Tag: v1.0.0~804^2~10 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=83607a740bacf88b52823a22d3a5127f5f2970fc;p=dygraphs.git merge --- 83607a740bacf88b52823a22d3a5127f5f2970fc diff --cc docs/index.html index b5dc38a,6e9fc3f..394577f --- a/docs/index.html +++ b/docs/index.html @@@ -56,7 -56,7 +56,8 @@@ +

Internet Explorer Compatibility

+ +

The dygraphs library relies heavily on HTML's <canvas> tag, which +Microsoft Internet Explorer does not support. Fortunately, some clever engineers +created the excanvas +library, which imlements the <canvas> tag in IE using VML.

+ +

You can add IE support to any page using dygraphs by including the following +in your page:

+ +
 +<head>
 +<!--[if IE]><script src="excanvas.js"></script><![endif]-->
 +</head>
 +
+ +

This works quite well in practice. Charts are responsive, even under VML +emulation.

+ +

One common gotcha to look out for: make sure you don't have any trailing +commas in parameter lists, e.g.

+ +
new Dygraph(el, data, {
 +  showRoller:true,  // <-- note trailing comma
 +})
+ +

Most browsers will ignore the trailing comma, but it will break under IE.

+ +

Charting Fractions

+

Situations often arise where you want to plot fractions, e.g. the fraction of respondents in a poll who said they'd vote for candidate X or the number of hits divided by at bats (baseball's batting average). Fractions require special treatment for two main reasons:

+ +
+ +

Fortunately, dygraphs handles both of these for you! Here's a chart and the command that generated it:

+ +
Batting Average for Ichiro Suzuki vs. Mariners (2004)
+
+ + +

Command:

+
+ new Dygraph(
+   document.getElementById("baseballdiv"), "suzuki-mariners.txt",
+   {
+     fractions: true, errorBars: true,
+     showRoller: true, rollPeriod: 15
+   });
+ 
+ +

The fractions option indicates that the values in each column should be parsed as fractions (e.g. "1/2" instead of "0.5"). The errorBars option indicates that we'd like to see a confidence interval around each data point. By default, when fractions is set, you get a Wilson confidence interval. If you look carefully at the chart, you can see that the error bars are asymmetric.

+ +

A couple things to notice about this chart:

+ +

One last demo

This chart shows monthly closes of the Dow Jones Industrial Average, both in nominal and real (i.e. adjusted for inflation) dollars. The shaded areas show its monthly high and low. CPI values with a base from 1982-84 are used to adjust for inflation.