From 9132284b778bfd8c94b0c6e742225464e8199503 Mon Sep 17 00:00:00 2001
From: Sigve Kvalsvik
Date: Thu, 24 May 2018 12:01:15 +0200
Subject: [PATCH] #1502: Remove HighStock imports as it is no longer needed
---
app/components/Exchange/DepthHighChart.jsx | 69 ++++----------------
app/components/Exchange/Exchange.jsx | 6 +-
app/components/Explorer/BlocktimeChart.jsx | 4 +-
app/components/Explorer/TransactionChart.jsx | 4 +-
4 files changed, 19 insertions(+), 64 deletions(-)
diff --git a/app/components/Exchange/DepthHighChart.jsx b/app/components/Exchange/DepthHighChart.jsx
index a94af954ae..90f60c1d11 100644
--- a/app/components/Exchange/DepthHighChart.jsx
+++ b/app/components/Exchange/DepthHighChart.jsx
@@ -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";
@@ -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",
@@ -179,7 +138,7 @@ class DepthHighChart extends React.Component {
${counterpart.translate("exchange.price")}: |
${utils.format_number(
- this.x / power,
+ this.x,
base.get("precision")
)} ${baseSymbol}/${quoteSymbol} |
@@ -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",
@@ -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
@@ -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: {
@@ -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: {
@@ -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,
@@ -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)
};
}
@@ -456,7 +411,7 @@ class DepthHighChart extends React.Component {
)}
{flatBids || flatAsks || flatCalls ? (
-
+
) : null}
);
@@ -492,7 +447,7 @@ class DepthHighChart extends React.Component {
) : null}
{flatBids || flatAsks || flatCalls ? (
-
+
) : null}
diff --git a/app/components/Exchange/Exchange.jsx b/app/components/Exchange/Exchange.jsx
index 64595dfa98..8e7fcaa84a 100644
--- a/app/components/Exchange/Exchange.jsx
+++ b/app/components/Exchange/Exchange.jsx
@@ -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 = {
diff --git a/app/components/Explorer/BlocktimeChart.jsx b/app/components/Explorer/BlocktimeChart.jsx
index c95567f8b1..223042ae21 100644
--- a/app/components/Explorer/BlocktimeChart.jsx
+++ b/app/components/Explorer/BlocktimeChart.jsx
@@ -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";
@@ -148,7 +148,7 @@ class BlocktimeChart extends React.Component {
};
return blockTimes.length ? (
-
+
) : null;
}
}
diff --git a/app/components/Explorer/TransactionChart.jsx b/app/components/Explorer/TransactionChart.jsx
index a9793ab965..330d4177ed 100644
--- a/app/components/Explorer/TransactionChart.jsx
+++ b/app/components/Explorer/TransactionChart.jsx
@@ -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 {
@@ -155,7 +155,7 @@ class TransactionChart extends React.Component {
};
return trxData.length ? (
-
+
) : null;
}
}