import { format } from "d3-format"; import { timeFormat } from "d3-time-format"; import { ChartCanvas, Chart } from "react-stockcharts"; import { CandlestickSeries, LineSeries, } from "react-stockcharts/lib/series"; import { XAxis, YAxis } from "react-stockcharts/lib/axes"; import { CrossHairCursor, EdgeIndicator, CurrentCoordinate, MouseCoordinateX, MouseCoordinateY, } from "react-stockcharts/lib/coordinates"; import { LabelAnnotation, Label, Annotate } from "react-stockcharts/lib/annotation"; import { discontinuousTimeScaleProvider } from "react-stockcharts/lib/scale"; import { OHLCTooltip, MovingAverageTooltip } from "react-stockcharts/lib/tooltip"; import { ema } from "react-stockcharts/lib/indicator"; // import { fitWidth } from "react-stockcharts/lib/helper"; import { last } from "react-stockcharts/lib/utils"; let CandleStickChartWithAnnotation = function(props) { const annotationProps = { fontFamily: "Glyphicons Halflings", fontSize: 20, fill: "#060F8F", opacity: 0.8, text: "\ue182", y: ({ yScale }) => yScale.range()[0], onClick: console.log.bind(console), tooltip: d => timeFormat("%B")(d.date), // onMouseOver: console.log.bind(console), }; const margin = { left: 80, right: 80, top: 30, bottom: 50 }; const height = 400; const { type, data: initialData, width, ratio } = props; const [yAxisLabelX, yAxisLabelY] = [ width - margin.left - 40, (height - margin.top - margin.bottom) / 2 ]; const xScaleProvider = discontinuousTimeScaleProvider .inputDateAccessor(d => d.date); const { data, xScale, xAccessor, displayXAccessor, } = xScaleProvider(initialData); const start = xAccessor(last(data)); const end = xAccessor(data[Math.max(0, data.length - 150)]); const xExtents = [start, end]; return ( ); } /* CandleStickChartWithAnnotation.propTypes = { data: PropTypes.array.isRequired, width: PropTypes.number.isRequired, ratio: PropTypes.number.isRequired, type: PropTypes.oneOf(["svg", "hybrid"]).isRequired, }; CandleStickChartWithAnnotation.defaultProps = { type: "svg", }; */ // CandleStickChartWithAnnotation = fitWidth(CandleStickChartWithAnnotation); export default CandleStickChartWithAnnotation;