11import { getAxisId , getGroupId , getSpecId } from '../../../utils/ids' ;
22import { ScaleType } from '../../../scales' ;
33import { computeLegend } from './legend' ;
4- import { SeriesCollectionValue , getSeriesLabel } from '../utils/series' ;
4+ import { SeriesCollectionValue , getSeriesName } from '../utils/series' ;
55import { AxisSpec , BasicSeriesSpec , SeriesTypes } from '../utils/specs' ;
66import { Position } from '../../../utils/commons' ;
77import { ChartTypes } from '../..' ;
@@ -118,7 +118,7 @@ describe('Legends', () => {
118118 const expected = [
119119 {
120120 color : 'red' ,
121- label : 'Spec 1 title' ,
121+ name : 'Spec 1 title' ,
122122 seriesIdentifier : {
123123 seriesKeys : [ 'y1' ] ,
124124 specId : 'spec1' ,
@@ -142,7 +142,7 @@ describe('Legends', () => {
142142 const expected = [
143143 {
144144 color : 'red' ,
145- label : 'Spec 1 title' ,
145+ name : 'Spec 1 title' ,
146146 seriesIdentifier : {
147147 seriesKeys : [ 'y1' ] ,
148148 specId : 'spec1' ,
@@ -158,7 +158,7 @@ describe('Legends', () => {
158158 } ,
159159 {
160160 color : 'blue' ,
161- label : 'a - b' ,
161+ name : 'a - b' ,
162162 seriesIdentifier : {
163163 seriesKeys : [ 'a' , 'b' , 'y1' ] ,
164164 specId : 'spec1' ,
@@ -182,7 +182,7 @@ describe('Legends', () => {
182182 const expected = [
183183 {
184184 color : 'red' ,
185- label : 'Spec 1 title' ,
185+ name : 'Spec 1 title' ,
186186 seriesIdentifier : {
187187 seriesKeys : [ 'y1' ] ,
188188 specId : 'spec1' ,
@@ -198,7 +198,7 @@ describe('Legends', () => {
198198 } ,
199199 {
200200 color : 'green' ,
201- label : 'spec2' ,
201+ name : 'spec2' ,
202202 seriesIdentifier : {
203203 seriesKeys : [ 'y1' ] ,
204204 specId : 'spec2' ,
@@ -227,7 +227,7 @@ describe('Legends', () => {
227227 const expected = [
228228 {
229229 color : 'violet' ,
230- label : 'Spec 1 title' ,
230+ name : 'Spec 1 title' ,
231231 banded : undefined ,
232232 seriesIdentifier : {
233233 seriesKeys : [ 'y1' ] ,
@@ -272,7 +272,7 @@ describe('Legends', () => {
272272 const visibility = [ ...legend . values ( ) ] . map ( ( item ) => item . isSeriesVisible ) ;
273273 expect ( visibility ) . toEqual ( [ false , false , true ] ) ;
274274 } ) ;
275- it ( 'returns the right series label for a color series' , ( ) => {
275+ it ( 'returns the right series name for a color series' , ( ) => {
276276 const seriesIdentifier1 = {
277277 specId : getSpecId ( '' ) ,
278278 yAccessor : 'y1' ,
@@ -289,38 +289,38 @@ describe('Legends', () => {
289289 } ;
290290
291291 // null removed, seriesIdentifier has to be at least an empty array
292- let label = getSeriesLabel ( seriesIdentifier1 , true , false ) ;
293- expect ( label ) . toBe ( '' ) ;
294- label = getSeriesLabel ( seriesIdentifier1 , true , false , spec1 ) ;
295- expect ( label ) . toBe ( 'Spec 1 title' ) ;
296- label = getSeriesLabel ( seriesIdentifier1 , true , false , spec2 ) ;
297- expect ( label ) . toBe ( 'spec2' ) ;
298- label = getSeriesLabel ( seriesIdentifier2 , true , false , spec1 ) ;
299- expect ( label ) . toBe ( 'Spec 1 title' ) ;
300- label = getSeriesLabel ( seriesIdentifier2 , true , false , spec2 ) ;
301- expect ( label ) . toBe ( 'spec2' ) ;
292+ let name = getSeriesName ( seriesIdentifier1 , true , false ) ;
293+ expect ( name ) . toBe ( '' ) ;
294+ name = getSeriesName ( seriesIdentifier1 , true , false , spec1 ) ;
295+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
296+ name = getSeriesName ( seriesIdentifier1 , true , false , spec2 ) ;
297+ expect ( name ) . toBe ( 'spec2' ) ;
298+ name = getSeriesName ( seriesIdentifier2 , true , false , spec1 ) ;
299+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
300+ name = getSeriesName ( seriesIdentifier2 , true , false , spec2 ) ;
301+ expect ( name ) . toBe ( 'spec2' ) ;
302302
303- label = getSeriesLabel ( seriesIdentifier1 , false , false , spec1 ) ;
304- expect ( label ) . toBe ( 'Spec 1 title' ) ;
305- label = getSeriesLabel ( seriesIdentifier1 , false , false , spec2 ) ;
306- expect ( label ) . toBe ( 'spec2' ) ;
307- label = getSeriesLabel ( seriesIdentifier2 , false , false , spec1 ) ;
308- expect ( label ) . toBe ( 'a - b' ) ;
309- label = getSeriesLabel ( seriesIdentifier2 , false , false , spec2 ) ;
310- expect ( label ) . toBe ( 'a - b' ) ;
303+ name = getSeriesName ( seriesIdentifier1 , false , false , spec1 ) ;
304+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
305+ name = getSeriesName ( seriesIdentifier1 , false , false , spec2 ) ;
306+ expect ( name ) . toBe ( 'spec2' ) ;
307+ name = getSeriesName ( seriesIdentifier2 , false , false , spec1 ) ;
308+ expect ( name ) . toBe ( 'a - b' ) ;
309+ name = getSeriesName ( seriesIdentifier2 , false , false , spec2 ) ;
310+ expect ( name ) . toBe ( 'a - b' ) ;
311311
312- label = getSeriesLabel ( seriesIdentifier1 , true , false , spec1 ) ;
313- expect ( label ) . toBe ( 'Spec 1 title' ) ;
314- label = getSeriesLabel ( seriesIdentifier1 , true , false , spec2 ) ;
315- expect ( label ) . toBe ( 'spec2' ) ;
316- label = getSeriesLabel ( seriesIdentifier1 , true , false ) ;
317- expect ( label ) . toBe ( '' ) ;
318- label = getSeriesLabel ( seriesIdentifier1 , true , false , spec1 ) ;
319- expect ( label ) . toBe ( 'Spec 1 title' ) ;
320- label = getSeriesLabel ( seriesIdentifier1 , true , false , spec2 ) ;
321- expect ( label ) . toBe ( 'spec2' ) ;
312+ name = getSeriesName ( seriesIdentifier1 , true , false , spec1 ) ;
313+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
314+ name = getSeriesName ( seriesIdentifier1 , true , false , spec2 ) ;
315+ expect ( name ) . toBe ( 'spec2' ) ;
316+ name = getSeriesName ( seriesIdentifier1 , true , false ) ;
317+ expect ( name ) . toBe ( '' ) ;
318+ name = getSeriesName ( seriesIdentifier1 , true , false , spec1 ) ;
319+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
320+ name = getSeriesName ( seriesIdentifier1 , true , false , spec2 ) ;
321+ expect ( name ) . toBe ( 'spec2' ) ;
322322 } ) ;
323- it ( 'use the splitted value as label if has a single series and splitSeries is used' , ( ) => {
323+ it ( 'use the splitted value as name if has a single series and splitSeries is used' , ( ) => {
324324 const seriesIdentifier1 = {
325325 specId : getSpecId ( '' ) ,
326326 yAccessor : 'y1' ,
@@ -347,22 +347,22 @@ describe('Legends', () => {
347347 ...spec1 ,
348348 splitSeriesAccessors : [ 'g' ] ,
349349 } ;
350- let label = getSeriesLabel ( seriesIdentifier1 , true , false , specWithSplit ) ;
351- expect ( label ) . toBe ( 'Spec 1 title' ) ;
350+ let name = getSeriesName ( seriesIdentifier1 , true , false , specWithSplit ) ;
351+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
352352
353- label = getSeriesLabel ( seriesIdentifier3 , true , false , specWithSplit ) ;
354- expect ( label ) . toBe ( 'a' ) ;
353+ name = getSeriesName ( seriesIdentifier3 , true , false , specWithSplit ) ;
354+ expect ( name ) . toBe ( 'a' ) ;
355355
356356 // happens when we have multiple values in splitSeriesAccessor
357357 // or we have also multiple yAccessors
358- label = getSeriesLabel ( seriesIdentifier2 , true , false , specWithSplit ) ;
359- expect ( label ) . toBe ( 'a - b' ) ;
358+ name = getSeriesName ( seriesIdentifier2 , true , false , specWithSplit ) ;
359+ expect ( name ) . toBe ( 'a - b' ) ;
360360
361361 // happens when the value of a splitSeriesAccessor is null
362- label = getSeriesLabel ( seriesIdentifier1 , true , false , specWithSplit ) ;
363- expect ( label ) . toBe ( 'Spec 1 title' ) ;
362+ name = getSeriesName ( seriesIdentifier1 , true , false , specWithSplit ) ;
363+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
364364
365- label = getSeriesLabel ( seriesIdentifier1 , false , false , specWithSplit ) ;
366- expect ( label ) . toBe ( 'Spec 1 title' ) ;
365+ name = getSeriesName ( seriesIdentifier1 , false , false , specWithSplit ) ;
366+ expect ( name ) . toBe ( 'Spec 1 title' ) ;
367367 } ) ;
368368} ) ;
0 commit comments