/** * Linear data storage.<br/> * Data is stored as an array or rows where each row contains several columns (see Listing 1 below). * To start working with this storage you need to map columns using * {@link anychart.data.Set#mapAs} method (you can create as many mappings as you like).<br/> * Each field can be a number, a string, a function, an array or an object. * Data fields can of any type and they way you read them depends on mapping only: * {@link anychart.data.Set#mapAs}. Sample mappings are shown in code samples 3, 4 and 5.<br/> * <b>Note:</b> To create an instance of this class use {@link anychart.data#set} method. * @listing Sample 1. Data notion. * // Col1 Col2 Col3 * [ * [110, 112, 114], // row1 * [210, 212, 214], // row2 * [310, 312, 314], // row3 * [410, 412, 414] // row4 * ] * // Col1 * [ * 114, // row1 * 214, // row2 * 314, // row3 * 414 // row4 * ] * @listing Sample 2. Sample data. * // An array with numbers, strings and functions: * anychart.data.set([ * 20, * 7, * '10', * function(smth){ return smth*10; } * ]); * // An array of arrays: * anychart.data.set([ * [1, 22, 13], * [13, 22, 23], * [17, 22, 33], * [21, 22, 43] * ]); * // An array of objects. * anychart.data.set([ * {name: 'Point 1', value: 10}, * {name: 'Point 2', value: 7}, * {name: 'Point 3', value: 20}, * {name: 'Point 4', value: 14} * ]); * // A multi-typed array: * anychart.data.set([ * {value: 10, name: 'Point 1'}, * {value: 7, name: 'Point 2'}, * [20, 'Point 3'], * [14, 'Point 4'], * [-14, 'Point 5', function (params) { do_smth; return smth; }], * '17', * 22, * function (params) { do_smth; return smth; } * ]); * @listing Sample 3. Default data mapping. Numbers. * // 'x' is an index of an element and 'value' is its value. * // Raw data Mapped as * [ * 1, {x: 0, value: 1} * 2, {x: 1, value: 2} * '-5', {x: 2, value: -5} * function(){ return 1;} {x: 3, value: 1} * ] * // so this will not work with OHLC * @listing Sample 4. Default data mapping. Arrays. * // 'x' is an element with the index of 0, * // 'value' is an element with the index of 1, * // 'size' is an element with the index of 2. * // All elements with the index greater than 2 are ignored. * // Raw data Mapped as * [ * [2], {x: 2} * [5, 13], {x: 5, value: 13} * [7, '4', 21], {x: 7, value: 4, size: 21} * [11, 21, 34, 45] {x: 11, value: 21, size: 34} * ] * // In case of OHLC * // 'open' is an element with the index of 0 * // 'high' is an element with the index of 1 * // 'low' is an element with the index of 2 * // 'close' is an element with the index of 3 * // All elements with the index greater than 3 are ignored. * [ * [11, 21, 34, 45] {open: 11, high: 21, low: 34, close: 45} * ] * @listing Sample 5. Default data mapping. Objects. * // In objects everything corresponds to the names of properties, but you can define several mappings and a priority. * // E.g.: 'x' can be mapped to 'x' and 'value' can be looked for * // in 'value', then 'y', then in 'close'. * // Raw data Mapped as * [ * {x: 2}, {x: 2} * {x: 5, value: 13}, {x: 5, value: 13} * {x: 7, y: 4, size: 21}, {x: 7, value: 4, size: 21} * {x: 11, close: 21, size: 34} {x: 11, value: 21, size: 34} * ] * // In case of OHLC * [ * {open: 11, high: 21, low: 34, close: 45} {open: 11, high: 21, low: 34, close: 45} * ] * // 'open' is an element with the index of 0, * // 'high' is an element with the index of 1, * // 'low' is an element with the index of 2, * // 'close' is an element with the index of 3. * // All elements with the index greater than 3 are ignored. * @param {(Array|string)=} opt_data Data set raw data can be set here. * @param {Object.<string, (string|boolean)>=} opt_csvSettings If CSV string is passed, you can pass CSV parser settings * here as a hash map. * @constructor * @extends {anychart.core.Base} */ anychart.data.Set;
/** * Getter for the data in the Set. * @shortDescription Data settings. * @category Data * @return {!Array} Data array of the Set. */ anychart.data.Set.prototype.data;
/** * Setter for Set data. * @example anychart.data.Set.data_set_asArray Using array * @example anychart.data.Set.data_set_asArrayofArrays Using array of arrays * @example anychart.data.Set.data_set_asArrayofObjects Using array of objects * @example anychart.data.Set.data_set_asCSV Using CSV * @param {(Array|string)=} opt_value A value to set. * @param {Object.<string, (string|boolean|undefined)>=} opt_csvSettings If CSV string is passed, you can pass CSV parser settings * here as a hash map. * @return {anychart.data.Set} Self instance for method chaining. */ anychart.data.Set.prototype.data;
/** * Defines data mapping. * @category Data * @detailed You can define mappings for the different types of data (see samples). * Default mapping is shown in {@link anychart.data.Set} constructor samples. * @listing Custom data mapping. * // Simple mapping * dataSet.mapAs({ * 'value': [0], * 'x': [1], * 'fill': [2] * }); * // Raw data Mapped as * [ * [11, 1, 'red 0.5'], {x: 1, value: 11, fill: 'red 0.5'} * [21, 2, 'green 0.5'], {x: 2, value: 21, fill: 'green 0.5'} * [14, 3, 'blue 0.5'], {x: 3, value: 14, fill: 'blue 0.5'} * [11, 4, 'yellow 0.5'] {x: 4, value: 11, fill: 'yellow 0.5'} * ] * // Combined mapping * dataSet.mapAs({ * 'value': [0], * 'x': [1], * 'fill': [2] * },{ * 'value': ['close', 'customY'], * 'fill': ['fill', 'color'] * }, null, ['close'] * ); * // Raw data Mapped as * [ * [11, 1, 'red 0.5'], {x: 1, value: 11, fill: 'red 0.5'} * [21, 2, 'green 0.5'], {x: 2, value: 21, fill: 'green 0.5'} * { * value: 14, * x: 3, {x: 3, value: 14, fill: 'blue 0.5'} * fill: 'blue 0.5' * },{ * customY: '71', * x: 3, {x: 3, value: 71, fill: 'blue 0.5', size 14} * color: 'blue 0.5', * size: 14 * }, * 11, {close: 4, value: 11} * function(){ return 99;} {close: 5, value: 99} * ] * @example anychart.data.Set.mapAs_set_asArray Mapping for base data as array * @example anychart.data.Set.mapAs_set_asObject Mapping for base data as object * @param {!(Object.<Array.<number>>)=} opt_arrayMapping [{ * 'x': [0], * 'value': [1, 0], * 'size': [2], * 'open': [1], * 'high': [2], * 'low': [3, 1], * 'close': [4] * }] Column mapping for the rows which are arrays. * @param {!(Object.<Array.<string>>)=} opt_objectMapping [{'value': ['value', 'y', 'close']}] Column mapping for the rows * which are objects. * @param {!(Array.<string>)=} opt_defaultProps [['value', 'close']] The names of the fields to map to * if a row is a string, number or a function. Does not work in cases when a row is an object. * @param {!(Array.<string>)=} opt_indexProps [['x']] The names of the fields to be mapped to the current index * if other options failed. * @return {anychart.data.Mapping} An instance of class for method chaining. */ anychart.data.Set.prototype.mapAs;
/* * Gets the full row of the set by the index. * @shortDescription Row of the set by the index * @category Data * @detailed <b>Note:</b> If there is no row for the index - returns <b>undefined</b>. * @listing Example. * // Data * [ * [1, 2, 4, 7], * {'high': 14, 'low': 3}, * 7 * ] * dataSet.row(0); // returns [1, 2, 4, 7] * dataSet.row(1); // returns {'high': 14, 'low': 3} * dataSet.row(2); // returns 7 * dataSet.row(3); // returns undefined * @example anychart.data.Set.row_get * @param {number} rowIndex The index of the row to fetch. * @return {} The current row. */ anychart.data.Set.prototype.row;
/* * Sets the row in the set by the index. * @detailed <b>Note:</b> Replaces the current value, previous values is returned but it is lost completely after that! * @listing Example. * // Data * [ * [1, 2, 4, 7], * {'high': 14, 'low': 3}, * 7 * ] * dataSet.row(2, [2, 2, 2, 2]); // returns 7 * dataSet.row(3, {'low': 4, 'high': 11}); // returns undefined * // Data after the changes * [ * [1, 2, 4, 7], * {'high': 14, 'low': 3}, * [2, 2, 2, 2], * {'low': 4, 'high': 11} * ] * @example anychart.data.Set.row_set * @param {number} rowIndex The index of the row to fetch. * @param {=} opt_value The value to set. * @return {*} The previous value of the row. */ anychart.data.Set.prototype.row;
/* * Appends new rows to the set. Each argument is a row that will be appended to the Set. * @category Data * @example anychart.data.Set.append * @param {…} var_args Rows to append. * @return {anychart.data.Set} Self instance for method chaining. */ anychart.data.Set.prototype.append;
/* * Inserts the row to the set at the specified position. * @category Data * @example anychart.data.Set.insert * @param {} row Row to insert. * @param {number=} opt_index [0] The index at which to insert the object. A negative index is counted from the end of an array. * @return {anychart.data.Set} Self instance for method chaining. */ anychart.data.Set.prototype.insert;
/** * Removes the row by index. * @category Data * @example anychart.data.Set.remove * @param {number} index Index of the row to remove. * @return {anychart.data.Set} Self instance for method chaining. */ anychart.data.Set.prototype.remove;
/** * Returns the number of the rows in the current data set. * @category Data * @example anychart.data.Set.getRowsCount * @return {number} The number of the rows in the set. */ anychart.data.Set.prototype.getRowsCount;
/** * Return instance of class {@link anychart.data.Set}. * @category Data * @example anychart.data.set * @param {(Array|string)=} opt_data Data set raw data can be set here. * @param {Object.<string, (string|boolean)>=} opt_csvSettings If CSV string is passed, you can pass CSV parser settings * here as a hash map. * @return {anychart.data.Set} Self instance for method chaining. */ anychart.data.set;
/** @inheritDoc */ anychart.data.Set.prototype.listen;
/** @inheritDoc */ anychart.data.Set.prototype.listenOnce;
/** @inheritDoc */ anychart.data.Set.prototype.unlisten;
/** @inheritDoc */ anychart.data.Set.prototype.unlistenByKey;
/** @inheritDoc */ anychart.data.Set.prototype.removeAllListeners;