tweaks to reduce horizontal width of home page
[dygraphs.git] / docs / index.html
index 772ab2c..9853757 100644 (file)
@@ -1,12 +1,25 @@
 <!DOCTYPE html>
 <html>
   <head>
+    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
     <title>dygraphs JavaScript Visualization Library</title>
     <!--[if IE]>
       <script type="text/javascript" src="excanvas.js"></script>
     <![endif]-->
     <script type="text/javascript" src="dygraph-combined.js"></script>
     <link rel="stylesheet" href="style.css">
+
+    <!-- Google Analytics -->
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-769809-2']);
+      _gaq.push(['_trackPageview']);
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
   </head>
   <body>
     <div id="nav">
@@ -86,8 +99,6 @@
 
       <p style="font-size:0.8em">(Mouse over to highlight individual values. Click and drag to zoom. Double-click to zoom back out. Change the number and hit enter to adjust the averaging period.)</p>
 
-      <div id="title" style="width:800px; margin: 1em;text-align:center; font-weight: bold; font-size: 125%;">Temperatures in New York vs. San Francisco</div>
-
       <div id="demodiv" style="width:800px; height:320px;"></div>
       <script type="text/javascript">
         g = new Dygraph(
             rollPeriod: 14,
             showRoller: true,
             customBars: true,
-            yAxisLabelWidth: 30
+            title: 'Daily Temperatures in New York vs. San Francisco',
+            ylabel: 'Temperature (F)',
+            legend: 'always',
+            labelsDivStyles: { 'textAlign': 'right' }
           }
         );
       </script>
         <li>Plots time series without using an external server or Flash</li>
         <li>Works in Internet Explorer (using excanvas)</li>
         <li>Lightweight (69kb) and responsive</li>
-        <li>Displays values on mouseover (this makes it easily discoverable)</li>
+        <li>Displays values on mouseover, making interaction easily discoverable</li>
         <li>Supports error bands around data series</li>
         <li>Interactive zoom</li>
         <li>Displays Annotations on the chart</li>
 &lt;/head&gt;
 &lt;body&gt;
 &lt;div id=&quot;graphdiv4&quot;
-  style=&quot;width:600px; height:300px;&quot;&gt;&lt;/div&gt;
+  style=&quot;width:480px; height:320px;&quot;&gt;&lt;/div&gt;
 &lt;script type=&quot;text/javascript&quot;&gt;
   g4 = new Dygraph(
     document.getElementById(&quot;graphdiv4&quot;),
         </div>
         <div class="codeoutput" style="float:left;">
           <h3 style="text-align:center">OUTPUT</h3>
-          <div id="graphdiv4" style="width:600px; height:300px;"></div>
+          <div id="graphdiv4" style="width:480px; height:320px;"></div>
           <script type="text/javascript">
             g4 = new Dygraph(
               document.getElementById("graphdiv4"),
 
       <h2 id="ie">Internet Explorer Compatibility</h2>
 
-      <p>The dygraphs library relies heavily on HTML's <code>&lt;canvas&gt;</code> tag, which Microsoft Internet Explorer does not support. Fortunately, some clever engineers created the <a href="http://code.google.com/p/explorercanvas/">excanvas</a> library, which implements the <code>&lt;canvas&gt;</code> tag in IE using VML.</p>
+      <p>The dygraphs library relies heavily on the HTML5 <code>&lt;canvas&gt;</code> tag, which Microsoft Internet Explorer did not traditionally support. To use Microsoft's native canvas implementation in IE9, you need to set an HTML5 doctype on your page:</p>
+
+<pre>
+&lt;!DOCTYPE html&gt;
+</pre>
+
+      <p>When IE9 is in HTML5 mode, dygraphs works just like in other modern browsers.</p>
 
-      <p>You can add IE support to any page using dygraphs by including the following in your page:</p>
+      <p>If you want to support previous versions of Internet Explorer (IE6&ndash;IE8), you'll need to include the <a href="http://code.google.com/p/explorercanvas/">excanvas</a> library, which emulates the <code>&lt;canvas&gt;</code> tag using VML. You can add excanvas by including the following snippet:</p>
 
 <pre>
-&lt;head&gt;
-  &lt;!--[if IE]&gt;&lt;script src="excanvas.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
-&lt;/head&gt;
+&lt;!DOCTYPE html&gt; 
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9"&gt; 
+    &lt;!--[if IE]&gt;&lt;script src="path/to/excanvas.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
+  &lt;/head&gt;
 </pre>
 
-    <p>This works quite well in practice. Charts are responsive, even under VML emulation.</p>
+<p>(This is surprisingly tricky because the HTML5 doctype breaks excanvas in IE8. See <a href="https://groups.google.com/group/dygraphs-users/browse_thread/thread/c60709e04bc7fe5f#">this discussion</a> for details.)</p>
+
+    <p>While VML emulation sounds like it would be slow, it works well in practice for most charts.</p>
 
     <p>One common gotcha to look out for: make sure you don't have any trailing commas in parameter lists, e.g.</p>
 
@@ -452,7 +477,7 @@ new Dygraph(el, data, {
 
     <p>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.</p>
 
-    <div id="dow_chart" style="width:900px; height:350px;"></div>
+    <div id="dow_chart" style="width:750px; height:350px;"></div>
     <p><b>Display: </b>
     <input type=checkbox id=0 onClick="stockchange(this)" checked>
     <label for="0"> Nominal</label>
@@ -564,14 +589,15 @@ perl -ne 'BEGIN{print "Month,Nominal,Real\n"} chomp; ($m,$cpi,$low,$close,$high)
     <p>Call org.danvk.Dygraphs.install() when your application starts to install the JavaScript code into the browser.  You can use <a href="http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html">JSNI</a> to call Dygraphs from your GWT code, as in the example below.  The example uses the <a href="http://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingStarted">Visualization API for GWT</a> and the <a href="#gviz">Dygraphs GViz API.</a></p>
 
 <pre>
-  public static native JavaScriptObject drawDygraph(Element element, DataTable dataTable, double minY, double maxY) /*-{
-    var chart = new $wnd.Dygraph.GVizChart(element);
-    chart.draw(dataTable,
-      {
-        valueRange: [minY, maxY]
-      });
-    return chart;
-  }-*/;
+public static native JavaScriptObject drawDygraph(
+    Element element, DataTable dataTable, double minY, double maxY) /*-{
+  var chart = new $wnd.Dygraph.GVizChart(element);
+  chart.draw(dataTable,
+    {
+      valueRange: [minY, maxY]
+    });
+  return chart;
+}-*/;
 </pre>
 
     <h2 id="policy">Data Policy</h2>
@@ -580,9 +606,5 @@ perl -ne 'BEGIN{print "Month,Nominal,Real\n"} chomp; ($m,$cpi,$low,$close,$high)
     <p style="font-size:0.8em">Created May 9, 2008 by <a href=mailto:danvdk@gmail.com>Dan Vanderkam</a></p>
   </div>
 
-
-  <!-- Google Analytics -->
-  <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
-  <script type="text/javascript">_uacct = "UA-769809-1";urchinTracker();</script>
 </body>
 </html>