TOC : Script API > JavaScript > JavaScript API > ChartObject > ChartLabel > Method >

 

SetUserValue

<< Click to Display Table of Contents >>

TOC : Script API > JavaScript > JavaScript API > ChartObject > ChartLabel > Method >

 

SetUserValue

 

 

Assigns a user defined value to the user value

 

 

 

Prototype :

 

void SetUserValue

(

       var UserValue

)

 

 

 

Arguments :

 

UserValue

a user defined value

 

 

 

Reference :

 

The value can be either numeric or string.

 

In OnBind, to reference a value set by OnInitialize in the same component, use the user value rather than a global variable.

 

Set the user value at OnInitialize using SetUserValue and get it into OnBind using GetUserValue.

 

 

 

Example :

 

var ChartRootUnit = This.GetChartRootUnit();

var ChartShapeCnt = ChartRootUnit.GetShapeCount();

for(i = 0; i < ChartShapeCnt; i++) {

  var ChartShape = ChartRootUnit.GetShape(i);

  var ChartPieceCnt = ChartShape.GetPieceCount();

  for(j = 0; j < ChartPieceCnt; j++) {

     var ChartPiece = ChartShape.GetPiece(j);

     var ChartPieceLabel = ChartPiece.GetLabel();

     if(ChartPieceLabel != null) {

        //numeric - create in OnBind event

           ChartPieceLabel.SetUserValue(1);

        //string - create in OnBind event

        // ChartPieceLabel .SetUserValue("OZ");

     }

  }

}

 

 

 

Available Events :

 

OnBind, OnPostChartBuild

For the object returned by GetChartLabel function of a chart, the function can be called only in OnBind event, and for the object returned by GetLabel function of a ChartPiece, the function can be called only in OnPostChartBuild event.