- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图显示一个小值的烛台,但我在图表上看不到蜡烛。
这是一个例子:
HTML:
<div class="graphs">
<div id="chartEURUSDContainer" style="height: 331px; min-width: 611px"></div>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
Javascript:
$(function () {
var jsonData = [{"LastModification":"04:18:45","Symbol":"EURUSD","Bid":"1.33132","Ask":"1.33157","High":"1.33336","Low":"1.33007","Direction":"0","InserTime":"\/Date(1358760060933)\/"},{"LastModification":"04:20:05","Symbol":"EURUSD","Bid":"1.33151","Ask":"1.33174","High":"1.33336","Low":"1.33007","Direction":"0","InserTime":"\/Date(1358760140625)\/"},{"LastModification":"04:21:25","Symbol":"EURUSD","Bid":"1.3312","Ask":"1.33144","High":"1.33336","Low":"1.33007","Direction":"1","InserTime":"\/Date(1358760220731)\/"},{"LastModification":"04:22:48","Symbol":"EURUSD","Bid":"1.33115","Ask":"1.33141","High":"1.33336","Low":"1.33007","Direction":"-1","InserTime":"\/Date(1358760300387)\/"},{"LastModification":"04:23:48","Symbol":"EURUSD","Bid":"1.33107","Ask":"1.33132","High":"1.33336","Low":"1.33007","Direction":"-1","InserTime":"\/Date(1358760361033)\/"},{"LastModification":"04:25:08","Symbol":"EURUSD","Bid":"1.33139","Ask":"1.33164","High":"1.33336","Low":"1.33007","Direction":"0","InserTime":"\/Date(1358760440193)\/"},{"LastModification":"04:26:28","Symbol":"EURUSD","Bid":"1.33202","Ask":"1.33222","High":"1.33336","Low":"1.33007","Direction":"1","InserTime":"\/Date(1358760520037)\/"},{"LastModification":"04:27:48","Symbol":"EURUSD","Bid":"1.33212","Ask":"1.33238","High":"1.33336","Low":"1.33007","Direction":"-1","InserTime":"\/Date(1358760600163)\/"}]
var data = [];
fillData();
function fillData() {
for (i = 0; i < jsonData.length; i++) {
data.push([
parseInt(jsonData[i].InserTime.substr(6)),
jsonData[i].Ask ,
jsonData[i].High ,
jsonData[i].Low ,
jsonData[i].Bid
]);
}
CreateChart();
}
function CreateChart() {
// create the chart
chart = new Highcharts.StockChart({
chart: {
renderTo: 'chartEURUSDContainer',
type: 'candlestick',
marginRight: 10,
},
rangeSelector : {
enabled: false
},
scrollbar : {
enabled: false
},
navigator : {
enabled: false
},
series : [{
type : 'candlestick',
color: '#00FF00',
name : 'Currency Rates',
data : data,
}]
});
}
});
最佳答案
您应该使用 parseFloat() 将字符串更改为 Ask/High 值的数字。
data.push([
parseInt(jsonData[i].InserTime.substr(6)),
parseFloat(jsonData[i].Ask),
parseFloat(jsonData[i].High),
parseFloat(jsonData[i].Low),
parseFloat(jsonData[i].Bid)]);
这是一个完整的例子:
HTML:
<div class="graphs">
<div id="chartEURUSDContainer" style="height: 331px; min-width: 611px"></div>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"
type="text/javascript"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
Javascript:
$(function () {
var jsonData = [{
"LastModification": "04:18:45",
"Symbol": "EURUSD",
"Bid": "1.33132",
"Ask": "1.33157",
"High": "1.33336",
"Low": "1.33007",
"Direction": "0",
"InserTime": "\/Date(1358760060933)\/"
}, {
"LastModification": "04:20:05",
"Symbol": "EURUSD",
"Bid": "1.33151",
"Ask": "1.33174",
"High": "1.33336",
"Low": "1.33007",
"Direction": "0",
"InserTime": "\/Date(1358760140625)\/"
}, {
"LastModification": "04:21:25",
"Symbol": "EURUSD",
"Bid": "1.3312",
"Ask": "1.33144",
"High": "1.33336",
"Low": "1.33007",
"Direction": "1",
"InserTime": "\/Date(1358760220731)\/"
}, {
"LastModification": "04:22:48",
"Symbol": "EURUSD",
"Bid": "1.33115",
"Ask": "1.33141",
"High": "1.33336",
"Low": "1.33007",
"Direction": "-1",
"InserTime": "\/Date(1358760300387)\/"
}, {
"LastModification": "04:23:48",
"Symbol": "EURUSD",
"Bid": "1.33107",
"Ask": "1.33132",
"High": "1.33336",
"Low": "1.33007",
"Direction": "-1",
"InserTime": "\/Date(1358760361033)\/"
}, {
"LastModification": "04:25:08",
"Symbol": "EURUSD",
"Bid": "1.33139",
"Ask": "1.33164",
"High": "1.33336",
"Low": "1.33007",
"Direction": "0",
"InserTime": "\/Date(1358760440193)\/"
}, {
"LastModification": "04:26:28",
"Symbol": "EURUSD",
"Bid": "1.33202",
"Ask": "1.33222",
"High": "1.33336",
"Low": "1.33007",
"Direction": "1",
"InserTime": "\/Date(1358760520037)\/"
}, {
"LastModification": "04:27:48",
"Symbol": "EURUSD",
"Bid": "1.33212",
"Ask": "1.33238",
"High": "1.33336",
"Low": "1.33007",
"Direction": "-1",
"InserTime": "\/Date(1358760600163)\/"
}]
var data = [];
fillData();
function fillData() {
for (i = 0; i < jsonData.length; i++) {
data.push([
parseInt(jsonData[i].InserTime.substr(6)),
parseFloat(jsonData[i].Ask),
parseFloat(jsonData[i].High),
parseFloat(jsonData[i].Low),
parseFloat(jsonData[i].Bid)]);
}
CreateChart();
}
function CreateChart() {
// create the chart
chart = new Highcharts.StockChart({
chart: {
renderTo: 'chartEURUSDContainer',
type: 'candlestick',
marginRight: 10,
},
rangeSelector: {
enabled: false
},
scrollbar: {
enabled: false
},
navigator: {
enabled: false
},
series: [{
type: 'candlestick',
color: '#00FF00',
name: 'Currency Rates',
data: data,
}]
});
}
});
关于javascript - 如何使用 Highcharts 显示小值的烛台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14436013/
在我看来,这似乎是一件非常微不足道的事情,我让它在 Android 上运行,但在 iOS 上不起作用,即使在彻底阅读了之前的问题之后也是如此...... 无论如何,我只是想创建一个历史价格数据的组合图
下午好 我想看看你们中是否有人可以帮助我在几分钟内制作出蜡烛图。我设法在几天内将它们绘制成图表,但我不知道如何在几分钟内完成。 附加代码。 import numpy as np import matp
我目前正在制作类似于 this 的图表使用 Highcharts 根据我的观察,柱形和烛台图表仅当我将鼠标悬停在框本身上时才会触发mouseover,而折线 或面积 图表将在图表上的任何位置显示它们,
看了他们的documentation关于这方面的信息很少。 我基本上想在图表的开头和结尾显示一个完整的蜡烛图,而不是现有的半条柱(水平显示蜡烛条的一半)。我可以选择调整我的 JSON 数据并添加一个假
我看过 docs for combo charts并且能够将带有一条线的条形图重现为不同的系列。但是,我如何获得带有不同系列线条的烛台图表? 当我尝试时,出现错误 Last domain does n
我正在尝试使用 Matplotlib 绘制烛台图表,其中包含我为 REST API 调用获取的数据。但是,由于调用使用了唯一的访问 token ,我已经下载了示例数据并将其加载到 csv 中以解决此问
我需要每 5 分钟绘制一次交易数据(一根蜡烛) 这是我目前所拥有的: from matplotlib.finance import candlestick2_ohlc fig, ax = plt.su
我是一名优秀的程序员,十分优秀!