Closed danielkrizian closed 10 years ago
Arrow annotations now available (run /examples/ohlc-trades.R
)
Works when opened in the browser with this button in the RStudio Viewer pane:
Doesn't work within RStudio Viewer:
@timelyportfolio , any idea why? I suspect it could have something to do with using g.ready()
in the new script template, which is a way of telling the dygraph
to do something after chart finished rendering:
<script>
if (typeof gs === 'undefined') { var gs = [] };
if (typeof blockRedraw === 'undefined') { var blockRedraw = false };
(function(){
var params = {{{ chartParams }}};
gs.push(new Dygraph(
document.getElementById( '{{chartId}}' ),
_.unzip(params.data),
params.options
));
for (var i = 0; i < gs.length; i++) {
var g = gs[i];
g.ready(function () {
var labels = g.getLabels();
g.setAnnotations(_.map(params.options.annotations, function(annotation) {
if (_.indexOf(labels, annotation.series) === -1) {
if (_.isNumber(annotation.series)) {
annotation.series = labels[annotation.series];
}
}
return annotation;
}));
});
}
})();
</script>
Interesting and wonder if might be part of the same issue why nvd3 do not work. Unfortunately I do not know how to debug in RStudio viewer, so not sure how to attack this.
There is some debugging environment for the RStudio Viewer under right-click-> Inspect
:
Perhaps @ramnathv has some leads on this?
@timelyportfolio , ( @ramnathv ) : FYI the above commit https://github.com/danielkrizian/rChartsDygraphs/commit/b22e2af93e1caad9ae55b83ca8264e39d390249e , could be also possibly solving the nvd3
troubles you mentioned.
Test arrow annotations on the graph symbolizing trade timings, direction and profitability.
Existing dygraph functionality: https://github.com/danielkrizian/dygraphs/blob/canvas-annotations/tests/canvas-annotation.html