@@ -37,8 +37,14 @@ define([
3737 this . state = {
3838 chartType : 'scatter' ,
3939 data : '' ,
40+ x : '' , y : '' , z : '' ,
41+ x_start : '' , x_end : '' ,
42+ values : '' , names : '' , parents : '' ,
43+ color : '' ,
4044 userOption : '' ,
4145 title : '' ,
46+ x_label : '' ,
47+ y_label : '' ,
4248 userCode : '' ,
4349 autoRefresh : true ,
4450 ...this . state
@@ -453,9 +459,9 @@ define([
453459 */
454460 let {
455461 chartType,
456- data, x, y, setXY,
462+ data, x, y, color , setXY,
457463 userOption, userCode,
458- title
464+ title, x_label , y_label
459465 } = this . state ;
460466 let code = new com_String ( ) ;
461467 let config = this . chartConfig [ chartType ] ;
@@ -465,6 +471,42 @@ define([
465471 if ( title != '' ) {
466472 etcOptionCode . push ( com_util . formatString ( "title='{0}'" , title ) ) ;
467473 }
474+ let labelOptions = [ ] ;
475+ // add x_label
476+ if ( x_label != '' ) {
477+ if ( setXY === true ) {
478+ // replace 'x' to x_label
479+ labelOptions . push ( com_util . formatString ( "'x': '{0}'" , x_label ) ) ;
480+ } else {
481+ // if x is selected
482+ if ( x != '' ) {
483+ // replace x column name to x_label
484+ labelOptions . push ( com_util . formatString ( "{0}: '{1}'" , x , x_label ) ) ;
485+ } else {
486+ // replace 'index' to x_label
487+ labelOptions . push ( com_util . formatString ( "'index': '{0}'" , x_label ) ) ;
488+ }
489+ }
490+ }
491+ // add y_label
492+ if ( y_label != '' ) {
493+ if ( setXY === true ) {
494+ // replace 'y' to y_label
495+ labelOptions . push ( com_util . formatString ( "'y': '{0}'" , y_label ) ) ;
496+ } else {
497+ // if y is selected
498+ if ( y != '' ) {
499+ // replace y column name to y_label
500+ labelOptions . push ( com_util . formatString ( "{0}: '{1}'" , y , y_label ) ) ;
501+ } else {
502+ // replace 'index' to y_label
503+ labelOptions . push ( com_util . formatString ( "'index': '{0}'" , y_label ) ) ;
504+ }
505+ }
506+ }
507+ if ( labelOptions . length > 0 ) {
508+ etcOptionCode . push ( com_util . formatString ( "labels={ {0} }" , labelOptions . join ( ', ' ) ) ) ;
509+ }
468510 // add user option
469511 if ( userOption != '' ) {
470512 etcOptionCode . push ( userOption ) ;
0 commit comments