DataTransformer: PP.IDataAdapter;
The DataTransformer property determines data converter.
Property value can be set from JSON or using the setDataTransformer property.
To execute the example, the HTML page must contain the component named bubbleChart (see Example of Creating the BubbleChart ComponentBubbleChart component named bubbleChart (see Example of Creating the BubbleChart Component). Convert a set of values using custom converter that increases input value 20 times:
// Get object of mapping of data series and bubble chart bubbles var colorVisual = bubbleChart.getColorVisual(); // Get data mapping settings var mapping = colorVisual.getColorMapping(); // Describe own data transformer PP.MyTransformer = function (settings) { PP.MyTransformer.base.constructor.apply(this, arguments); }; PP.initClass(PP.MyTransformer, PP.Object, 'PP.MyTransformer', ['PP.IDataAdapter']); var myTransP = PP.MyTransformer.prototype; // Increase input value by 20 times myTransP.getData = function (value) { return value * 20; }; myTransP.init = myTransP.getMinData = myTransP.getMaxData = function (data) {}; // Set data mapping type mapping.setType(PP.DataMappingType.Transformer); // Set own data transformer mapping.setDataTransformer(new PP.MyTransformer()); console.log("Data transformer:"); console.log("Input: -0.05, output: " + mapping.getDataTransformer().getData(-0.05)); console.log("Input: 0, output: " + mapping.getDataTransformer().getData(0)); console.log("Input: 5, output: " + mapping.getDataTransformer().getData(5)); console.log("Input: 1000, output: " + mapping.getDataTransformer().getData(1000));
After executing the example a custom converter increasing the input value in 20 times is created, and the development environment console shows transformation results for the values -0.05, 0, 5 and 1000:
Data converter:
Input: -0.05, output: -1
Input: 0, output: 0
Input: 5, output: 100
Input: 1000, output: 20000
See also: