diff --git a/packages/react-financial-charts-examples/src/components/stockChart.tsx b/packages/react-financial-charts-examples/src/components/stockChart.tsx index 14ac419be..bdc15fe67 100644 --- a/packages/react-financial-charts-examples/src/components/stockChart.tsx +++ b/packages/react-financial-charts-examples/src/components/stockChart.tsx @@ -39,6 +39,7 @@ class StockChart extends React.Component { const start = xAccessor(data[data.length - 1]); const end = xAccessor(data[Math.max(0, data.length - 100)]); const xExtents = [start, end]; + const yExtents = (d: IOHLCData) => [d.high, d.low]; const margin = { left: 32, right: 70, top: 32, bottom: 32 }; const gridWidth = width - margin.left - margin.right; @@ -62,15 +63,16 @@ class StockChart extends React.Component { height={gridHeight / 2} origin={(w, h) => [0, h - (gridHeight / 2)]} yExtents={(d: IOHLCData) => d.volume}> - d.volume} /> + d.volume} /> - [d.high, d.low]}> + + ticks={6} /> { + displayFormat={timeFormat("%d %b")} /> { itemType="last" orient="right" edgeAt="right" - fill={(d: IOHLCData) => d.close > d.open ? "#26a69a" : "#ef5350"} - lineStroke={(d: IOHLCData) => d.close > d.open ? "#26a69a" : "#ef5350"} + fill={this.openCloseColor} + lineStroke={this.openCloseColor} displayFormat={format(".5f")} yAccessor={(d: IOHLCData) => d.close} /> @@ -98,6 +100,10 @@ class StockChart extends React.Component { ); } + + private readonly openCloseColor = (data: IOHLCData) => { + return data.close > data.open ? "#26a69a" : "#ef5350"; + } } export default withDimensions(StockChart); diff --git a/packages/react-financial-charts/src/axes/Axis.tsx b/packages/react-financial-charts/src/axes/Axis.tsx index ff7b8edc2..a56016ccd 100644 --- a/packages/react-financial-charts/src/axes/Axis.tsx +++ b/packages/react-financial-charts/src/axes/Axis.tsx @@ -13,41 +13,41 @@ interface AxisProps { readonly fontSize?: number; readonly fontWeight?: number; readonly orient?: "top" | "left" | "right" | "bottom"; - innerTickSize?: number; - outerTickSize?: number; - tickFormat?: any; // func - tickPadding?: number; - tickSize?: number; - ticks?: number; - tickLabelFill?: string; - tickStroke?: string; - tickStrokeOpacity?: number; - tickStrokeWidth?: number; - tickStrokeDasharray?: strokeDashTypes; - tickValues?: number[] | any; // func - tickInterval?: number; - tickIntervalFunction?: any; // func - showDomain?: boolean; - showTicks?: boolean; - showTickLabel?: boolean; - className?: string; - axisZoomCallback?: any; // func - zoomEnabled?: boolean; - inverted?: boolean; - zoomCursorClassName?: string; - transform: number[]; - range: number[]; - getMouseDelta: any; // func - getScale: any; // func - bg: { + readonly innerTickSize?: number; + readonly outerTickSize?: number; + readonly tickFormat?: any; // func + readonly tickPadding?: number; + readonly tickSize?: number; + readonly ticks?: number; + readonly tickLabelFill?: string; + readonly tickStroke?: string; + readonly tickStrokeOpacity?: number; + readonly tickStrokeWidth?: number; + readonly tickStrokeDasharray?: strokeDashTypes; + readonly tickValues?: number[] | any; // func + readonly tickInterval?: number; + readonly tickIntervalFunction?: any; // func + readonly showDomain?: boolean; + readonly showTicks?: boolean; + readonly showTickLabel?: boolean; + readonly className?: string; + readonly axisZoomCallback?: any; // func + readonly zoomEnabled?: boolean; + readonly inverted?: boolean; + readonly zoomCursorClassName?: string; + readonly transform: number[]; + readonly range: number[]; + readonly getMouseDelta: any; // func + readonly getScale: any; // func + readonly bg: { h: number; x: number; w: number; y: number; }; - edgeClip: boolean; - onContextMenu?: any; // func - onDoubleClick?: any; // func + readonly edgeClip: boolean; + readonly onContextMenu?: any; // func + readonly onDoubleClick?: any; // func } class Axis extends React.Component { @@ -247,7 +247,9 @@ function tickHelper(props, scale) { } return { - ticks, scale, tickStroke, + ticks, + scale, + tickStroke, tickLabelFill: (tickLabelFill || tickStroke), tickStrokeOpacity, tickStrokeWidth, diff --git a/packages/react-financial-charts/src/axes/XAxis.tsx b/packages/react-financial-charts/src/axes/XAxis.tsx index 93106bdf1..fa8ceabdc 100644 --- a/packages/react-financial-charts/src/axes/XAxis.tsx +++ b/packages/react-financial-charts/src/axes/XAxis.tsx @@ -71,7 +71,7 @@ export class XAxis extends React.Component { diff --git a/packages/react-financial-charts/src/axes/YAxis.tsx b/packages/react-financial-charts/src/axes/YAxis.tsx index adbdd9265..ebe711e7c 100644 --- a/packages/react-financial-charts/src/axes/YAxis.tsx +++ b/packages/react-financial-charts/src/axes/YAxis.tsx @@ -68,7 +68,7 @@ export class YAxis extends React.Component {