Skip to content

Commit

Permalink
#1502: Remove HighStock imports as it is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed May 24, 2018
1 parent adfdcd9 commit 9132284
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 64 deletions.
69 changes: 12 additions & 57 deletions app/components/Exchange/DepthHighChart.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import {PropTypes} from "react";
import ReactHighstock from "react-highcharts/dist/ReactHighstock";
import ReactHighchart from "react-highcharts";
import utils from "common/utils";
import counterpart from "counterpart";
import {cloneDeep} from "lodash-es";
Expand Down Expand Up @@ -101,47 +101,6 @@ class DepthHighChart extends React.Component {
flatCalls = cloneDeep(flat_calls),
flatSettles = cloneDeep(flat_settles);

function findNormalizationPower(power, array) {
while (array[array.length - 1][0] * power < 1) {
power *= 10;
}
return power;
}

function normalizeValues(array) {
if (array.length) {
array.forEach(entry => {
entry[0] *= power;
});
}
}

/*
* Because Highstock does not deal with X axis values below 1, we need to
* normalize the values and use the normalizing factor when displaying the
* values on the chart
*/
let power = 1;
if (flat_bids.length) {
power = findNormalizationPower(power, flat_bids);
} else if (flat_asks.length) {
power = findNormalizationPower(power, flat_asks);
} else if (flat_calls && flat_calls.length) {
power = findNormalizationPower(power, flat_calls);
} else if (flat_settles && flat_settles.length) {
power = findNormalizationPower(power, flat_settles);
}

// Add one more factor of 10 to make sure it's enough
power *= 10;

if (power !== 1) {
normalizeValues(flatBids);
normalizeValues(flatAsks);
normalizeValues(flatCalls);
normalizeValues(flatSettles);
}

let config = {
chart: {
type: "area",
Expand Down Expand Up @@ -179,7 +138,7 @@ class DepthHighChart extends React.Component {
<tr>
<td>${counterpart.translate("exchange.price")}:</td>
<td style="text-align: right">${utils.format_number(
this.x / power,
this.x,
base.get("precision")
)} ${baseSymbol}/${quoteSymbol}</td>
</tr>
Expand Down Expand Up @@ -232,10 +191,10 @@ class DepthHighChart extends React.Component {
labels: {
style: {
color: primaryText
},
formatter: function() {
return this.value / power;
}
// formatter: function() {
// return this.value / power;
// }
},
ordinal: false,
lineColor: "#000000",
Expand Down Expand Up @@ -297,8 +256,8 @@ class DepthHighChart extends React.Component {
}

if (this.props.hasPrediction) {
config.xAxis.min = -0.05 * power;
config.xAxis.max = 1.05 * power;
config.xAxis.min = -0.05;
config.xAxis.max = 1.05;
}

// Add plotlines if defined
Expand All @@ -319,7 +278,7 @@ class DepthHighChart extends React.Component {
color: axisLineColor,
id: "plot_line",
dashStyle: "longdash",
value: this.props.LCP * power,
value: this.props.LCP,
label: {
text: counterpart.translate("explorer.block.call_limit"),
style: {
Expand Down Expand Up @@ -356,7 +315,7 @@ class DepthHighChart extends React.Component {
color: settlementColor,
id: "plot_line",
dashStyle: "solid",
value: feedPrice * power,
value: feedPrice,
label: {
text: counterpart.translate("explorer.block.feed_price"),
style: {
Expand All @@ -380,10 +339,6 @@ class DepthHighChart extends React.Component {

// Add settle orders
if (feedPrice && (flatSettles && flatSettles.length)) {
// flat_settles.forEach(settle => {
// settle[0] *= power;
// });

config.series.push({
name: `Settle ${quoteSymbol}`,
data: flatSettles,
Expand Down Expand Up @@ -423,7 +378,7 @@ class DepthHighChart extends React.Component {
// Add onClick event listener if defined
if (this.props.onClick) {
config.chart.events = {
click: this.props.onClick.bind(this, power)
click: this.props.onClick.bind(this)
};
}

Expand Down Expand Up @@ -456,7 +411,7 @@ class DepthHighChart extends React.Component {
</p>
)}
{flatBids || flatAsks || flatCalls ? (
<ReactHighstock config={config} />
<ReactHighchart config={config} />
) : null}
</div>
);
Expand Down Expand Up @@ -492,7 +447,7 @@ class DepthHighChart extends React.Component {
</span>
) : null}
{flatBids || flatAsks || flatCalls ? (
<ReactHighstock ref="depthChart" config={config} />
<ReactHighchart ref="depthChart" config={config} />
) : null}
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/components/Exchange/Exchange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -804,21 +804,21 @@ class Exchange extends React.Component {
}
}

_depthChartClick(base, quote, power, e) {
_depthChartClick(base, quote, e) {
e.preventDefault();
let {bid, ask} = this.state;

bid.price = new Price({
base: this.state.bid.for_sale,
quote: this.state.bid.to_receive,
real: e.xAxis[0].value / power
real: e.xAxis[0].value
});
bid.priceText = bid.price.toReal();

ask.price = new Price({
base: this.state.ask.to_receive,
quote: this.state.ask.for_sale,
real: e.xAxis[0].value / power
real: e.xAxis[0].value
});
ask.priceText = ask.price.toReal();
let newState = {
Expand Down
4 changes: 2 additions & 2 deletions app/components/Explorer/BlocktimeChart.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactHighstock from "react-highcharts/dist/ReactHighstock";
import ReactHighchart from "react-highcharts";
import {takeRight} from "lodash-es";
import counterpart from "counterpart";

Expand Down Expand Up @@ -148,7 +148,7 @@ class BlocktimeChart extends React.Component {
};

return blockTimes.length ? (
<ReactHighstock ref="chart" config={config} />
<ReactHighchart ref="chart" config={config} />
) : null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/Explorer/TransactionChart.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactHighstock from "react-highcharts/dist/ReactHighstock";
import ReactHighchart from "react-highcharts";
import counterpart from "counterpart";

class TransactionChart extends React.Component {
Expand Down Expand Up @@ -155,7 +155,7 @@ class TransactionChart extends React.Component {
};

return trxData.length ? (
<ReactHighstock ref="trx_chart" config={config} />
<ReactHighchart ref="trx_chart" config={config} />
) : null;
}
}
Expand Down

0 comments on commit 9132284

Please sign in to comment.