dojox
Version:
Dojo eXtensions, a rollup of many useful sub-projects and varying states of maturity – from very stable and robust, to alpha and experimental. See individual projects contain README files for details.
59 lines (53 loc) • 1.6 kB
HTML
<!--[if IE 7]>
<!DOCTYPE>
<html lang="en">
<head>
<![endif]-->
<!--[if IE 8]>
<!DOCTYPE>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<![endif]-->
<![if gte IE 9]>
<html lang="en">
<head>
<![endif]>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Testing Axes with Date Labels</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/tests/css/dijitTests.css";
@import "../../../dijit/themes/claro/claro.css";
</style>
</head>
<body class="claro">
<div id="simplechart" style="width: 600px; height: 200px;"></div>
<script src='../../../dojo/dojo.js' data-dojo-config="async:1, isDebug:1"></script>
<script>
require([
"dojo/date",
"dojo/date/locale",
"dojox/charting/Chart",
"dojox/charting/themes/Claro",
"dojox/charting/plot2d/Lines",
"dojox/charting/axis2d/Default",
"dojo/domReady!"
], function (date, locale, Chart, Claro) {
function makeLabel(index){
var idx = index - 1;
var d = date.add(new Date(), 'month', idx);
return locale.format(d, {datePattern:'MM-dd-yyyy', selector:'date'});
}
var chart = new Chart("simplechart");
chart.setTheme(Claro);
chart.addPlot("myPlot", {type: "Lines"});
chart.addAxis("x", {labelFunc:makeLabel, minorTicks:false});
chart.addAxis("y", {vertical: true, leftBottom: true, includeZero:true});
chart.addSeries("Series 1", [2, 2, 2, 3, 4, 5, 5, 7]);
chart.render();
});
</script>
</body>
</html>