var data = [
{ count: 2, avg_duration: 4.6, date: { year: 2014, month: 8, day: 11 } },
{ count: 6, avg_duration: 8.5, date: { year: 2014, month: 8, day: 12 } }
...
]
$scope.time_series.data = [
{ key: 'Number of views', bar: true, values: data },
{ key: 'Average duration (seconds)', values: data }
]
$scope.time_series.options = {
chart: {
type: 'linePlusBarChart',
height: 350,
margin: {
top: 20,
right: 20,
bottom: 60,
left: 55
},
x: function(d) {
return new Date(d.date.year, d.date.month, d.date.day)
},
y1: function(d) {
return d.count
},
y2: function(d) {
return d.avg_duration
},
color: d3.scale.category10().range(),
transitionDuration: 250,
xAxis: {
axisLabel: 'Date',
tickFormat: function(d) {
return d3.time.format('%x')(new Date(d))
},
showMaxMin: false,
staggerLabels: true
},
y1Axis: {
axisLabel: 'Number of views',
tickFormat: function(d) {
return d3.format(',f')(d)
}
},
y2Axis: {
axisLabel: 'Average duration (seconds)',
tickFormat: function(d) {
return d3.format(',.2f')(d)
}
}
}
}
But this doesn't work. Is there only one way specify the y
data?