Critical bug | Drawing Objects in the empty space in front of the chart #562

TradingView functionality bug #549
Loading data infinite loop #526
Time scale marks get stale after new bars came #500
When full screen, tools are not shown #457
Bug when drawing a line with its closing end outside the last bar #426
Option to disable border #420
Removing an entry from context menu #412
This commit is contained in:
Eugene
2015-07-01 10:49:32 +03:00
parent 2ce6342882
commit c32ff2135c
40 changed files with 38082 additions and 14958 deletions

186
test.html
View File

@@ -1,15 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>TradingView Charting Library demo</title>
<title>TradingView Charting Library demo -- testing mess</title>
<!-- Fix for iOS Safari zooming bug -->
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="charting_library/charting_library.min.js"></script>
<script type="text/javascript" src="charting_library/datafeed/udf/datafeed.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
@@ -24,7 +26,6 @@
symbol: 'AA',
interval: 'D',
toolbar_bg: '#f4f7f9',
allow_symbol_change: true,
container_id: "tv_chart_container",
// BEWARE: no trailing slash is expected in feed URL
datafeed: new Datafeeds.UDFCompatibleDatafeed("http://demo_feed.tradingview.com"),
@@ -32,11 +33,12 @@
locale: "en",
// Regression Trend-related functionality is not implemented yet, so it's hidden for a while
drawings_access: { type: 'black', tools: [ { name: "Regression Trend" } ] },
indicators_file_name: 'http://e12:9090/indicators.js',
disabled_features: ["use_localstorage_for_settings"],
disabled_features: ["use_localstorage_for_settings", "volume_force_overlay"],
enabled_features: ["move_logo_to_main_pane"],
overrides: {
"mainSeriesProperties.style": 0,
"symbolWatermarkProperties.color" : "#644"
"symbolWatermarkProperties.color" : "#944",
"volumePaneSize": "tiny"
},
studies_overrides: {
"volume.volume.color.0": "#00FFFF",
@@ -61,25 +63,33 @@
{ text: "5d", resolution: "10" },
{ text: "3d", resolution: "10" },
{ text: "2d", resolution: "5" },
{ text: "1d", resolution: "5" },
{ text: "1d", resolution: "5" }
],
charts_storage_url: 'http://saveload.tradingview.com',
client_id: 'tradingview.com',
user_id: 'public_user_id'
user_id: 'public_user',
favorites: {
intervals: ["1D", "3D", "3W", "W", "M"],
chartTypes: ["Area", "Line"]
}
});
var savedWidgetContent = null;
var savedTemplate = null;
widget.onChartReady(function() {
widget.onContextMenu(function(time, price) {
return [{
position: "top",
text: new Date(time * 1000) + "; " + price,
text: new Date(time * 1000).toUTCString() + "; " + price.toFixed(4),
click: function() {
alert(1);
console.log("Custom context menu item clicked");
}
}]
},
{ text: "-", position: "top" },
{ text: "-Objects Tree..." }
];
});
widget.createButton()
@@ -115,38 +125,92 @@
})
.append($('<span>load reference 2</span>'));
widget.createButton()
.attr('title', "russian")
.on('click', function (e) {
widget.setLanguage('ru');
})
.append($('<span>ru</span>'));
widget.createButton()
.attr('title', "english")
.on('click', function (e) {
widget.setLanguage('en');
widget.createStudyTemplate({saveInterval: false}, function(data) {
savedTemplate = data;
});
})
.append($('<span>en</span>'));
.append($('<span>save template (-i)</span>'));
widget.createButton()
.on('click', function (e) {
widget.createStudyTemplate({saveInterval: true}, function(data) {
savedTemplate = data;
});
})
.append($('<span>save template (+i)</span>'));
widget.createButton()
.on('click', function (e) {
if (savedTemplate) {
widget.applyStudyTemplate(savedTemplate);
}
})
.append($('<span>apply template</span>'));
widget.createButton()
.attr('title', "english")
.on('click', function (e) {
widget.setSymbol("F", '2D');
})
.append($('<span>F, 2D</span>'));
widget.createButton()
.on('click', function (e) {
widget.createStudy("Hull MA");
})
.append($('<span>+ Hull MA</span>'));
widget.createButton()
.on('click', function (e) {
widget.createStudy("MA Cross");
widget.clearMarks();
})
.append($('<span>+ MA cross</span>'));
.append($('<span>Clear marks</span>'));
widget.createButton()
.attr('title', "Add item")
.on('click', function (e) {
widget.createStudy("Bollinger Bands", false, false, [
10 + parseInt(Math.random() * 10),
3 + parseInt(Math.random() * 3)
], function (guid) {
console.log(guid);
}
);
})
.append($('<span>+BB</span>'));
widget.createButton({align: "right"})
.attr('title', "Add item")
.on('click', function (e) {
widget.createStudy("Moving Average", false, false, [
10 + parseInt(Math.random() * 10)
], function (guid) {
console.log(guid);
}
);
})
.append($('<span>+MA</span>'));
widget.createButton({align: "right"})
.attr('title', "Add item")
.on('click', function (e) {
widget.createStudy("Moving Average", false, false, [
10 + parseInt(Math.random() * 10)
], function (guid) {
console.log(guid);
},
{"plot.color.0" : "#FF0000"}
);
})
.append($('<span>+MA++</span>'));
widget.createButton({align: "right"})
.attr('title', "Add item")
.on('click', function (e) {
widget.createStudy('Stochastic', false, false, [12, 3, 3], null, {"%d.color" : "#000000", "%k.color" : "#00FF00"});
})
.append($('<span>+Stoch</span>'));
widget.createButton()
.on('click', function (e) {
@@ -154,6 +218,18 @@
})
.append($('<span>new order</span>'));
widget.createButton()
.on('click', function (e) {
widget.removeAllStudies();
})
.append($('<span>rm all studies</span>'));
widget.createButton()
.on('click', function (e) {
widget.removeAllShapes();
})
.append($('<span>rm all shapes</span>'));
widget.onGrayedObjectClicked(function(x) {
alert("You are not permitted to use " + x.name + "(" + x.type + ")");
});
@@ -161,14 +237,64 @@
widget.onIntervalChange(function(x) {
console.log("onIntervalChange: " + x);
});
widget.createButton()
.on('click', function (e) {
widget.setVisibleRange({
from: Date.UTC(2012, 2, 3) / 1000,
to: Date.UTC(2013, 3, 3) / 1000
});
})
.append($('<span>set view</span>'));
widget.createButton()
.on('click', function (e) {
widget.getVisibleRange(function(range) {
console.log(range);
});
})
.append($('<span>get range</span>'));
var position = widget.createPositionLine()
.onReverse(function(text) {
console.log("Position reverse event");
})
.onClose(function(text) {
console.log("Position close event");
})
.setText("PROFIT: 71.1 (3.31%)")
.setQuantity("8.235")
.setLineLength(3);
position.setPrice(position.getPrice() - 2);
var order = widget.createOrderLine()
.onMove(function() {
console.log("Order moved event");
})
.onCancel(function(text) {
console.log("Order cancel event");
})
.setText("STOP: 73.5 (5,64%)")
.setLineLength(3)
.setQuantity("2");
order.setPrice(order.getPrice() - 2.5);
widget.createExecutionShape()
.setText("@1,320.75 Limit Buy 1")
.setTextColor("rgba(255,0,0,0.5)")
.setArrowSpacing(25)
.setArrowHeight(25)
.setArrowColor("#F00")
.setTime(new Date("4 Dec 2014 00:00:00 GMT+0").valueOf() / 1000)
.setPrice(15.5);
});
})
});
</script>
</head>
<body style="margin:0px;">
<body style="margin:0;">
<div id="tv_chart_container"></div>
</body>