Permalink
Browse files

move back to time scale for x axis, get example working again, kind of

  • Loading branch information...
boorad committed Jan 10, 2012
1 parent 806b91b commit 4c0b9ec2f4b49be8935c0642085e5f81577ec57e
Showing with 17 additions and 21 deletions.
  1. +6 −8 index.haml
  2. +6 −8 index.html
  3. +5 −5 js/d3.tsline.js
View
@@ -24,31 +24,29 @@
var mychart = new d3_tsline("#chart");
// override format_data function, taking json payload and creating
- // 2-arrays as data points in a series. Return an array of series
+ // 2-arrays as data points in a series. Return an array of one series
mychart.format_data = function(data) {
var series = [];
- data.forEach(function(json) {
+ data[0].forEach(function(json) {
series.push([json.date, json.val]);
});
return [ series ];
};
// override parse_date function to handle our data's date format
- mychart.parse_date = function(dt) {
- d3.time.format("%b %d, %Y").parse(dt);
- };
+ mychart.parse_date = d3.time.format("%b %d, %Y").parse;
// add some metadata about the series
mychart.series = [
{
"name" : "AAPL",
"css" : "aapl"
}
- ]
+ ];
// fetch data and draw the chart
var url = "aapl.csv";
d3.csv(url, function(data) {
- mychart.data = data;
- mychart.draw_chart();
+ mychart.setSeriesData([data]);
+ mychart.render();
});
View
@@ -27,33 +27,31 @@
var mychart = new d3_tsline("#chart");
// override format_data function, taking json payload and creating
- // 2-arrays as data points in a series. Return an array of series
+ // 2-arrays as data points in a series. Return an array of one series
mychart.format_data = function(data) {
var series = [];
- data.forEach(function(json) {
+ data[0].forEach(function(json) {
series.push([json.date, json.val]);
});
return [ series ];
};
// override parse_date function to handle our data's date format
- mychart.parse_date = function(dt) {
- d3.time.format("%b %d, %Y").parse(dt);
- };
+ mychart.parse_date = d3.time.format("%b %d, %Y").parse;
// add some metadata about the series
mychart.series = [
{
"name" : "AAPL",
"css" : "aapl"
}
- ]
+ ];
// fetch data and draw the chart
var url = "aapl.csv";
d3.csv(url, function(data) {
- mychart.data = data;
- mychart.draw_chart();
+ mychart.setSeriesData([data]);
+ mychart.render();
});
//]]>
</script>
View
@@ -262,8 +262,8 @@ function d3_tsline(id) {
// set up scale and axis functions
var diff = self.get_diff(w, values);
- var x = d3.scale.linear()
- .range([1, w + diff]) // overlap to make smooth scroll effect
+ var x = d3.time.scale()
+ .range([1, w + diff])
.domain(self.domain.view.x);
var y = d3.scale.linear()
.range([h, 0])
@@ -338,9 +338,9 @@ function d3_tsline(id) {
// set up scale and axis functions
var diff = w / values[0].length;
- var x = d3.scale.linear()
- .range([1, w + diff]) // overlap to make smooth scroll effect
- .domain(self.domain.summary.x);
+ var x = d3.time.scale()
+ .range([1, w + diff])
+ .domain(self.domain.view.x);
var y = d3.scale.linear()
.range([h, 0])
.domain(self.domain.summary.y).nice();

0 comments on commit 4c0b9ec

Please sign in to comment.