Getting Started

Performance !!!

Chart Data

Bar and Column Charts

Line and Area Charts

Pie and Funnel 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>
<html>
<head>
	<title>
	Skip Empty Days Example - JavaScript Chart by DataViz Charts
</title>
	<link rel="stylesheet" type="text/css" href="../../css/dataviz.chart.css" />
	<link rel="stylesheet" type="text/css" href="../../themes/le-frog/styles.css" />
	<script src="../../js/dataviz.chart.min.js" type="text/javascript"></script>
	
	<script lang="javascript" type="text/javascript">

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

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

		var request = new XMLHttpRequest();

		request.onload = function () {
			if (request.status >= 200 && request.status < 400) {
				// Success!
				var resp = request.responseText;

				processData(resp);
				initCharts();
			}
		};

		request.open('GET', "../ChartData.csv");
		request.send();

		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() {
			var chart = new DataViz.Chart({
				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'
                    }
				]
			});
			chart.write('chart');

			var volumeChart = new DataViz.Chart({
				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'
                    }
				]
			});
			volumeChart.write('chartVolume');

			var isHighlighting = false;

			chart.addEventListener('dataHighlighting', function (event, data) {
				if (!data) {
					volumeChart.highlightData();
					return;
				}

				document.getElementById('open').innerHTML = data.open;
				document.getElementById('high').innerHTML = data.high;
				document.getElementById('low').innerHTML = data.low;
				document.getElementById('close').innerHTML = data.close;

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

				document.getElementById('date').innerHTML = date;

				if (!isHighlighting) {

					isHighlighting = true;

					var index = ohlcData.indexOf(data.dataItem);
					volumeChart.highlightData([volumeData[index]]);
				}

				isHighlighting = false;
			});

			volumeChart.addEventListener('dataHighlighting', function (event, data) {
				if (!data) {
					chart.highlightData();
					return;
				}

				document.getElementById('volume').innerHTML = data.y;

				if (!isHighlighting) {

					isHighlighting = true;

					var index = volumeData.indexOf(data.dataItem);
					chart.highlightData([ohlcData[index]]);
				}

				isHighlighting = false;
			});
		}

		function parseDate(date) {

			var items = date.split('-');
			var month = monthNames.indexOf(items[1]);

			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="chart" style="width: 600px; height: 250px;">
			</div>
		</div>
		<div>
			<div id="chartVolume" style="width: 600px; height: 130px;">
			</div>
		</div>
	</div>
</body>
</html>