Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
fix(charts): fix trade arrows for current trades
Browse files Browse the repository at this point in the history
Now the arrows are shown when the trade is inserted.
The arrow colors are similar to fxTrade ones.
  • Loading branch information
albertosantini committed Feb 4, 2016
1 parent 8833ad0 commit a485339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/client/app/charts/charts.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ path.tradearrow {
}

path.tradearrow.buy {
fill: #0000FF;
fill: rgb(114, 213, 255);
}

path.tradearrow.buy-pending {
Expand All @@ -71,7 +71,7 @@ path.tradearrow.buy-pending {
}

path.tradearrow.sell {
fill: #9900FF;
fill: rgb(243, 198, 113);
}

.tradearrow path.highlight {
Expand Down
31 changes: 10 additions & 21 deletions src/client/app/components/charts.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
if (csv && csv.length > 0) {
myInstrument = scope.instrument;
myGranularity = scope.granularity;
myTrades = scope.trades;

refreshChart = drawChart(element[0], csv);

Expand Down Expand Up @@ -90,8 +89,6 @@
lastData.low = lastData.close;
}

myTrades = scope.trades;

refreshChart();
}

Expand Down Expand Up @@ -311,13 +308,6 @@
});

svg.select("g.candlestick").datum(data);
svg.select("g.tradearrow").datum(myTrades.map(function (trade) {
return {
date: new Date(trade.time),
type: trade.side,
price: trade.price
};
}));
svg.select("g.sma.ma-0").datum(sma0Calculator(data));
svg.select("g.sma.ma-1").datum(sma1Calculator(data));
svg.select("g.volume").datum(data);
Expand Down Expand Up @@ -351,17 +341,16 @@

svg.select("g.candlestick").call(ohlc);

var datum = svg.select("g.tradearrow").datum();
svg.select("g.tradearrow").datum()
.splice.apply(datum, [0, datum.length].concat(
myTrades.map(function (trade) {
return {
date: new Date(trade.time),
type: trade.side,
price: trade.price
};
})));
svg.select("g.tradearrow").call(tradearrow);
svg.select("g.tradearrow").remove();
svg.append("g").attr("class", "tradearrow");
myTrades = scope.trades.map(function (trade) {
return {
date: new Date(trade.time),
type: trade.side,
price: trade.price
};
});
svg.select("g.tradearrow").datum(myTrades).call(tradearrow);

// Recalculate indicators and update the SAME array and
// redraw moving average
Expand Down

0 comments on commit a485339

Please sign in to comment.