Google Charts

Visualization: Candlestick Chart (Image)

Important: The Image Charts portion of Google Chart Tools has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy.

Overview

A candlestick chart that is rendered as an image using the Google Charts API.

A candlestick chart is used to show an opening and closing value overlaid on top of a total variance. Candlestick charts are often used to show stock value behavior. In this chart, items where the opening value is less than the closing value are drawn in green, and items where the opening value is more than the closing value are drawn in red. See the candlestick documentation in the Google Charts API for more information.

By: Google

Example

Code it yourself on the Visualization Playground

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
     <title>
      Google Visualization API Sample
     </title>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
     <script type="text/javascript">
       google.load('visualization', '1.0', {packages: ['imagechart']});
     </script>
    <script type="text/javascript">
      function drawVisualization() {
        var options = {};
        dataTable = google.visualization.arrayToDataTable([
               ['Gainers',10,30,45,60],
               ['Losers',20,35,25,45],
        ], true);

        var chart = new google.visualization.ImageCandlestickChart(document.getElementById('visualization'));
        chart.draw(dataTable, options);
      }

      google.setOnLoadCallback(drawVisualization);
     </script>
  </head>
   <body style="font-family: Arial;border: 0 none;">
     <div id="visualization" style="width: 300px; height: 300px;"></div>
   </body>
</html>

Loading

The google.load package name is "imagechart"

  google.load('visualization', '1', {packages: [imagechart]});

The visualization's class name is google.visualization.ImageCandlestickChart

  var visualization = new google.visualization.ImageCandlestickChart(container);

Data Format

Five columns, where each row describes a single candlestick marker:

  • Col 0: String used as a label for this marker on the X axis.
  • Col 1: Number specifying the low/minimum value of this marker. This is the base of the black line.
  • Col 2: Number specifying the opening/initial value of this marker. This is one vertical border of the candle. If less than the column 3 value, the candle will be green; otherwise it will be red.
  • Col 3: Number specifying the closing/final value of this marker. This is the second vertical border of the candle. If less than the column 2 value, the candle will be red; otherwise it will be green.
  • Col 4: Number specifying the high/maximum value of this marker. This is the top of the black line.

Configuration Options

In addition to the options supported by the Generic Image Chart, the Candlestick Chart supports the following options:

Name Type Default Description
backgroundColor string '#FFFFFF' (white) The background color for the chart. This is a #RRGGBB string, including the # mark.
showAxisLines boolean true Whether to show the axis lines. If set to false, then the axis labels will also not be shown.
height number Height of the containing element Height of the chart, in pixels. If 30 < height or height > 1,000 then this value will default to 200.
max number Maximum data value The maximum Y axis value.
min number Minimum data value The minimum Y axis value.
showCategoryLabels boolean true If false, hides the X axis labels.
showValueLabels boolean true If false, hides the Y axis labels.
showValueLabelsInternal number auto The spacing between the Y axis labels, in pixels.
title string '' Text to display above the chart.
width number Width of the containing element Width of the chart, in pixels. If width is less than 30 or greater than 1,000, then width will be set to 300.

Methods

Method Return Type Description
draw(data, options) none Draws the chart.

Events

You can register to hear the events described on the Generic Image Chart page.

Data Policy

Please refer to the Chart API logging policy.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.