当打开错误栏时,图形中断.还有注解没有显示
Dygraphs breaking when turning on Errorbar. Also annotations not showing
我真的很喜欢dygraphs中的errorBar功能,但我似乎不能让它工作。图形正常显示,但如果我将errorBars更改为true,则不再绘制图形。
注释也没有显示。当我"硬编码"数据时,我能够得到这项工作,但现在看来,我把它放入一个数组,它不再工作了。
function nameAnnotation(ann) {
return "(" + ann.series + ", " + ann.x + ")";
};
var data = [];
data.push([new Date("2007/01/01"),10000,1]);
data.push([new Date("2007/01/02"),9463.777815,16]);
data.push([new Date("2007/01/03"),8748.659709,31]);
data.push([new Date("2007/01/04"),7779.545394,46]);
data.push([new Date("2007/01/05"),6846.280611,61]);
data.push([new Date("2007/01/06"),6042.265704,76]);
data.push([new Date("2007/01/07"),5052.064845,91]);
data.push([new Date("2007/01/08"),4089.830899,106]);
data.push([new Date("2007/01/09"),3195.631158,121]);
data.push([new Date("2007/01/10"),2541.901849,136]);
data.push([new Date("2007/01/11"),1805.774559,151]);
data.push([new Date("2007/01/12"),1167.31813,166]);
data.push([new Date("2007/01/13"),433.566787,181]);
data.push([new Date("2007/01/14"),-475.4670651,196]);
data.push([new Date("2007/01/15"),-1171.779711,211]);
data.push([new Date("2007/01/16"),5000,226]);
data.push([new Date("2007/01/17"),4091.462451,241]);
data.push([new Date("2007/01/18"),3386.055666,256]);
data.push([new Date("2007/01/19"),2728.37301,271]);
data.push([new Date("2007/01/20"),2167.424525,286]);
data.push([new Date("2007/01/21"),1483.230149,301]);
data.push([new Date("2007/01/22"),917.4477079,316]);
data.push([new Date("2007/01/23"),179.2235937,331]);
data.push([new Date("2007-01-24"),-625.1312787,346]);
data.push([new Date("2007/01/25"),-1209.343528,361]);
data.push([new Date("2007/01/26"),-1832.497902,376]);
data.push([new Date("2007/01/27"),-2426.93031,391]);
data.push([new Date("2007/01/28"),-2940.290957,406]);
data.push([new Date("2007/01/29"),-3745.675041,421]);
data.push([new Date("2007/01/30"),-4412.335834,436]);
data.push([new Date("2007/01/31"),-5303.819068,451]);
g = new Dygraph(
document.getElementById("graphdiv"),
data
,
{
labels: [ "Date", "Series1", "Error" ],
//errorBars: true,
axisLineColor: "red",
sigma: 2.0
}
);
g.ready(function() {
g.setAnnotations([
{
series: "Series1",
icon: 'images/Money.png',
width: 35,
height: 45,
x: "2007/01/01",
shortText: "P",
text: "Pay Day"
},
{
series: "Series1",
icon: 'images/Money.png',
width: 35,
height: 45,
x: "2007/01/16",
shortText: "P",
text: "Pay Day"
},
{
series: "Series1",
icon: 'images/dollarsign.png',
width: 18,
height: 20,
x: "2007/01/14",
shortText: "O",
text: "Possible Cash Shortage"
},
{
series: "Series1",
icon: 'images/dollarsign.png',
width: 18,
height: 20,
x: "2007/01/24",
text: "Possible Cash Shortage"
},
{
series: "Series1",
icon: 'images/bill.png',
width: 18,
height: 20,
x: "2007/01/13",
text: "Car Insurance Payment"
},
{
series: "Series1",
icon: 'images/bill.png',
width: 18,
height: 20,
x: "2007/01/23",
text: "Car Loan Payment"
}
]);
});
我不确定这是否是您想要的效果,但是看看文档 (http://dygraphs.com/tests/steps.html)中的示例,您可以看到为errorBars
设置数据的正确方法
与其将数据格式化为:[new Date("2007/01/01"),10000,1]
,不如将其设置为:
[new Date("2007/01/01"),[10000,1]]
标签设置
labels: [ "Date", "Series1" ]
就注释而言…同样,这些设置是错误的。如果您查看它们是如何设置的,就会发现它使用了选项内部的Dygraph绘制回调函数。注释的示例用法:
drawCallback: function(g) {
var ann = g.annotations();
var html = "";
for (var i = 0; i < ann.length; i++) {
var name = nameAnnotation(ann[i]);
html += name + " : " + (ann[i].shortText || '(icon)') + "<br/>";
}
document.getElementById("ann").innerHTML = html;
}
请参阅以下文档和示例文件了解正确使用方法:
http://jsfiddle.net/eM2Mg/7144/http://dygraphs.com/options.html注释
相关文章:
- 从桌面读取python文件时高亮显示代码
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何在生成下载文件时显示加载动画
- React重新渲染但未显示正确的组件
- nodejs-expressjs上传图像并显示它们
- 高亮显示与数组字符串一起使用时文本插件中断
- jQuery显示/隐藏返回未定义的、中断的插件
- 为什么“<br>"显示而不是引起中断
- Javascript 显示复选框值与值中的空格中断
- 显示语法错误的 JavaScript 中断标签
- HTML 按钮在不中断脚本的情况下显示文本
- 嵌套循环中出现意外中断;t显示在调试器中
- Jasny-Bootstrap显示菜单中断了导航栏折叠和导航栏切换功能
- 当打开错误栏时,图形中断.还有注解没有显示
- 设置xAxis.在两点高程图中显示最小中断区域
- 如何避免在JavaScript代码中断并抛出异常时显示angular标记
- 当我添加按钮时,jQuery幻灯片显示中断
- 当选择Start等于零时高亮显示时,代码中断
- CSS显示:无&JS.show()中断JQuery和AjaxToolkit日期选择器
- 如何在 AJAX 的成功中中断执行和显示错误