Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 315 - Add Chart Clamp To Settings Dropdown #373

Merged
merged 2 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@
"fib": "Draw Fibonacci retracement",
"trendline": "Draw trend line",
"volume": "Show volume chart",
"clamp_chart": "Clamp chart edge",
"period": "Period",
"height": "Chart height",
"price_title": "Price indicators",
Expand Down
3 changes: 3 additions & 0 deletions web/app/components/Exchange/Exchange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ class Exchange extends React.Component {
let isNullAccount = currentAccount.get("id") === "1.2.3";

const showVolumeChart = this.props.viewSettings.get("showVolumeChart", true);
const enableChartClamp = this.props.viewSettings.get("enableChartClamp", true);

if (quoteAsset.size && baseAsset.size && currentAccount.size) {
base = baseAsset;
Expand Down Expand Up @@ -1122,6 +1123,7 @@ class Exchange extends React.Component {
zoom={this.state.currentPeriod}
tools={tools}
showVolumeChart={showVolumeChart}
enableChartClamp={enableChartClamp}

buckets={buckets} bucketSize={bucketSize}
currentPeriod={this.state.currentPeriod}
Expand All @@ -1145,6 +1147,7 @@ class Exchange extends React.Component {
onChangeChartHeight={this.onChangeChartHeight.bind(this)}
chartHeight={chartHeight}
onToggleVolume={() => {SettingsActions.changeViewSetting({showVolumeChart: !showVolumeChart});}}
onToggleChartClamp={() => {SettingsActions.changeViewSetting({enableChartClamp: !enableChartClamp});}}
onChangeIndicatorSetting={this._changeIndicatorSetting.bind(this)}
/>
</div>) : (
Expand Down
20 changes: 16 additions & 4 deletions web/app/components/Exchange/PriceChartD3.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class CandleStickChartWithZoomPan extends React.Component {
}

_renderCandleStickChart(chartMultiplier, maCalcs) {
const { height, width, showVolumeChart, indicators } = this.props;
const { height, width, showVolumeChart, indicators, enableChartClamp } = this.props;
const { timeFormatter, volumeFormat, priceFormat, margin, enableTrendLine,
enableFib, calculators } = this.state;
const { positiveColor, negativeColor, axisLineColor, indicatorLineColor } = this._getThemeColors();
Expand Down Expand Up @@ -309,7 +309,7 @@ class CandleStickChartWithZoomPan extends React.Component {

render() {
const { width, priceData, height, ratio, theme, zoom,
indicators, showVolumeChart } = this.props;
indicators, showVolumeChart, enableChartClamp } = this.props;
const { timeFormatter, enableFib, enableTrendLine, margin, calculators } = this.state;
const themeColors = colors[theme];
const { axisLineColor, indicatorLineColor} = themeColors;
Expand Down Expand Up @@ -343,6 +343,7 @@ class CandleStickChartWithZoomPan extends React.Component {
ratio={ratio} width={width - 20} height={height}
seriesName="PriceChart"
margin={margin}
clamp={enableChartClamp}
data={filteredData} calculator={calc}
xAccessor={d => d.date} xScaleProvider={discontinuousTimeScaleProvider}
xExtents={[filteredData[0].date, filteredData[filteredData.length - 1].date]}
Expand Down Expand Up @@ -417,7 +418,8 @@ export default class Wrapper extends React.Component {
np.width !== this.props.width ||
np.leftOrderBook !== this.props.leftOrderBook ||
np.zoom !== this.props.zoom ||
np.showVolumeChart !== this.props.showVolumeChart
np.showVolumeChart !== this.props.showVolumeChart ||
np.enableChartClamp !== this.props.enableChartClamp
);
}

Expand Down Expand Up @@ -559,7 +561,7 @@ export default class Wrapper extends React.Component {
});

/* Tools dropdown */
const settingsOptions = ["volume", "height"].map(i => {
const settingsOptions = ["volume", "height", "clamp_chart"].map(i => {
let content;
switch (i) {
case "height": {
Expand All @@ -586,6 +588,16 @@ export default class Wrapper extends React.Component {
break;
}

case "clamp_chart": {
content = (
<li className="clickable indicator" key={i} onClick={this.props.onToggleChartClamp}>
<input type="checkbox" checked={this.props.enableChartClamp} />
<div><Translate content={`exchange.chart_options.${i}`} /></div>
</li>
);
break;
}

default:{
content = (
<li key={i}>
Expand Down
1 change: 0 additions & 1 deletion web/app/components/Exchange/PriceStat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import cnames from "classnames";
import ReactTooltip from "react-tooltip";

export default class PriceStat extends React.Component {

constructor() {
super();
this.state = {
Expand Down