Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SVG Rect在一段时间后失去笔划_Javascript_Html_Svg_Stroke - Fatal编程技术网

Javascript SVG Rect在一段时间后失去笔划

Javascript SVG Rect在一段时间后失去笔划,javascript,html,svg,stroke,Javascript,Html,Svg,Stroke,出于某种原因,我的直肠在随机时间后失去了一些冲程,有时是50秒,真的想不出任何原因,也许你能帮忙吗 这是小提琴- 一些代码 $(window).resize(OwResize); function OwResize() { $("#myConta").height($(window).innerHeight() - ($(window).innerHeight() / 40)); } var sideRectW = window.innerWidth / 20, sideRe

出于某种原因,我的直肠在随机时间后失去了一些冲程,有时是50秒,真的想不出任何原因,也许你能帮忙吗

这是小提琴-

一些代码

$(window).resize(OwResize);

function OwResize() {
    $("#myConta").height($(window).innerHeight() - ($(window).innerHeight() / 40));
}

var sideRectW = window.innerWidth / 20,
    sideRectH = $(window).innerHeight() / 20,
    width = $(window).innerWidth() - ($(window).innerWidth() / 50),
    height = $(window).innerHeight() - ($(window).innerHeight() / 40),
    boxW = (width - sideRectW) / 4,
    boxH = (height - sideRectH) / 4,
    boxSize = boxW + boxH,
    xPos1 = sideRectW,
    xPos2 = boxW + sideRectW,
    xPos3 = (boxW * 2) + sideRectW,
    xPos4 = (boxW * 3) + sideRectW,
    yPos1 = 0,
    yPos2 = boxH,
    yPos3 = boxH * 2,
    yPos4 = boxH * 3;


var CreateRect = function (x, y, boxColor, boxId) {
    svgContainer.append("rect")
        .attr("x", x)
        .attr("y", y)
        .attr("id", "rectBox" + boxId)
        .attr("width", boxW)
        .attr("height", boxH)
        .attr("fill", boxColor)
        .attr("stroke", "black")
        .attr("class", "hover_group")
        .attr("onclick", "alert('haha');");
};
var CreateRectWithLength = function (x, y, w, h, boxColor) {
    svgContainer.append("rect")
        .attr("x", x)
        .attr("y", y)
        .attr("width", w)
        .attr("height", h)
        .attr("fill", boxColor);
};
var CreateText = function (x, y, text, textColor, size) {
    svgContainer.append("text")
        .attr("x", x)
        .attr("y", y)
        .attr("fill", textColor)
        .attr("font-size", size)
        .text(text);
};
var CreateText90 = function (x, y, text, textColor, size) {
    svgContainer.append("text")
        .attr("x", x)
        .attr("y", y)
        .attr("fill", textColor)
        .attr("font-size", size)
        .attr("transform", "rotate(-90," + x + 20 + ", " + y + ")")
        .text(text);
};
var svgContainer = d3.select("#myConta")
    .append("svg")
    .attr("id", "myContasvg")
    .attr("width", "100%")
    .attr("height", "100%")
    .attr("preserveAspectRatio", "none")
    .attr("viewBox", "0 0 " + width+ " " + height)
    .attr("fill", "#2E2E2E")
    .attr("float", "right")
    .append("g");

CreateRectWithLength(0, 0, sideRectW, window.innerHeight, "Black");
CreateRectWithLength(0, height - sideRectH, width, sideRectH, "Black");

CreateText90(0, yPos3, "Sales", "white", 16);
CreateText(xPos3, height - sideRectH / 5, "Profit", "white", 16);

CreateText(sideRectW / 2, yPos1 + (boxH / 2), "3", "white", 12);
CreateText(sideRectW / 2, yPos2 + (boxH / 2), "2", "white", 12);
CreateText(sideRectW / 2, yPos3 + (boxH / 2), "1", "white", 12);
CreateText(sideRectW / 2, yPos4 + (boxH / 2), "0", "white", 12);

CreateText(xPos1 + (boxW / 2), height - sideRectH / 2, "0", "white", 12);
CreateText(xPos2 + (boxW / 2), height - sideRectH / 2, "1", "white", 12);
CreateText(xPos3 + (boxW / 2), height - sideRectH / 2, "2", "white", 12);
CreateText(xPos4 + (boxW / 2), height - sideRectH / 2, "3", "white", 12);

CreateRect(xPos1, yPos1, "#C0FC3E", 03);
CreateRect(xPos1, yPos2, "#60FC60", 02);
CreateRect(xPos1, yPos3, "#64FE2E", 01);
CreateRect(xPos1, yPos4, "#00FF00", 00);

CreateRect(xPos2, yPos1, "#F6FF33", 13);
CreateRect(xPos2, yPos2, "#AFFC3B", 12);
CreateRect(xPos2, yPos3, "#00FF00", 11);
CreateRect(xPos2, yPos4, "#64FE2E", 10);

CreateRect(xPos3, yPos1, "#FDB500", 23);
CreateRect(xPos3, yPos2, "#8DB723", 22);
CreateRect(xPos3, yPos3, "#AFFC3B", 21);
CreateRect(xPos3, yPos4, "#60FC60", 20);

