Skip to content

Commit f5e79c9

Browse files
committed
use unix time for date representations
1 parent 9d8ee6f commit f5e79c9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ <h1 class="title">Angular D3 Chart Directive</h1>
6262
</div>
6363
<div class="example__javascript">
6464
<div class="example__title text_group__title">Javascript</div>
65-
<pre class="example__text text_group__text">$scope.drawLine({&#10; colors: {&#10; axes: &apos;#222&apos;,&#10; labels: &apos;#666&apos;,&#10; lines: &apos;#F2CFDA&apos;&#10; },&#10; labels: {&#10; y: &apos;Completion (%)&apos;&#10; },&#10; data: [&#10; {&#10; x: &apos;13-Oct-13&apos;,&#10; y: 10&#10; }, {&#10; x: &apos;17-Oct-13&apos;,&#10; y: 30&#10; }, {&#10; x: &apos;19-Oct-13&apos;,&#10; y: 23&#10; }, {&#10; x: &apos;26-Oct-13&apos;,&#10; y: 42&#10; },&#10; ]&#10;});</pre>
65+
<pre class="example__text text_group__text">$scope.drawLine({&#10; colors: {&#10; axes: &apos;#222&apos;,&#10; labels: &apos;#666&apos;,&#10; lines: &apos;#F2CFDA&apos;&#10; },&#10; labels: {&#10; y: &apos;Completion (%)&apos;&#10; },&#10; data: [&#10; {&#10; x: 1381640400000,&#10; y: 10&#10; }, {&#10; x: 1381986000000,&#10; y: 30&#10; }, {&#10; x: 1382158800000,&#10; y: 23&#10; }, {&#10; x: 1382763600000,&#10; y: 42&#10; }&#10; ]&#10;});</pre>
6666
</div>
6767
</div>
6868
<div class="example__output">
@@ -166,18 +166,18 @@ <h1 class="title">Angular D3 Chart Directive</h1>
166166
},
167167
data: [
168168
{
169-
x: '13-Oct-13',
169+
x: 1381640400000,
170170
y: 10
171171
}, {
172-
x: '17-Oct-13',
172+
x: 1381986000000,
173173
y: 30
174174
}, {
175-
x: '19-Oct-13',
175+
x: 1382158800000,
176176
y: 23
177177
}, {
178-
x: '26-Oct-13',
178+
x: 1382763600000,
179179
y: 42
180-
},
180+
}
181181
]
182182
});
183183

src/angular-graphs.line.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ angular.module('picardy.graphs.line', ['picardy.graphs.common'])
55

66
function render (scope, element) {
77

8-
var options, d3Data, options, getColor, svg, parseDate, margin, width, height, x, y, labels, axes, lines;
8+
var options, d3Data, options, getColor, svg, margin, width, height, x, y, labels, axes, lines;
99

1010
if (!scope.data) {
1111
return;
@@ -34,10 +34,10 @@ angular.module('picardy.graphs.line', ['picardy.graphs.common'])
3434
width = options.width - margin.left - margin.right;
3535
height = options.height - margin.top - margin.bottom;
3636

37-
parseDate = d3.time.format('%d-%b-%y').parse;
38-
3937
angular.forEach(options.data, function (d) {
40-
d.x = parseDate(d.x);
38+
if (d.x > 0) {
39+
d.x = new Date(d.x);
40+
}
4141
d3Data.push(d);
4242
});
4343

0 commit comments

Comments
 (0)