-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDepthChartContainer.js
73 lines (65 loc) · 2.32 KB
/
DepthChartContainer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import { DepthChart, Loading } from "../components";
var AmCharts = require("@amcharts/amcharts3-react");
class DepthChartContainer extends React.Component {
formatNumber = (val, chart, precision) => {
return AmCharts.formatNumber(
val,
{
precision: precision ? precision : chart.precision,
decimalSeparator: chart.decimalSeparator,
thousandsSeparator: chart.thousandsSeparator
}
);
}
toolTip = (item, graph) => {
const self = this;
var txt;
if (graph.id == "asks") {
txt = "Ask: <strong>" + self.formatNumber(item.dataContext.value, graph.chart, 4) + "</strong><br />"
+ "Total volume: <strong>" + self.formatNumber(item.dataContext.askstotalvolume, graph.chart, 4) + "</strong><br />"
+ "Volume: <strong>" + self.formatNumber(item.dataContext.asksvolume, graph.chart, 4) + "</strong>";
}
else {
txt = "Bid: <strong>" + self.formatNumber(item.dataContext.value, graph.chart, 4) + "</strong><br />"
+ "Total volume: <strong>" + self.formatNumber(item.dataContext.bidstotalvolume, graph.chart, 4) + "</strong><br />"
+ "Volume: <strong>" + self.formatNumber(item.dataContext.bidsvolume, graph.chart, 4) + "</strong>";
}
return txt;
}
render() {
const {
props: {
style, loading, data, title
},
toolTip
} = this;
return (
<div style={style} className={loading ? "depth-chart-container loading" : "depth-chart-container"}>
{
loading &&
<Loading />
}
{
!loading &&
<DepthChart
data={data}
title={title}
tootlTip={toolTip}
/>
}
</div>
)
}
}
DepthChartContainer.propTypes = {
data: PropTypes.array.isRequired,
title: PropTypes.string.isRequired,
}
DepthChartContainer.defaultProps = {
loading: false,
decimalPoints: 4,
style: {}
}
export default DepthChartContainer;