11import DatasetController from '../core/core.datasetController' ;
2- import { valueOrDefault } from '../helpers/helpers.core' ;
32import { isNumber , _limitValue } from '../helpers/helpers.math' ;
4- import { resolve } from '../helpers/helpers.options' ;
53import { _lookupByKey } from '../helpers/helpers.collection' ;
64
75export default class LineController extends DatasetController {
@@ -32,9 +30,13 @@ export default class LineController extends DatasetController {
3230
3331 // In resize mode only point locations change, so no need to set the options.
3432 if ( mode !== 'resize' ) {
33+ const options = me . resolveDatasetElementOptions ( mode ) ;
34+ if ( ! me . options . showLine ) {
35+ options . borderWidth = 0 ;
36+ }
3537 me . updateElement ( line , undefined , {
3638 animated : ! animationsDisabled ,
37- options : me . resolveDatasetElementOptions ( )
39+ options
3840 } , mode ) ;
3941 }
4042
@@ -49,7 +51,7 @@ export default class LineController extends DatasetController {
4951 const firstOpts = me . resolveDataElementOptions ( start , mode ) ;
5052 const sharedOptions = me . getSharedOptions ( firstOpts ) ;
5153 const includeOptions = me . includeOptions ( mode , sharedOptions ) ;
52- const spanGaps = valueOrDefault ( me . _config . spanGaps , me . chart . options . spanGaps ) ;
54+ const spanGaps = me . options . spanGaps ;
5355 const maxGapLength = isNumber ( spanGaps ) ? spanGaps : Number . POSITIVE_INFINITY ;
5456 const directUpdate = me . chart . _animationsDisabled || reset || mode === 'none' ;
5557 let prevParsed = start > 0 && me . getParsed ( start - 1 ) ;
@@ -77,32 +79,6 @@ export default class LineController extends DatasetController {
7779 me . updateSharedOptions ( sharedOptions , mode , firstOpts ) ;
7880 }
7981
80- /**
81- * @param {boolean } [active]
82- * @protected
83- */
84- resolveDatasetElementOptions ( active ) {
85- const me = this ;
86- const config = me . _config ;
87- const options = me . chart . options ;
88- const lineOptions = options . elements . line ;
89- const values = super . resolveDatasetElementOptions ( active ) ;
90- const showLine = valueOrDefault ( config . showLine , options . showLine ) ;
91-
92- // The default behavior of lines is to break at null values, according
93- // to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
94- // This option gives lines the ability to span gaps
95- values . spanGaps = valueOrDefault ( config . spanGaps , options . spanGaps ) ;
96- values . tension = valueOrDefault ( config . tension , lineOptions . tension ) ;
97- values . stepped = resolve ( [ config . stepped , lineOptions . stepped ] ) ;
98-
99- if ( ! showLine ) {
100- values . borderWidth = 0 ;
101- }
102-
103- return values ;
104- }
105-
10682 /**
10783 * @protected
10884 */
@@ -132,37 +108,12 @@ LineController.id = 'line';
132108 */
133109LineController . defaults = {
134110 datasetElementType : 'line' ,
135- datasetElementOptions : [
136- 'backgroundColor' ,
137- 'borderCapStyle' ,
138- 'borderColor' ,
139- 'borderDash' ,
140- 'borderDashOffset' ,
141- 'borderJoinStyle' ,
142- 'borderWidth' ,
143- 'capBezierPoints' ,
144- 'cubicInterpolationMode' ,
145- 'fill'
146- ] ,
147-
148111 dataElementType : 'point' ,
149- dataElementOptions : {
150- backgroundColor : 'pointBackgroundColor' ,
151- borderColor : 'pointBorderColor' ,
152- borderWidth : 'pointBorderWidth' ,
153- hitRadius : 'pointHitRadius' ,
154- hoverHitRadius : 'pointHitRadius' ,
155- hoverBackgroundColor : 'pointHoverBackgroundColor' ,
156- hoverBorderColor : 'pointHoverBorderColor' ,
157- hoverBorderWidth : 'pointHoverBorderWidth' ,
158- hoverRadius : 'pointHoverRadius' ,
159- pointStyle : 'pointStyle' ,
160- radius : 'pointRadius' ,
161- rotation : 'pointRotation'
162- } ,
163112
164- showLine : true ,
165- spanGaps : false ,
113+ datasets : {
114+ showLine : true ,
115+ spanGaps : false ,
116+ } ,
166117
167118 interaction : {
168119 mode : 'index'
0 commit comments