File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ const propTypes = {
5454 * Set this prop to false to prevent x values from being converted to time.
5555 */
5656 isXTime : PropTypes . bool ,
57+ yAxisTickFormat : PropTypes . func ,
58+ yAxisTickSize : PropTypes . number ,
5759} ;
5860
5961const defaultProps = {
@@ -359,10 +361,13 @@ class LineGraph extends Component {
359361
360362 this . yAxis = d3
361363 . axisLeft ( )
362- . ticks ( 4 )
364+ . ticks ( this . props . yAxisTickSize ? this . props . yAxisTickSize : 4 )
363365 . tickSize ( - this . width )
364366 . scale ( this . y . nice ( ) ) ;
365367
368+ if ( this . props . yAxisTickFormat ) {
369+ this . yAxis = this . yAxis . tickFormat ( this . props . yAxisTickFormat ) ;
370+ }
366371 this . renderAxes ( ) ;
367372 this . renderLabels ( ) ;
368373 this . renderOverlay ( ) ;
Original file line number Diff line number Diff line change @@ -168,6 +168,42 @@ storiesOf('LineGraph', module)
168168 onBlur = { action ( 'Blur' ) }
169169 />
170170 ) )
171+ . addWithInfo (
172+ 'Static Custom Y Axis' ,
173+ ` Static Custom Y Axis' Example. ` ,
174+ ( ) => (
175+ < LineGraph
176+ datasets = { [
177+ [
178+ [ 1 , 1507563000000 ] ,
179+ [ - 1 , 1507563900000 ] ,
180+ [ 0 , 1507564800000 ] ,
181+ ] ,
182+ [
183+ [ - 1 , 1507563004000 ] ,
184+ [ 0 , 1507563900140 ] ,
185+ [ 1 , 1507564830000 ] ,
186+ ] ,
187+ ] }
188+ yAxisTickSize = { 2 }
189+ yAxisTickFormat = { val => {
190+ if ( val === 1 ) {
191+ return 'running' ;
192+ }
193+ if ( val === - 1 ) {
194+ return 'stopped' ;
195+ }
196+ if ( val === 0 ) {
197+ return 'unknown' ;
198+ }
199+ return '' ;
200+ } }
201+ onHover = { action ( 'Hover' ) }
202+ onMouseOut = { action ( 'Mouseout' ) }
203+ onBlur = { action ( 'Blur' ) }
204+ />
205+ )
206+ )
171207 . addWithInfo ( 'Number values for X' , ` Static Example. ` , ( ) => (
172208 < LineGraph
173209 datasets = { [
Original file line number Diff line number Diff line change 11{
22 "name" : " carbon-addons-data-viz-react" ,
3- "version" : " 1.25 .0" ,
3+ "version" : " 1.26 .0" ,
44 "description" : " Carbon Data Visualization" ,
55 "main" : " cjs/index.js" ,
66 "module" : " es/index.js" ,
You can’t perform that action at this time.
0 commit comments