- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer", {
zoomEnabled: false,
animationEnabled: true,
title: {
text: "Mobile Phone Subscriptions"
},
axisY2: {
valueFormatString: "0.0 bn",
maximum: 1.2,
interval: .2,
interlacedColor: "#F5F5F5",
gridColor: "#D7D7D7",
tickColor: "#D7D7D7"
},
theme: "theme2",
toolTip: {
shared: true
},
legend: {
verticalAlign: "bottom",
horizontalAlign: "center",
fontSize: 15,
fontFamily: "Lucida Sans Unicode"
},
data: [{
type: "line",
lineThickness: 3,
axisYType: "secondary",
showInLegend: true,
name: "India",
dataPoints: [{
x: new Date(2001, 0),
y: 0
}, {
x: new Date(2002, 0),
y: 0.001
}, {
x: new Date(2003, 0),
y: 0.01
}, {
x: new Date(2004, 0),
y: 0.05
}, {
x: new Date(2005, 0),
y: 0.1
}, {
x: new Date(2006, 0),
y: 0.15
}, {
x: new Date(2007, 0),
y: 0.22
}, {
x: new Date(2008, 0),
y: 0.38
}, {
x: new Date(2009, 0),
y: 0.56
}, {
x: new Date(2010, 0),
y: 0.77
}, {
x: new Date(2011, 0),
y: 0.91
}, {
x: new Date(2012, 0),
y: 0.94
}
]
}, {
type: "line",
lineThickness: 3,
showInLegend: true,
name: "China",
axisYType: "secondary",
dataPoints: [{
x: new Date(2001, 00),
y: 0.18
}, {
x: new Date(2002, 00),
y: 0.2
}, {
x: new Date(2003, 0),
y: 0.25
}, {
x: new Date(2004, 0),
y: 0.35
}, {
x: new Date(2005, 0),
y: 0.42
}, {
x: new Date(2006, 0),
y: 0.5
}, {
x: new Date(2007, 0),
y: 0.58
}, {
x: new Date(2008, 0),
y: 0.67
}, {
x: new Date(2009, 0),
y: 0.78
}, {
x: new Date(2010, 0),
y: 0.88
}, {
x: new Date(2011, 0),
y: 0.98
}, {
x: new Date(2012, 0),
y: 1.04
}
]
}, {
type: "line",
lineThickness: 3,
showInLegend: true,
name: "USA",
axisYType: "secondary",
dataPoints: [{
x: new Date(2001, 00),
y: 0.16
}, {
x: new Date(2002, 0),
y: 0.17
}, {
x: new Date(2003, 0),
y: 0.18
}, {
x: new Date(2004, 0),
y: 0.19
}, {
x: new Date(2005, 0),
y: 0.20
}, {
x: new Date(2006, 0),
y: 0.23
}, {
x: new Date(2007, 0),
y: 0.261
}, {
x: new Date(2008, 0),
y: 0.289
}, {
x: new Date(2009, 0),
y: 0.3
}, {
x: new Date(2010, 0),
y: 0.31
}, {
x: new Date(2011, 0),
y: 0.32
}, {
x: new Date(2012, 0),
y: 0.33
}
]
}
],
legend: {
cursor: "pointer",
itemclick: function(e) {
if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
chart.render();
}
}
});
chart.render();
}
#control_panel_container {
text-align: center;
}
.cp_content_container {
padding-top: 12px;
text-align: left;
color: #373737;
}
.cp_content_container > div {
display: none;
}
input.control_panel_tabs {
display: none;
}
label.control_panel_tabs {
font-family: Verdana, Tahoma, sans-serif;
font-weight: 600;
background-color: #C0B9C7;
color: white;
display: inline-block;
padding: 15px 25px;
text-align: center;
border: 2px solid black;
border-radius: 15px;
}
label.control_panel_tabs:hover {
background-color: #AA95B9;
color: #fff;
cursor: pointer;
}
input:checked + label.control_panel_tabs {
background: #9471AB;
color: #fff;
}
#cp_tab1:checked ~ .cp_content_container #cp_content1,
#cp_tab2:checked ~ .cp_content_container #cp_content2 {
display: block;
}
<script src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="control_panel_container">
<input class="control_panel_tabs" id="cp_tab1" type="radio" name="cp_tabs" checked>
<label class="control_panel_tabs" for="cp_tab1">tab 1</label>
<input class="control_panel_tabs" id="cp_tab2" type="radio" name="cp_tabs">
<label class="control_panel_tabs" for="cp_tab2">tab 2</label>
<div class="cp_content_container">
<div id="cp_content1"></div>
<div id="cp_content2">
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
</div>
</div>
</div>
我在默认情况下隐藏的选项卡中有一个图表。当用户单击该选项卡时,它们就会出现。然而,它们有点倾斜,水平方向被挤压,垂直方向被拉伸(stretch)。请参阅 fiddle 了解我的意思,它位于“选项卡 2”下。
更改浏览器的缩放级别(至少在 Firefox 中)似乎可以使其自行纠正。
我注意到如果我将它放在选项卡 1 中,但是在页面加载时它会正确显示。只有当它不是默认选项卡时,它才会扭曲并需要缩放更改才能正确显示。
这是怎么回事?看起来图形只在我打开选项卡时呈现(根据动画判断)。我在想也许是因为 CSS 中的 display
属性,但也许是因为它需要在页面加载时呈现?
这是一个可编辑的 fiddle : http://jsfiddle.net/ryfy8j9s/1/
最佳答案
问题是图表的默认宽度设置为 500,即使您在 window.onload 中调用 chart.render(),由于其容器不可见,它会以默认宽度创建图表并卡在那里直到再次调用 chart.render() (例如,调整窗口大小)。 这不是唯一的问题。例如,如果您调整窗口大小以修复图表,但随后单击返回选项卡 1,再次调整窗口大小,然后单击返回选项卡 2,再次单击图表尺寸不对。
您可以在创建图表时设置明确的宽度,但这会使图表无法响应调整大小,这可能不是您想要的。
我建议在 tab2 上使用点击处理程序来检查这种确切情况,并仅在图表可见且与其容器大小不同时才调用 chart.render():
window.onload = function () {
$("#cp_tab2").on("click", function() {
if ($("#chartContainer").is(":visible") && $("#chartContainer canvas").width() !== $("#chartContainer").width()) {
chart.render();
}
});
var chart = new CanvasJS.Chart("chartContainer", {
zoomEnabled: false,
// etc.
我在你的 fiddle 上试过了,它解决了这个问题。看我的fork of your jsFiddle.有了这个工作。
关于javascript - CanvasJS 图形倾斜直到缩放级别改变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32872620/
我是初学者,我正在做一些练习来熟悉 CALayer ... 我只是想知道如何“倾斜”(或倾斜)CALayer 45° 角? 谢谢。 最佳答案 CALayers 有一个属性 affineTransfor
无法理解如何制作this trick或 this与CSS。我的意思是标题和标志。这条线不直。它们是倾斜的/倾斜的边界。能否请您举个例子或只是举例说明这是可行的? 最佳答案 看看https://jsfi
如何倾斜图像?例如,每个角都有一个 CGPoint,其坐标为 - p1、p2、p3、p4。然后,我需要设置 - p4.x+=50,p4.y+=30。因此这个角 (p4) 应该在 2D 透视中拉伸(st
我想弄清楚如何通过仅使用 css 来实现元素底部的跟随边框,并使其尽可能对跨浏览器友好 示例代码,带有标准边框 .object { width: 200px; height: 45p
我正在尝试使用 CSS transform 来倾斜 Bootstrap 导航 li,我可以做到这一点,但是当我尝试扭转内部链接上的倾斜时,li 倾斜也会反转回来。我不知道为什么。我试着做这里接受的答案
这个问题在这里已经有了答案: CSS: Set a background color which is 50% of the width of the window (14 个答案) 关闭 7 年前
我已经创建了一个预定的 div 来与我的导航栏一起使用,但是它弄乱了网站的其余格式。导航栏位于右上角,倾斜的 div 位于其下方,但它弄乱了网页上的所有其他内容。我一直在尝试一切都无济于事。 http
你好,我想像这里的附图一样对步骤菜单进行风格化。我该如何风格化这个?主要问题是菜单右侧的边框。 检查我的 JSFiddle URL https://jsfiddle.net/hcx1pv8x/ , 不
我正在尝试使用 HTML5 在 javascript 中倾斜 svg 元素,例如: 中的矩形元素是倾斜的,但 rect 元素也向右移动(不需要),我尝试手动设置位置使用 transform
目前我对应该倾斜的容器使用clip-path。 .box { height: 150px; line-height: 150px; text-align: center; backgr
我有一个相机从上方指向禅宗花园。然而,相机固定在侧面而不是直接在板的上方。结果,图像看起来像这样(注意矩形的倾斜形状): 有没有办法处理图像,使沙子区域看起来或多或少像一个完美的正方形? cap =
我正在尝试使用倾斜 350 度的 UIScrollview,我首先想到的是使用变换属性,滚动上的倾斜起作用了,但现在滚动上的所有内容看起来都不对,当我谈论所有内容时,我指的是位置和这个卷轴的所有 ch
我需要将我的应用程序升级到 Rails 3.2.16,当时我做了 bundle update rails它给了我以下错误。 Bundler could not find compatible vers
我正在尝试运行 rake db:migrate在本地,但我收到以下错误: Gem::LoadError: You have already activated rake 10.2.2, but you
很难用语言表达我想要完成的事情,所以请查看这张照片作为示例: 如您所见,我希望创建一个带有图案背景的倾斜 div(简单),但另一部分,即倾斜被半遮住的部分,也必须有背景图像。我想到了很多不同的想法,并
假设,我想将两个二维数组添加到第三个二维数组中。 我正在使用以下代码: cudaMallocPitch((void**)&device_a, &pitch, 2*sizeof(int),2); cud
很难用语言表达我想要完成的事情,所以请查看这张照片作为示例: 如您所见,我希望创建一个带有图案背景的倾斜 div(简单),但另一部分,即倾斜被半遮住的部分,也必须有背景图像。我想到了很多不同的想法,并
我刚刚遇到了这种附加字符串的变体,其中包含存储在变量中的值,这是我以前从未见过的。谁能帮我解释一下这是怎么回事? 这是我遇到的情况: var fruit = "banana"; $main = $('
假设,我想将两个二维数组添加到第三个二维数组中。 我正在使用以下代码: cudaMallocPitch((void**)&device_a, &pitch, 2*sizeof(int),2); cud
我正在尝试分析在 Windows 上运行的 Java UI 应用程序的 CPU 使用率。我将它连接到 VisualVM,但看起来 CPU 使用率最高的是 sum.rmi.transport.tcp.T
我是一名优秀的程序员,十分优秀!