From 30df660490226ccfeb23c84efdfdb7a95b8108fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=8B=87=E5=8B=87?= <961245677@qq.com> Date: Thu, 23 Aug 2018 16:02:04 +0800 Subject: [PATCH 1/2] replace default tooltips 'n/a' Enable the ability to Change the init display but 'n/a' --- src/lib/tooltip/SingleValueTooltip.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/tooltip/SingleValueTooltip.js b/src/lib/tooltip/SingleValueTooltip.js index 3c6c04e5c..3a8566d1e 100644 --- a/src/lib/tooltip/SingleValueTooltip.js +++ b/src/lib/tooltip/SingleValueTooltip.js @@ -18,14 +18,14 @@ class SingleValueTooltip extends Component { renderSVG(moreProps) { const { onClick, fontFamily, fontSize, labelFill, valueFill, className } = this.props; - const { xDisplayFormat, yDisplayFormat, xLabel, yLabel, xAccessor, yAccessor } = this.props; + const { xDisplayFormat, yDisplayFormat, xLabel, yLabel, xAccessor, yAccessor,yInitDisplay,xInitDisplay } = this.props; const { displayValuesFor } = this.props; const { chartConfig: { width, height } } = moreProps; const currentItem = displayValuesFor(this.props, moreProps); - const xDisplayValue = isDefined(currentItem) && isDefined(xAccessor(currentItem)) ? xDisplayFormat(xAccessor(currentItem)) : "n/a"; - const yDisplayValue = isDefined(currentItem) && isDefined(yAccessor(currentItem)) ? yDisplayFormat(yAccessor(currentItem)) : "n/a"; + const xDisplayValue = isDefined(currentItem) && isDefined(xAccessor(currentItem)) ? xDisplayFormat(xAccessor(currentItem)) : xInitDisplay; + const yDisplayValue = isDefined(currentItem) && isDefined(yAccessor(currentItem)) ? yDisplayFormat(yAccessor(currentItem)) : yInitDisplay; const { origin: originProp } = this.props; const origin = functor(originProp); @@ -67,6 +67,8 @@ SingleValueTooltip.propTypes = { PropTypes.func ]).isRequired, className: PropTypes.string, + xInitDisplay: PropTypes.string, + yInitDisplay: PropTypes.string, fontFamily: PropTypes.string, fontSize: PropTypes.number, onClick: PropTypes.func, @@ -84,6 +86,8 @@ SingleValueTooltip.defaultProps = { xAccessor: noop, yAccessor: identity, className: "react-stockcharts-tooltip", + xInitDisplay:"n/a", + yInitDisplay:"n/a", }; export default SingleValueTooltip; From b5bca9e79bb85193dedf7aaba1465e0e0b9a46c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=8B=87=E5=8B=87?= <961245677@qq.com> Date: Fri, 14 Sep 2018 10:37:07 +0800 Subject: [PATCH 2/2] Update SingleValueTooltip.js --- src/lib/tooltip/SingleValueTooltip.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/tooltip/SingleValueTooltip.js b/src/lib/tooltip/SingleValueTooltip.js index 3a8566d1e..16d475ed9 100644 --- a/src/lib/tooltip/SingleValueTooltip.js +++ b/src/lib/tooltip/SingleValueTooltip.js @@ -18,7 +18,7 @@ class SingleValueTooltip extends Component { renderSVG(moreProps) { const { onClick, fontFamily, fontSize, labelFill, valueFill, className } = this.props; - const { xDisplayFormat, yDisplayFormat, xLabel, yLabel, xAccessor, yAccessor,yInitDisplay,xInitDisplay } = this.props; + const { xDisplayFormat, yDisplayFormat, xLabel, yLabel, xAccessor, yAccessor, yInitDisplay, xInitDisplay } = this.props; const { displayValuesFor } = this.props; const { chartConfig: { width, height } } = moreProps; @@ -86,8 +86,8 @@ SingleValueTooltip.defaultProps = { xAccessor: noop, yAccessor: identity, className: "react-stockcharts-tooltip", - xInitDisplay:"n/a", - yInitDisplay:"n/a", + xInitDisplay: "n/a", + yInitDisplay: "n/a", }; export default SingleValueTooltip;