Merge branch 'master' of git://github.com/danvk/dygraphs
[dygraphs.git] / docs / index.html
index 928b121..fe36356 100644 (file)
         <li><a href="#policy">Data Policy</a></li>
       </ul>
 
+      <h2>Features</h2>
+      <ul>
+        <li><a href="data.html">Data Formats</a></li>
+        <li><a href="annotations.html">Annotations</a></li>
+      </ul>
+
       <h2>Project</h2>
       <ul>
         <li><a href="http://github.com/danvk/dygraphs">Source</a></li>
 
       <h2>Gallery</h2>
       <ul>
+        <li><a href="tests/">(browse demos)</a></li>
         <li><a href="tests/demo.html">Basic Demo</a></li>
         <li><a href="tests/gviz.html">GViz Demo</a></li>
         <li><a href="tests/plotter.html">Equation Plotter</a></li>
         <li><a href="tests/perf.html">Performance Test</a></li>
+        <li><a href="tests/annotation.html">Annotations</a></li>
+        <li><a href="tests/annotation-gviz.html">Annotations (GViz)</a></li>
         <li><a href="tests/fillGraph.html">Filled Chart</a></li>
         <li><a href="tests/perf.html">Fractions</a></li>
         <li><a href="tests/visibility.html">Visibility</a></li>
       <ul>
         <li>Plots time series without using an external server or Flash</li>
         <li>Works in Internet Explorer (using excanvas)</li>
-        <li>Lightweight (45kb) and responsive</li>
+        <li>Lightweight (57kb) and responsive</li>
         <li>Displays values on mouseover (this makes it easily discoverable)</li>
         <li>Supports error bands around data series</li>
-        <li>Interactive zoom and pan</li>
+        <li>Interactive zoom</li>
+        <li>Displays Annotations on the chart</li>
         <li>Adjustable averaging period</li>
         <li>Can intelligently chart fractions</li>
         <li>Customizable click-through actions</li>
