MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / getValueAxesMinGaps

Function getValueAxesMinGaps

libs/echarts/echarts-en.simple.js:36677–36734  ·  view source on GitHub ↗

* Map from (baseAxis.dim + '_' + baseAxis.index) to min gap of two adjacent * values. * This works for time axes, value axes, and log axes. * For a single time axis, return value is in the form like * {'x_0': [1000000]}. * The value of 1000000 is in milliseconds.

(barSeries)

Source from the content-addressed store, hash-verified

36675 * The value of 1000000 is in milliseconds.
36676 */
36677function getValueAxesMinGaps(barSeries) {
36678 /**
36679 * Map from axis.index to values.
36680 * For a single time axis, axisValues is in the form like
36681 * {'x_0': [1495555200000, 1495641600000, 1495728000000]}.
36682 * Items in axisValues[x], e.g. 1495555200000, are time values of all
36683 * series.
36684 */
36685 var axisValues = {};
36686 each$1(barSeries, function (seriesModel) {
36687 var cartesian = seriesModel.coordinateSystem;
36688 var baseAxis = cartesian.getBaseAxis();
36689 if (baseAxis.type !== 'time' && baseAxis.type !== 'value') {
36690 return;
36691 }
36692
36693 var data = seriesModel.getData();
36694 var key = baseAxis.dim + '_' + baseAxis.index;
36695 var dim = data.mapDimension(baseAxis.dim);
36696 for (var i = 0, cnt = data.count(); i < cnt; ++i) {
36697 var value = data.get(dim, i);
36698 if (!axisValues[key]) {
36699 // No previous data for the axis
36700 axisValues[key] = [value];
36701 }
36702 else {
36703 // No value in previous series
36704 axisValues[key].push(value);
36705 }
36706 // Ignore duplicated time values in the same axis
36707 }
36708 });
36709
36710 var axisMinGaps = [];
36711 for (var key in axisValues) {
36712 if (axisValues.hasOwnProperty(key)) {
36713 var valuesInAxis = axisValues[key];
36714 if (valuesInAxis) {
36715 // Sort axis values into ascending order to calculate gaps
36716 valuesInAxis.sort(function (a, b) {
36717 return a - b;
36718 });
36719
36720 var min = null;
36721 for (var j = 1; j < valuesInAxis.length; ++j) {
36722 var delta = valuesInAxis[j] - valuesInAxis[j - 1];
36723 if (delta > 0) {
36724 // Ignore 0 delta because they are of the same axis value
36725 min = min === null ? delta : Math.min(min, delta);
36726 }
36727 }
36728 // Set to null if only have one data
36729 axisMinGaps[key] = min;
36730 }
36731 }
36732 }
36733 return axisMinGaps;
36734}

Callers 1

makeColumnLayoutFunction · 0.70

Calls 5

pushMethod · 0.80
minMethod · 0.80
each$1Function · 0.70
getDataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected