0
我想为当前时间添加一个垂直“当前”标记到用angular-nvd3指令实现的工作时间序列折线图。有点像这样:http://i.imgur.com/XsmfOXe.jpg在角度nvd3折线图中显示当前时间
以前我使用纯粹的d3.js构建了这个图表,并让它工作。所以我试图将我现有的解决方案移植到这样的指令中:
myApp.directive('nowMarker', function() {
return {
restrict: 'A',
link: function (scope, element, attr) {
var line = d3.svg.line()
.interpolate("basis")
// ####### this cannot work #######
.x(function (d) { return x(d.t); })
.y(function (d) { return y(d.value); });
// ################################
element.children()[0].append('svg:path')
.attr("class", "NOW")
.attr('d', line(scope.nowData))
.attr('stroke', '#14022B')
.attr('stroke-width', '1px')
.attr('stroke-dasharray', ('5,5'))
.attr('fill', 'none');
}
};
});
这就是我卡住的地方。我不知道如何访问angularjs-nvd3-directives图表的x和y比例。
的HTML是:
<nvd3-line-chart nowMarker ...>
</nvd3-line-chart>
,在我的图表控制器我有:
var now = new Date();
$scope.nowData = [
{name: "NOW", t: now, value: 0},
{name: "NOW", t: now, value: 100}
];
有没有错误信息,只是什么都不会发生。
任何帮助,非常感谢。谢谢! 班纳特
根本没有想法? – burtelli 2015-04-08 12:45:09