@@ -369,7 +379,15 @@ new Dygraph(el, data, {
 
     <h2 id="gviz">GViz Data</h2>
 
-    <p>The <a href="http://code.google.com/apis/visualization/documentation/index.html">Google Visualization API</a> provides a standard interface for describing data. Once you've specified your data using this API, you can plug in any GViz-compatible visualization. dygraphs is such a visualization.</p>
+    <p>The <a
+      href="http://code.google.com/apis/visualization/documentation/index.html">Google
+      Visualization API</a> provides a standard interface for describing data.
+    Once you've specified your data using this API, you can plug in any
+    GViz-compatible visualization. dygraphs is such a visualization. In
+    particular, it can be used as a drop-in replacement for the
+    AnnotatedTimeline visualization used on Google Finance and other sites. To
+    see how this works, check out the <a href="tests/annotation-gviz.html">gviz
+      annotation demo.</a></p>
 
     <p>For a simple demonstration of how to use dygraphs a GViz visualization, see <a href="http://danvk.org/dygraphs/tests/gviz.html">http://danvk.org/dygraphs/tests/gviz.html</a>. dygraphs can also be used as a GViz gadget. This allows it to be embedded inside of a Google Spreadsheet. For a demonstration of this, see <a   href="http://spreadsheets.google.com/ccc?key=0Anx1yCqeL8YUdDR1c3pPREhraGhkWmdhaURjOXRncXc&amp;hl=en">this spreadsheet</a>. The URL for the gadget is <code><a href="http://danvk.org/dygraphs/gadget.xml">http://danvk.org/dygraphs/gadget.xml</a></code>.</p>
 
@@ -438,9 +456,38 @@ new Dygraph(el, data, {
     <label for="0"> Nominal</label>
     <input type=checkbox id=1 onClick="stockchange(this)" checked>
     <label for="1"> Real</label>
+    <input type=checkbox id=ann onClick="annotationschange(this)" checked>
+    <label for="ann"> Annotations</label>
     </p>
 
     <script type="text/javascript">
+      var stock_annotations = [
+        {
+          series: "Real",
+          x: "1929-08-15",
+          shortText: "A",
+          text: "1929 Stock Market Peak"
+        },
+        {
+          series: "Nominal",
+          x: "1987-08-15",
+          shortText: "B",
+          text: "1987 Crash"
+        },
+        {
+          series: "Nominal",
+          x: "1999-12-15",
+          shortText: "C",
+          text: "1999 (.com) Peak"
+        },
+        {
+          series: "Nominal",
+          x: "2007-10-15",
+          shortText: "D",
+          text: "All-Time Market Peak"
+        }
+      ];
+
     // From http://www.econstats.com/eqty/eq_d_mi_3.csv
       stockchart = new Dygraph(
         document.getElementById('dow_chart'),
@@ -448,13 +495,25 @@ new Dygraph(el, data, {
         {
           showRoller: true,
           customBars: true,
-          labelsKMB: true
+          labelsKMB: true,
+          drawCallback: function(g, is_initial) {
+            if (!is_initial) return;
+            g.setAnnotations( stock_annotations );
+          }
         }
       );
 
       function stockchange(el) {
         stockchart.setVisibility(el.id, el.checked);
       }
+
+      function annotationschange(el) {
+        if (el.checked) {
+          stockchart.setAnnotations(stock_annotations);
+        } else {
+          stockchart.setAnnotations([]);
+        }
+      }
     </script>
 <!--
 
@@ -715,6 +774,16 @@ perl -ne 'BEGIN{print "Month,Nominal,Real\n"} chomp; ($m,$cpi,$low,$close,$high)
           <td>Function to call to format values along the x axis.
             <div class="tests">Tests: <a href="tests/x-axis-formatter.html">xAxisLabelFormatter</a></div>
           </td>
+        </tr>
+        <tr>
+          <td><strong>yAxisLabelFormatter</strong></td>
+          <td><code>function(x)</code></td>
+          <td><code>yValueFormatter</code></td>
+          <td>
+            Function used to format values along the Y axis. By default it uses the same as the <code>yValueFormatter</code> unless specified.
+            <div class="tests">Tests: <a href="tests/y-axis-formatter.html">yAxisLabelFormatter</a></div>
+          </td>
+        </tr>
         <tr>
           <td><strong>rightGap</strong></td>
           <td><code>integer</code></td>
@@ -822,6 +891,46 @@ perl -ne 'BEGIN{print "Month,Nominal,Real\n"} chomp; ($m,$cpi,$low,$close,$high)
           <td><code>320</code></td>
         </tr>
 
+        <tr>
+          <td><strong>stepPlot</strong></td>
+          <td><code>boolean</code></td>
+          <td><code>false</code></td>
+          <td>
+            When set, display the graph as a step plot instead of a line plot.
+            <div class="tests">Tests: <a href="tests/steps.html">steps</a></div>
+          </td>
+        </tr>
+
+        <tr>
+          <td><strong>xValueFormatter</strong></td>
+          <td><code>function(x)</code></td>
+          <td></td>
+          <td>
+            Function to provide a custom display format the X value for mouseover.
+          </td>
+        </tr>
+
+        <tr>
+          <td><strong>yValueFormatter</strong></td>
+          <td><code>function(x)</code></td>
+          <td>(Round to 2 decimal places)</td>
+          <td>
+            Function to provide a custom display format for the Y value for mouseover.
+            <div class="tests">Tests: <a href="tests/y-axis-formatter.html">yAxisLabelFormatter</a></div>
+          </td>
+        </tr>
+
+        <tr>
+          <td><strong>avoidMinZero</strong></td>
+          <td><code>boolean</code></td>
+          <td><code>false</code></td>
+          <td>
+            When set, the heuristic that fixes the Y axis at zero for a data set with the minimum Y value of zero is disabled.
+            This is particularly useful for data sets that contain many zero values, especially for step plots which may otherwise have lines not visible running along the bottom axis.
+            <div class="tests">Tests: <a href="tests/avoidMinZero.html">avoidMinZero</a></div>
+          </td>
+        </tr>
+
       </tbody>
     </table>