Getting Started

Performance !!!

Chart Data

Bar and Column Charts

Line and Area Charts

Pie Charts

Scatter and Bubble Charts

Radar and Polar Charts

Financial Charts

Gantt Charts

Combinational Charts

Dynamic Charts

Working with Chart Axes

Chart Features

Customizing Chart

Client-Side Events

Vodafone Group plc

Open: High: Low: Close:Volume:

This sample demonstrates how to skip the days, which don't have data (like weekends and holidays).

For detailed implementation, please take a look at the HTML code tab.
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>
    Skip Empty Days Example - HTML5 jQuery Chart Plugin by jqChart
</title>
    <link rel="stylesheet" type="text/css" href="../css/jquery.jqChart.css" />
    <link rel="stylesheet" type="text/css" href="../css/jquery.jqRangeSlider.css" />
    <link rel="stylesheet" type="text/css" href="../themes/le-frog/jquery-ui-1.8.20.css" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../js/jquery.mousewheel.js" type="text/javascript"></script>
    <script src="../js/jquery.jqChart.min.js" type="text/javascript"></script>
    <script src="../js/jquery.jqRangeSlider.min.js" type="text/javascript"></script>
    <!--[if IE]><script lang="javascript" type="text/javascript" src="../js/excanvas.js"></script><![endif]-->
    
    <script lang="javascript" type="text/javascript">

        var ohlcData = [];
        var volumeData = [];

        var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

        $(document).ready(function () {
            $.ajax({
                url: "../ChartData.csv",
                success: function (text) {

                    processData(text);
                    initCharts();
                }
            });
        });

        function processData(text) {

            ohlcData = [];
            volumeData = [];

            var lines = text.split(/\r\n|\n/);

            for (var i = lines.length - 1; i > 1; i--) {
                var line = lines[i];
                if (!line) {
                    continue;
                }

                var columns = line.split(',');

                var date = parseDate(columns[0]);
                var open = parseFloat(columns[1]);
                var high = parseFloat(columns[2]);
                var low = parseFloat(columns[3]);
                var close = parseFloat(columns[4]);
                var volume = parseFloat(columns[5]) / 1000000;

                ohlcData.push([date, high, low, open, close]);
                volumeData.push([date, volume]);
            }
        }

        function initCharts() {
            $('#jqChart').jqChart({
                legend: { visible: false },
                border: { lineWidth: 0, padding: 0 },
                tooltips: {
                    type: 'shared',
                    disabled: true
                },
                crosshairs: {
                    enabled: true,
                    hLine: false
                },
                animation: { duration: 1 },
                axes: [
                    {
                        type: 'linear',
                        location: 'left',
                        width: 35
                    },
                    {
                        type: 'dateTime',
                        location: 'bottom',
                        skipEmptyDays: true
                    }
                ],
                series: [
                    {
                        type: 'candlestick',
                        data: ohlcData,
                        priceUpFillStyle: 'white',
                        priceDownFillStyle: 'black',
                        strokeStyle: 'black'
                    }
                ]
            });

            $('#jqChartVolume').jqChart({
                legend: { visible: false },
                border: { lineWidth: 0, padding: 0 },
                tooltips: {
                    type: 'shared',
                    disabled: true
                },
                crosshairs: {
                    enabled: true,
                    hLine: false
                },
                animation: { duration: 1 },
                axes: [
                    {
                        type: 'linear',
                        location: 'left',
                        width: 35,
                        labels: { stringFormat: '%dm' }
                    },
                    {
                        type: 'dateTime',
                        location: 'bottom',
                        skipEmptyDays: true
                    }
                ],
                series: [
                    {
                        type: 'column',
                        data: volumeData,
                        fillStyle: 'black'
                    }
                ]
            });

            var isHighlighting = false;

            $('#jqChart').bind('dataHighlighting', function (event, data) {

                if (!data) {
                    $('#jqChartVolume').jqChart('highlightData', null);
                    return;
                }

                $('#open').html(data.open);
                $('#high').html(data.high);
                $('#low').html(data.low);
                $('#close').html(data.close);

                var date = data.chart.stringFormat(data.x, "mmmm d, yyyy");

                $('#date').html(date);

                if (!isHighlighting) {

                    isHighlighting = true;

                    var index = $.inArray(data.dataItem, ohlcData);
                    $('#jqChartVolume').jqChart('highlightData', [volumeData[index]]);
                }

                isHighlighting = false;
            });

            $('#jqChartVolume').bind('dataHighlighting', function (event, data) {

                if (!data) {
                    $('#jqChart').jqChart('highlightData', null);
                    return;
                }

                var volume = data.chart.stringFormat(data.y, "%.2f") + 'm';

                $('#volume').html(volume);

                if (!isHighlighting) {

                    isHighlighting = true;

                    var index = $.inArray(data.dataItem, volumeData);
                    $('#jqChart').jqChart('highlightData', [ohlcData[index]]);
                }

                isHighlighting = false;
            });

            $('#jqChart').jqChart('highlightData', [ohlcData[0]]);
            $('#jqChartVolume').jqChart('highlightData', [volumeData[0]]);
        }

        function parseDate(date) {

            var items = date.split('-');

            var month = $.inArray(items[1], monthNames);

            return new Date(2000 + parseInt(items[2]), month, parseInt(items[0]));
        }
    </script>

</head>
<body>
    <h3>Vodafone Group plc</h3>
    <div style="margin-left: 10px">
        <b>Open:</b><span id="open" style="display: inline-block; width: 45px;"> </span>
        <b>High:</b><span id="high" style="display: inline-block; width: 45px;"> </span>
        <b>Low:</b><span id="low" style="display: inline-block; width: 45px;"> </span><b>Close:</b><span
            id="close" style="display: inline-block; width: 45px;"></span><b>Volume: </b>
        <span id="volume" style="display: inline-block; width: 55px;"></span><span style="float: right;
            font-weight: bolder; width: 150px"
            id="date"></span>
    </div>
    <div>
        <div>
            <div id="jqChart" style="width: 600px; height: 250px;">
            </div>
        </div>
        <div>
            <div id="jqChartVolume" style="width: 600px; height: 130px;">
            </div>
        </div>
    </div>
</body>
</html>