CreateRect(xPos4, yPos1, "red", 33);
CreateRect(xPos4, yPos2, "#FDB500", 32);
CreateRect(xPos4, yPos3, "#F6FF33", 31);
CreateRect(xPos4, yPos4, "#C0FC3E", 30);
图片证据

$(window).resize(OwResize);

function OwResize() {
    $("#myConta").height($(window).innerHeight() - ($(window).innerHeight() / 40));
}

var sideRectW = window.innerWidth / 20,
    sideRectH = $(window).innerHeight() / 20,
    width = $(window).innerWidth() - ($(window).innerWidth() / 50),
    height = $(window).innerHeight() - ($(window).innerHeight() / 40),
    boxW = (width - sideRectW) / 4,
    boxH = (height - sideRectH) / 4,
    boxSize = boxW + boxH,
    xPos1 = sideRectW,
    xPos2 = boxW + sideRectW,
    xPos3 = (boxW * 2) + sideRectW,
    xPos4 = (boxW * 3) + sideRectW,
    yPos1 = 0,
    yPos2 = boxH,
    yPos3 = boxH * 2,
    yPos4 = boxH * 3;


var CreateRect = function (x, y, boxColor, boxId) {
    svgContainer.append("rect")
        .attr("x", x)
        .attr("y", y)
        .attr("id", "rectBox" + boxId)
        .attr("width", boxW)
        .attr("height", boxH)
        .attr("fill", boxColor)
        .attr("stroke", "black")
        .attr("class", "hover_group")
        .attr("onclick", "alert('haha');");
};
var CreateRectWithLength = function (x, y, w, h, boxColor) {
    svgContainer.append("rect")
        .attr("x", x)
        .attr("y", y)
        .attr("width", w)
        .attr("height", h)
        .attr("fill", boxColor);
};
var CreateText = function (x, y, text, textColor, size) {
    svgContainer.append("text")
        .attr("x", x)
        .attr("y", y)
        .attr("fill", textColor)
        .attr("font-size", size)
        .text(text);
};
var CreateText90 = function (x, y, text, textColor, size) {
    svgContainer.append("text")
        .attr("x", x)
        .attr("y", y)
        .attr("fill", textColor)
        .attr("font-size", size)
        .attr("transform", "rotate(-90," + x + 20 + ", " + y + ")")
        .text(text);
};
var svgContainer = d3.select("#myConta")
    .append("svg")
    .attr("id", "myContasvg")
    .attr("width", "100%")
    .attr("height", "100%")
    .attr("preserveAspectRatio", "none")
    .attr("viewBox", "0 0 " + width+ " " + height)
    .attr("fill", "#2E2E2E")
    .attr("float", "right")
    .append("g");

CreateRectWithLength(0, 0, sideRectW, window.innerHeight, "Black");
CreateRectWithLength(0, height - sideRectH, width, sideRectH, "Black");

CreateText90(0, yPos3, "Sales", "white", 16);
CreateText(xPos3, height - sideRectH / 5, "Profit", "white", 16);

CreateText(sideRectW / 2, yPos1 + (boxH / 2), "3", "white", 12);
CreateText(sideRectW / 2, yPos2 + (boxH / 2), "2", "white", 12);
CreateText(sideRectW / 2, yPos3 + (boxH / 2), "1", "white", 12);
CreateText(sideRectW / 2, yPos4 + (boxH / 2), "0", "white", 12);

CreateText(xPos1 + (boxW / 2), height - sideRectH / 2, "0", "white", 12);
CreateText(xPos2 + (boxW / 2), height - sideRectH / 2, "1", "white", 12);
CreateText(xPos3 + (boxW / 2), height - sideRectH / 2, "2", "white", 12);
CreateText(xPos4 + (boxW / 2), height - sideRectH / 2, "3", "white", 12);

CreateRect(xPos1, yPos1, "#C0FC3E", 03);
CreateRect(xPos1, yPos2, "#60FC60", 02);
CreateRect(xPos1, yPos3, "#64FE2E", 01);
CreateRect(xPos1, yPos4, "#00FF00", 00);

CreateRect(xPos2, yPos1, "#F6FF33", 13);
CreateRect(xPos2, yPos2, "#AFFC3B", 12);
CreateRect(xPos2, yPos3, "#00FF00", 11);
CreateRect(xPos2, yPos4, "#64FE2E", 10);

CreateRect(xPos3, yPos1, "#FDB500", 23);
CreateRect(xPos3, yPos2, "#8DB723", 22);
CreateRect(xPos3, yPos3, "#AFFC3B", 21);
CreateRect(xPos3, yPos4, "#60FC60", 20);

CreateRect(xPos4, yPos1, "red", 33);
CreateRect(xPos4, yPos2, "#FDB500", 32);
CreateRect(xPos4, yPos3, "#F6FF33", 31);
CreateRect(xPos4, yPos4, "#C0FC3E", 30);

您可以尝试指定笔划的宽度:

该属性的代码为:

stroke-width="2"

您可以在元素中或元素本身中应用笔划。

在哪个浏览器中?在chrome中,这不是happening@FrederikWitte它发生在Chrome和IE 10中