Fixed horizontal and vertical line drawing.

This commit is contained in:
Alexis Lahouze 2013-01-13 01:14:58 +01:00
parent ec40240bcc
commit b1c83a53aa
2 changed files with 20 additions and 17 deletions

View File

@ -145,6 +145,7 @@
<script type="text/javascript" src="jqplot/plugins/jqplot.ohlcRenderer.min.js"></script> <script type="text/javascript" src="jqplot/plugins/jqplot.ohlcRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.pieRenderer.min.js"></script> <script type="text/javascript" src="jqplot/plugins/jqplot.pieRenderer.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.highlighter.min.js"></script> <script type="text/javascript" src="jqplot/plugins/jqplot.highlighter.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/jqplot.canvasOverlay.min.js"></script>
<script type="text/javascript" src="js/entries.js"></script> <script type="text/javascript" src="js/entries.js"></script>
</body> </body>

View File

@ -379,18 +379,9 @@ drawChart = function(entries, element) {
$(element).html(""); $(element).html("");
if(entries && entries.length > 0) { if(entries && entries.length > 0) {
var day = 24 * 60 * 60 * 1000;
var lastDate = new Date(Date.parse(entries[entries.length -1][0]).valueOf() + 1 * day);
var firstDate = new Date(Date.parse(entries[0][0]).valueOf() - 1 * day);
var chartValues = [[], []]; var chartValues = [[], []];
// For the '0' line. chartValues[0] = entries;
chartValues[0].push(
[new Date(firstDate.valueOf()).toString(), 0],
[new Date(lastDate.valueOf()).toString(), 0]);
chartValues[1] = entries;
// plot chart // plot chart
window.chart = $.jqplot(element.id, chartValues, { window.chart = $.jqplot(element.id, chartValues, {
@ -411,16 +402,27 @@ drawChart = function(entries, element) {
}, },
series: [{ series: [{
linePattern: "dashed",
lineWidth: 1,
color: "red",
showMarker: false
},{
renderer:$.jqplot.OHLCRenderer, renderer:$.jqplot.OHLCRenderer,
color: "blue", color: "blue",
lineWidth: 3, lineWidth: 3,
rendererOptions:{ rendererOptions:{}
}}], }],
canvasOverlay: {
show: true,
objects: [{
dashedHorizontalLine: {
name: "zero",
y: 0,
lineWidth: 1,
color: "red"
}},
{ dashedVerticalLine: {
name: "today",
x: new Date(),
lineWidth: 1,
color: "gray"
}}]
}
}); });
} else { } else {
window.chart = null; window.chart = null;