Javascript d3.v3.min.js:1错误:<;svg>;属性高度:预期长度;“南”;在模式弹出窗口中加载d3图表时
我一直试图在点击一个较小的图表时加载一个较大的图表。我调整了图表的视图框大小,使其具有响应性。但我现在面临的问题是,第一张图表正变得响应迅速,并在主页上加载。但是,当我单击该图形以在viewbox中加载更大的图表时,我得到了一个错误d3.v3.min.js:1错误:属性高度:预期长度,“NaN” 奇怪的是,我对两个图表使用相同的指令&相同的控制器,对于第一个图表,viewbox width给出了一个值,但是对于另一个图表,它给出了NaN 任何帮助都将受到感谢Javascript d3.v3.min.js:1错误:<;svg>;属性高度:预期长度;“南”;在模式弹出窗口中加载d3图表时,javascript,angularjs,d3.js,svg,Javascript,Angularjs,D3.js,Svg,我一直试图在点击一个较小的图表时加载一个较大的图表。我调整了图表的视图框大小,使其具有响应性。但我现在面临的问题是,第一张图表正变得响应迅速,并在主页上加载。但是,当我单击该图形以在viewbox中加载更大的图表时,我得到了一个错误d3.v3.min.js:1错误:属性高度:预期长度,“NaN” 奇怪的是,我对两个图表使用相同的指令&相同的控制器,对于第一个图表,viewbox width给出了一个值,但是对于另一个图表,它给出了NaN 任何帮助都将受到感谢 var-app=angular.m
var-app=angular.module('chartApp',[]);
app.controller('TimeReportCtrl',['$scope',函数($scope){
$scope.reportData={“其他时间”:0,“ais时间”:0,“议程时间”:0,“准备时间”:1,“会议时间”:7};
log($scope.reportData.other_time);
如果($scope.reportData.other_time==0)&($scope.reportData.ais_time==0)&($scope.reportData.agents_time==0)&($scope.reportData.preps_time==0)&($scope.reportData.meeting_time==0))
{
$scope.noData=false;
}
其他的
{
$scope.noData=true;
}
$scope.timeReportData=[];
for(var i在$scope.reportData中){
$scope.timeReportData.push({labelData:i,count:$scope.reportData[i]});
}
$scope.timeReport=[];
对于(var i=0;i
第251行:
function resize() {
改为:
function resize(container) {
var targetWidth = parseInt(container.style("width"));
console.log(targetWidth);
svg.attr("width", targetWidth);
svg.attr("height", Math.round(targetWidth / aspect));
}
需要传递容器变量。第251行:
function resize() {
改为:
function resize(container) {
var targetWidth = parseInt(container.style("width"));
console.log(targetWidth);
svg.attr("width", targetWidth);
svg.attr("height", Math.round(targetWidth / aspect));
}
需要传递容器变量。请尝试这种方法
d3.select(window).on("resize", resize);
// get width of container and resize svg to fit it
function resize() {
var containerWidth = parseInt(container.style("width"));
var targetWidth = containerWidth ? containerWidth : parseInt(svg.style("width"));
console.log(targetWidth);
svg.attr("width", targetWidth);
svg.attr("height", Math.round(targetWidth / aspect));
}
var-app=angular.module('chartApp',[]);
app.controller('TimeReportCtrl',['$scope',函数($scope){
$scope.reportData={“其他时间”:0,“ais时间”:0,“议程时间”:0,“准备时间”:1,“会议时间”:7};
log($scope.reportData.other_time);
如果($scope.reportData.other_time==0)&($scope.reportData.ais_time==0)&($scope.reportData.agents_time==0)&($scope.reportData.preps_time==0)&($scope.reportData.meeting_time==0))
{
$scope.noData=false;
}
其他的
{
$scope.noData=true;
}
$scope.timeReportData=[];
for(var i在$scope.reportData中){
$scope.timeReportData.push({labelData:i,count:$scope.reportData[i]});
}
$scope.timeReport=[];
对于(var i=0;i
这样试试
d3.select(window).on("resize", resize);
// get width of container and resize svg to fit it
function resize() {
var containerWidth = parseInt(container.style("width"));
var targetWidth = containerWidth ? containerWidth : parseInt(svg.style("width"));
console.log(targetWidth);
svg.attr("width", targetWidth);
svg.attr("height", Math.round(targetWidth / aspect));
}
var-app=angular.module('chartApp',[]);
app.controller('TimeReportCtrl',['$scope',函数($scope){
$scope.reportData={“其他时间”:0,“ais时间”:0,“议程时间”:0,“准备时间”:1,“会议时间”:7};
log($scope.reportData.other_time);
如果($scope.reportData.other_time==0)&($scope.reportData.ais_time==0)&($scope.reportData.agents_time==0)&($scope.reportData.preps_time==0)&($scope.reportData.meeting_time==0))
{
$scope.noData=false;
}
其他的
{
$scope.noData=true;
}
$scope.timeReportData=[];
for(var i在$scope.reportData中){
$scope.timeReportData.push({labelData:i,count:$scope.reportData[i]});
}
$scope.timeReport=[];
对于(var i=0;i
在传递容器变量时,它给出了未捕获的TypeError:无法读取未定义的属性“style”。如果我添加该属性,它也不会使报表响应。第241行:d3.select(window).on(“resize.”+container.attr(“id”),resize);应该是(“resize”+…)这只是消除了未定义的错误。它仍然没有响应,抱歉,改变这一点也没有帮助。问题是它很好地加载了第一张图表,甚至调整了它的大小,但问题是在模态中加载图表时出现的。当时只有它给出了值,因为NanI很难弄清楚您的目标是什么或者,但我注意到您在html标记中显式设置了50%高度和宽度的样式。这可能也会给您带来问题。在传递容器变量时,它会给出未捕获的TypeError:无法读取未定义的属性“style”。此外,如果添加该属性,则不会使报表响应。第241行:d3.select(window)。on(“resize”)+container.attr(“id”),resize);应该是(“resize”+…)这只是消除了未定义的错误。它仍然没有响应,抱歉,改变这一点也没有帮助。问题是它很好地加载了第一张图表,甚至调整了它的大小,但问题是在模态中加载图表时出现的。当时只有它给出了值,因为NanI很难弄清楚您的目标是什么或者,但我注意到您在html标记中明确设置了50%高度和宽度的样式。这可能也会给您带来问题。嘿,我面临同样的问题属性高度:预期长度,“NaN”
我正在使用并且当我实现其给我高度错误时
嘿,我面临着相同的问题属性高度:预期长度,“NaN”
我正在使用并且当我实现其给我高度错误时