- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
场景:
我能够使用 Zingchart 获取状态图,使用 stacked hbar 并绘制元素状态不变的数据间隔:
但是,我希望在提供时间的轴上有更多的分辨率。
问题:
我无法增加y 轴
中刻度 的数量(这是一个堆叠的hbar 图,所以通常x 轴
实际上是 y 轴
)。
如果我在 scaleY
字段中引入 step:"1hour",
,我将返回到纪元 0,这就是我获得的结果:
问题:
我做错了什么?我想要:
data-customValue
作为间隔开始/结束的实际日期?在代码中,我从纪元 0 跳到我开始拥有数据的时间,并定义 minValue
以绘制为我拥有数据的第一个纪元减去一秒。这是工作代码(未定义 step
属性):
<!DOCTYPE html>
<html>
<head>
<script src="/home/eballes/Work/backup/zingchart_test/zingchart_2.3.3/zingchart.min.js"></script>
<script>
zingchart.MODULESDIR = "/home/eballes/Work/backup/zingchart_test/zingchart_2.3.3/modules/";
</script>
<style></style>
</head>
<body>
<div id='myChart'></div>
<script>
var myConfig = {
type: "hbar",
utc:true,
title: {
text: 'Status'
},
scaleY:{
transform:{
type:'date',
all:"%d/%M/%Y\n%H:%i:%s",
},
minValue:1456693864000,
zooming:true,
label:{
"text": "Time",
},
tick:{
"line-color":"black",
"line-width":"2px",
"size":8,
},
maxItems:10,
itemsOverlap:true,
item:{
"font-size":10
},
},
scaleX:{
label:{
"text": "Item",
},
},
plot:{
stacked:true,
exact:false,
barWidth:10,
rules:[
{
rule:'%data-customValue == 0',
alpha:0, // Transparent
},
{
rule:'%data-customValue == 1',
backgroundColor:'#0000FF' // Dark Blue
},
{
rule:'%data-customValue == 2',
backgroundColor:'#00FFFF' // Light Blue
},
{
rule:'%data-customValue == 3',
backgroundColor:'#FF7F50' // Orange
},
{
rule:'%data-customValue == 4',
backgroundColor:'#FFFF00' // Yellow
},
{
rule:'%data-customValue == 5',
backgroundColor:'#EE82EE' // Purple
},
{
rule:'%data-customValue == 6',
backgroundColor:'#00FF00' // Green
},
{
rule:'%data-customValue == 7',
backgroundColor:'#FF0000' // Red
},
]
},
tooltip:{
jsRule:"CustomFn.formatTooltip()",
},
series : [
{
values : [
[1,1456693864000],
[2,1456693864000],
.... // From 1 to 36
[36,1456693864000],
],
'data-customValue':[0,0,0,0,0,0,
0,0,0,0,0,0,
0,0,0,0,0,0,
0,0,0,0,0,0,
0,0,0,0,0,0,
0,0,0,0,0,0],
},
{
values : [
[11, 32000], [12, 10270000], [14, 5033000], [18, 79000], [20, 43000], [24, 76000], [26, 4043000], [8, 33000], [9, 63000],
],
'data-customValue':[2, 6, 6, 0, 1, 2, 6, 1, 0, ],
},
{
values : [
[14, 3000], [19, 20000], [26, 1000], [8, 86000], [9, 13000],
],
'data-customValue':[2, 2, 2, 0, 1, ],
},
// All intervals
]
};
CustomFn = {};
CustomFn.formatTooltip = function(p){
var hours = Math.floor(p.value / 3600000);
var minutes = Math.floor((p.value % 3600000) / 60000);
var seconds = (p.value % 60000)/1000;
var tooltipText = "Item: " + p.scaletext + "\nDuration: ";
var hoursText = (hours == 0) ? "" : (hours + "h ");
var minutesText = (minutes == 0) ? "" : (minutes + "m");
var secondsText = (seconds == 0) ? "" : (seconds + "s");
tooltipText = tooltipText + hoursText + minutesText + secondsText + "\n";
tooltipText = tooltipText + "Value: " + p['data-customValue'];
var alpha = 70;
// We don't want any tooltip for the time-jump
if (hours > 300000) {
tooltipText = "";
alpha = 0;
}
return {
text : tooltipText,
backgroundColor : "#222",
alpha: alpha,
}
};
zingchart.render({
id : 'myChart',
data : myConfig,
height: 670,
width: '100%'
});
</script>
</body>
</html>
这是包含整个示例的 Plunker 的链接,但不起作用。如果您删除行 step:"1hour"
,它将起作用。
有趣的是,step:20
工作正常。但我更愿意以正常的方式进行我的步数,比如每小时。
注意:只是为了提供更多上下文,这个问题是另一个 previous 问题的延续。
最佳答案
完全披露,我是 ZingChart 团队的成员。
第一个问题是
step:'1hour'
该字符串值被我们的库解释为值 0。这是因为字符串“1hour”不匹配我们的任何关键字,也不计算为数字类型。我们不是简单地使用 parseInt,因此它的计算结果不会为 1。
如果您想要一个小时的步数,您可以以毫秒为单位计算步数。这记录在我们的 scales page 中。 .
step:3600000
为了显示刻度值,我们有一个 tokens列表,它允许您将比例中的值添加到工具提示中。在您的 customFn.formatTooltip 中,您将添加这一行。
...
tooltipText = tooltipText + "Value: " + p['data-customValue'];
tooltipText += '<br> %vv'
%vv
在我们的 tokens 中列表并将从 y 轴上获取转换后的值。如果您执行了 %vt
,它将为您提供毫秒值。
关于javascript - 在 Zingchart 中定义 'step' 属性会导致图形不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38033612/
在我用 OpenCascade 生成的 STEP 文件中,我可以看到: #58 = VERTEX_POINT('',#59); #59 = CARTESIAN_POINT('',(-0.5,-0.5,
这个问题在这里已经有了答案: How to use Firebug's debugger functions? (1 个回答) 关闭 8 年前。 我是 FireBug 调试器的新手,谁能告诉我什么是
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我想知道 Eclipse IDE 中是否存在任何功能,可以在执行 selenium 脚本 时“从步骤进行调试” “单步执行”、“单步执行”。 “QTP” 和大多数专有功能自动化工具中都提供此功能。我假
我正在寻找 .stp/.step 文件的某种规范、文档、解释等。 更多的是关于每行包含哪些信息而不是一般信息。 我似乎无法自己弄清楚每个值的含义。 有谁知道一些关于 STEP 文件的好读物? 我已经搜
我写了下面的代码: Mockup TOPdesk
我正在尝试研究 java String 类中的方法如何工作,因此我创建了一些调用该 String 类方法的自定义代码。 如您所见,我在自己的代码中设置了一个断点,并且在 java String 类源代
我有某些功能,需要我进行一个 api 调用来检索第二个 api 调用中使用的某个 id,逻辑上它看起来像这样: componentWillMount () { this.props.functio
在本地使用 AppEngine(即使用 dev_appserver.py)时,是否可以进行逐步调试?使用 logging.info() 或类似的函数来显示代码中所有变量的值并确定错误的位置是一种过时的
我正在使用 JQuery Steps,它非常好。但事实证明有些事情很棘手。 假设我在第 2 步。根据我在表单中选择的内容,我可能想在单击“下一步”时直接跳到第 4 步,并且进一步禁用第 3 步 anc
我已经包含了 jquery-steps 插件。 如何更改按钮文本? 现在它说“完成”我想把它改成“去” 谢谢 最佳答案 查看以下内容 link .您可以在初始化时更改所有标签。 var setting
在(现已弃用的) Angular 场景测试运行器中,有一个选项可以创建一个 runner.html 页面,该页面将在 iFrame 中运行测试,同时在主页中逐步报告进度。 有没有办法获得类似的 Pro
我有使用标签 的 primefaces 步骤像下面这样: 结果是这样的: 我可以点击步骤 1,但不能点击步骤 3 和 4。如何为所有步骤启用点击? 最佳答案 哇,
给定一个使用分区的 Spring Batch 作业,是否可以有多个分区步骤? 例如: 在上面的示例中,是否可以将另一个分区
假设您要从数据库中获取一条记录,该记录返回大量数据并且需要多次连接。 所以我的问题是,使用单个查询来检查数据是否存在并在存在时获取结果是否更好?或者做一个更简单的查询,检查数据是否存在然后id记录是否
我如何创建一个具有整数输入类型而不是字符串的任务,例如我想启动一个状态机: "SomeStage": { "Comment": "Getting busy
我还没有看到有人问过这个问题——尽管我确实阅读了大约 100 个关于类似主题的 jQuery 步骤——似乎没有一个能解决我的问题。 我正在使用 jQuery-steps 并希望在第一步完成后添加一个“
我想知道是否可以在 Laravel 5.3 中逐个迁移。 我无法使 --step 选项正常工作,文档仅提及此选项与 rollback 或 refresh 一起使用命令。 // this works p
我已按照 AWS 文档中的步骤在本地设置和运行 AWS Step Functions:https://docs.aws.amazon.com/step-functions/latest/dg/sfn-
我已按照 AWS 文档中的步骤在本地设置和运行 AWS Step Functions:https://docs.aws.amazon.com/step-functions/latest/dg/sfn-
我是一名优秀的程序员,十分优秀!