repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
ColorlibHQ/AdminLTE
|
bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js
|
function(val) {
return new Color(
val ? val : null,
this.options.colorSelectors,
this.options.fallbackColor ? this.options.fallbackColor : this.color,
this.options.fallbackFormat,
this.options.hexNumberSignPrefix
);
}
|
javascript
|
function(val) {
return new Color(
val ? val : null,
this.options.colorSelectors,
this.options.fallbackColor ? this.options.fallbackColor : this.color,
this.options.fallbackFormat,
this.options.hexNumberSignPrefix
);
}
|
[
"function",
"(",
"val",
")",
"{",
"return",
"new",
"Color",
"(",
"val",
"?",
"val",
":",
"null",
",",
"this",
".",
"options",
".",
"colorSelectors",
",",
"this",
".",
"options",
".",
"fallbackColor",
"?",
"this",
".",
"options",
".",
"fallbackColor",
":",
"this",
".",
"color",
",",
"this",
".",
"options",
".",
"fallbackFormat",
",",
"this",
".",
"options",
".",
"hexNumberSignPrefix",
")",
";",
"}"
] |
Creates a new color using the instance options
@protected
@param {String} val
@returns {Color}
|
[
"Creates",
"a",
"new",
"color",
"using",
"the",
"instance",
"options"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js#L1081-L1089
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jquery-sparkline/src/base.js
|
function (el, x, y) {
var currentRegion = this.currentRegion,
highlightEnabled = !this.options.get('disableHighlight'),
newRegion;
if (x > this.canvasWidth || y > this.canvasHeight || x < 0 || y < 0) {
return null;
}
newRegion = this.getRegion(el, x, y);
if (currentRegion !== newRegion) {
if (currentRegion !== undefined && highlightEnabled) {
this.removeHighlight();
}
this.currentRegion = newRegion;
if (newRegion !== undefined && highlightEnabled) {
this.renderHighlight();
}
return true;
}
return false;
}
|
javascript
|
function (el, x, y) {
var currentRegion = this.currentRegion,
highlightEnabled = !this.options.get('disableHighlight'),
newRegion;
if (x > this.canvasWidth || y > this.canvasHeight || x < 0 || y < 0) {
return null;
}
newRegion = this.getRegion(el, x, y);
if (currentRegion !== newRegion) {
if (currentRegion !== undefined && highlightEnabled) {
this.removeHighlight();
}
this.currentRegion = newRegion;
if (newRegion !== undefined && highlightEnabled) {
this.renderHighlight();
}
return true;
}
return false;
}
|
[
"function",
"(",
"el",
",",
"x",
",",
"y",
")",
"{",
"var",
"currentRegion",
"=",
"this",
".",
"currentRegion",
",",
"highlightEnabled",
"=",
"!",
"this",
".",
"options",
".",
"get",
"(",
"'disableHighlight'",
")",
",",
"newRegion",
";",
"if",
"(",
"x",
">",
"this",
".",
"canvasWidth",
"||",
"y",
">",
"this",
".",
"canvasHeight",
"||",
"x",
"<",
"0",
"||",
"y",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"newRegion",
"=",
"this",
".",
"getRegion",
"(",
"el",
",",
"x",
",",
"y",
")",
";",
"if",
"(",
"currentRegion",
"!==",
"newRegion",
")",
"{",
"if",
"(",
"currentRegion",
"!==",
"undefined",
"&&",
"highlightEnabled",
")",
"{",
"this",
".",
"removeHighlight",
"(",
")",
";",
"}",
"this",
".",
"currentRegion",
"=",
"newRegion",
";",
"if",
"(",
"newRegion",
"!==",
"undefined",
"&&",
"highlightEnabled",
")",
"{",
"this",
".",
"renderHighlight",
"(",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Highlight an item based on the moused-over x,y co-ordinate
|
[
"Highlight",
"an",
"item",
"based",
"on",
"the",
"moused",
"-",
"over",
"x",
"y",
"co",
"-",
"ordinate"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jquery-sparkline/src/base.js#L224-L243
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jvectormap/lib/world-map.js
|
function(){
this.width = this.container.width();
this.height = this.container.height();
this.resize();
this.canvas.setSize(this.width, this.height);
this.applyTransform();
}
|
javascript
|
function(){
this.width = this.container.width();
this.height = this.container.height();
this.resize();
this.canvas.setSize(this.width, this.height);
this.applyTransform();
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"width",
"=",
"this",
".",
"container",
".",
"width",
"(",
")",
";",
"this",
".",
"height",
"=",
"this",
".",
"container",
".",
"height",
"(",
")",
";",
"this",
".",
"resize",
"(",
")",
";",
"this",
".",
"canvas",
".",
"setSize",
"(",
"this",
".",
"width",
",",
"this",
".",
"height",
")",
";",
"this",
".",
"applyTransform",
"(",
")",
";",
"}"
] |
Synchronize the size of the map with the size of the container. Suitable in situations where the size of the container is changed programmatically or container is shown after it became visible.
|
[
"Synchronize",
"the",
"size",
"of",
"the",
"map",
"with",
"the",
"size",
"of",
"the",
"container",
".",
"Suitable",
"in",
"situations",
"where",
"the",
"size",
"of",
"the",
"container",
"is",
"changed",
"programmatically",
"or",
"container",
"is",
"shown",
"after",
"it",
"became",
"visible",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L190-L196
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jvectormap/lib/world-map.js
|
function() {
var key,
i;
for (key in this.series) {
for (i = 0; i < this.series[key].length; i++) {
this.series[key][i].clear();
}
}
this.scale = this.baseScale;
this.transX = this.baseTransX;
this.transY = this.baseTransY;
this.applyTransform();
}
|
javascript
|
function() {
var key,
i;
for (key in this.series) {
for (i = 0; i < this.series[key].length; i++) {
this.series[key][i].clear();
}
}
this.scale = this.baseScale;
this.transX = this.baseTransX;
this.transY = this.baseTransY;
this.applyTransform();
}
|
[
"function",
"(",
")",
"{",
"var",
"key",
",",
"i",
";",
"for",
"(",
"key",
"in",
"this",
".",
"series",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"series",
"[",
"key",
"]",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"series",
"[",
"key",
"]",
"[",
"i",
"]",
".",
"clear",
"(",
")",
";",
"}",
"}",
"this",
".",
"scale",
"=",
"this",
".",
"baseScale",
";",
"this",
".",
"transX",
"=",
"this",
".",
"baseTransX",
";",
"this",
".",
"transY",
"=",
"this",
".",
"baseTransY",
";",
"this",
".",
"applyTransform",
"(",
")",
";",
"}"
] |
Reset all the series and show the map with the initial zoom.
|
[
"Reset",
"all",
"the",
"series",
"and",
"show",
"the",
"map",
"with",
"the",
"initial",
"zoom",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L201-L214
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jvectormap/lib/world-map.js
|
function(key, marker, seriesData){
var markers = {},
data = [],
values,
i,
seriesData = seriesData || [];
markers[key] = marker;
for (i = 0; i < seriesData.length; i++) {
values = {};
values[key] = seriesData[i];
data.push(values);
}
this.addMarkers(markers, data);
}
|
javascript
|
function(key, marker, seriesData){
var markers = {},
data = [],
values,
i,
seriesData = seriesData || [];
markers[key] = marker;
for (i = 0; i < seriesData.length; i++) {
values = {};
values[key] = seriesData[i];
data.push(values);
}
this.addMarkers(markers, data);
}
|
[
"function",
"(",
"key",
",",
"marker",
",",
"seriesData",
")",
"{",
"var",
"markers",
"=",
"{",
"}",
",",
"data",
"=",
"[",
"]",
",",
"values",
",",
"i",
",",
"seriesData",
"=",
"seriesData",
"||",
"[",
"]",
";",
"markers",
"[",
"key",
"]",
"=",
"marker",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"seriesData",
".",
"length",
";",
"i",
"++",
")",
"{",
"values",
"=",
"{",
"}",
";",
"values",
"[",
"key",
"]",
"=",
"seriesData",
"[",
"i",
"]",
";",
"data",
".",
"push",
"(",
"values",
")",
";",
"}",
"this",
".",
"addMarkers",
"(",
"markers",
",",
"data",
")",
";",
"}"
] |
Add one marker to the map.
@param {String} key Marker unique code.
@param {Object} marker Marker configuration parameters.
@param {Array} seriesData Values to add to the data series.
|
[
"Add",
"one",
"marker",
"to",
"the",
"map",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L755-L770
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jvectormap/lib/world-map.js
|
function(markers, seriesData){
var i;
seriesData = seriesData || [];
this.createMarkers(markers);
for (i = 0; i < seriesData.length; i++) {
this.series.markers[i].setValues(seriesData[i] || {});
};
}
|
javascript
|
function(markers, seriesData){
var i;
seriesData = seriesData || [];
this.createMarkers(markers);
for (i = 0; i < seriesData.length; i++) {
this.series.markers[i].setValues(seriesData[i] || {});
};
}
|
[
"function",
"(",
"markers",
",",
"seriesData",
")",
"{",
"var",
"i",
";",
"seriesData",
"=",
"seriesData",
"||",
"[",
"]",
";",
"this",
".",
"createMarkers",
"(",
"markers",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"seriesData",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"series",
".",
"markers",
"[",
"i",
"]",
".",
"setValues",
"(",
"seriesData",
"[",
"i",
"]",
"||",
"{",
"}",
")",
";",
"}",
";",
"}"
] |
Add set of marker to the map.
@param {Object|Array} markers Markers to add to the map. In case of array is provided, codes of markers will be set as string representations of array indexes.
@param {Array} seriesData Values to add to the data series.
|
[
"Add",
"set",
"of",
"marker",
"to",
"the",
"map",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L777-L786
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jvectormap/lib/world-map.js
|
function(markers){
var i;
for (i = 0; i < markers.length; i++) {
this.markers[ markers[i] ].element.remove();
delete this.markers[ markers[i] ];
};
}
|
javascript
|
function(markers){
var i;
for (i = 0; i < markers.length; i++) {
this.markers[ markers[i] ].element.remove();
delete this.markers[ markers[i] ];
};
}
|
[
"function",
"(",
"markers",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"markers",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"markers",
"[",
"markers",
"[",
"i",
"]",
"]",
".",
"element",
".",
"remove",
"(",
")",
";",
"delete",
"this",
".",
"markers",
"[",
"markers",
"[",
"i",
"]",
"]",
";",
"}",
";",
"}"
] |
Remove some markers from the map.
@param {Array} markers Array of marker codes to be removed.
|
[
"Remove",
"some",
"markers",
"from",
"the",
"map",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L792-L799
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jvectormap/lib/world-map.js
|
function(lat, lng) {
var point,
proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
width = this.width - this.baseTransX * 2 * this.baseScale,
height = this.height - this.baseTransY * 2 * this.baseScale,
inset,
bbox,
scaleFactor = this.scale / this.baseScale;
if (lng < (-180 + centralMeridian)) {
lng += 360;
}
point = jvm.Proj[proj.type](lat, lng, centralMeridian);
inset = this.getInsetForPoint(point.x, point.y);
if (inset) {
bbox = inset.bbox;
point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
return {
x: point.x + this.transX*this.scale + inset.left*this.scale,
y: point.y + this.transY*this.scale + inset.top*this.scale
};
} else {
return false;
}
}
|
javascript
|
function(lat, lng) {
var point,
proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
width = this.width - this.baseTransX * 2 * this.baseScale,
height = this.height - this.baseTransY * 2 * this.baseScale,
inset,
bbox,
scaleFactor = this.scale / this.baseScale;
if (lng < (-180 + centralMeridian)) {
lng += 360;
}
point = jvm.Proj[proj.type](lat, lng, centralMeridian);
inset = this.getInsetForPoint(point.x, point.y);
if (inset) {
bbox = inset.bbox;
point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
return {
x: point.x + this.transX*this.scale + inset.left*this.scale,
y: point.y + this.transY*this.scale + inset.top*this.scale
};
} else {
return false;
}
}
|
[
"function",
"(",
"lat",
",",
"lng",
")",
"{",
"var",
"point",
",",
"proj",
"=",
"jvm",
".",
"WorldMap",
".",
"maps",
"[",
"this",
".",
"params",
".",
"map",
"]",
".",
"projection",
",",
"centralMeridian",
"=",
"proj",
".",
"centralMeridian",
",",
"width",
"=",
"this",
".",
"width",
"-",
"this",
".",
"baseTransX",
"*",
"2",
"*",
"this",
".",
"baseScale",
",",
"height",
"=",
"this",
".",
"height",
"-",
"this",
".",
"baseTransY",
"*",
"2",
"*",
"this",
".",
"baseScale",
",",
"inset",
",",
"bbox",
",",
"scaleFactor",
"=",
"this",
".",
"scale",
"/",
"this",
".",
"baseScale",
";",
"if",
"(",
"lng",
"<",
"(",
"-",
"180",
"+",
"centralMeridian",
")",
")",
"{",
"lng",
"+=",
"360",
";",
"}",
"point",
"=",
"jvm",
".",
"Proj",
"[",
"proj",
".",
"type",
"]",
"(",
"lat",
",",
"lng",
",",
"centralMeridian",
")",
";",
"inset",
"=",
"this",
".",
"getInsetForPoint",
"(",
"point",
".",
"x",
",",
"point",
".",
"y",
")",
";",
"if",
"(",
"inset",
")",
"{",
"bbox",
"=",
"inset",
".",
"bbox",
";",
"point",
".",
"x",
"=",
"(",
"point",
".",
"x",
"-",
"bbox",
"[",
"0",
"]",
".",
"x",
")",
"/",
"(",
"bbox",
"[",
"1",
"]",
".",
"x",
"-",
"bbox",
"[",
"0",
"]",
".",
"x",
")",
"*",
"inset",
".",
"width",
"*",
"this",
".",
"scale",
";",
"point",
".",
"y",
"=",
"(",
"point",
".",
"y",
"-",
"bbox",
"[",
"0",
"]",
".",
"y",
")",
"/",
"(",
"bbox",
"[",
"1",
"]",
".",
"y",
"-",
"bbox",
"[",
"0",
"]",
".",
"y",
")",
"*",
"inset",
".",
"height",
"*",
"this",
".",
"scale",
";",
"return",
"{",
"x",
":",
"point",
".",
"x",
"+",
"this",
".",
"transX",
"*",
"this",
".",
"scale",
"+",
"inset",
".",
"left",
"*",
"this",
".",
"scale",
",",
"y",
":",
"point",
".",
"y",
"+",
"this",
".",
"transY",
"*",
"this",
".",
"scale",
"+",
"inset",
".",
"top",
"*",
"this",
".",
"scale",
"}",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
@param {Number} lat Latitide of point in degrees.
@param {Number} lng Longitude of point in degrees.
|
[
"Converts",
"coordinates",
"expressed",
"as",
"latitude",
"and",
"longitude",
"to",
"the",
"coordinates",
"in",
"pixels",
"on",
"the",
"map",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L819-L849
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jvectormap/lib/world-map.js
|
function(x, y) {
var proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
insets = jvm.WorldMap.maps[this.params.map].insets,
i,
inset,
bbox,
nx,
ny;
for (i = 0; i < insets.length; i++) {
inset = insets[i];
bbox = inset.bbox;
nx = x - (this.transX*this.scale + inset.left*this.scale);
ny = y - (this.transY*this.scale + inset.top*this.scale);
nx = (nx / (inset.width * this.scale)) * (bbox[1].x - bbox[0].x) + bbox[0].x;
ny = (ny / (inset.height * this.scale)) * (bbox[1].y - bbox[0].y) + bbox[0].y;
if (nx > bbox[0].x && nx < bbox[1].x && ny > bbox[0].y && ny < bbox[1].y) {
return jvm.Proj[proj.type + '_inv'](nx, -ny, centralMeridian);
}
}
return false;
}
|
javascript
|
function(x, y) {
var proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
insets = jvm.WorldMap.maps[this.params.map].insets,
i,
inset,
bbox,
nx,
ny;
for (i = 0; i < insets.length; i++) {
inset = insets[i];
bbox = inset.bbox;
nx = x - (this.transX*this.scale + inset.left*this.scale);
ny = y - (this.transY*this.scale + inset.top*this.scale);
nx = (nx / (inset.width * this.scale)) * (bbox[1].x - bbox[0].x) + bbox[0].x;
ny = (ny / (inset.height * this.scale)) * (bbox[1].y - bbox[0].y) + bbox[0].y;
if (nx > bbox[0].x && nx < bbox[1].x && ny > bbox[0].y && ny < bbox[1].y) {
return jvm.Proj[proj.type + '_inv'](nx, -ny, centralMeridian);
}
}
return false;
}
|
[
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"proj",
"=",
"jvm",
".",
"WorldMap",
".",
"maps",
"[",
"this",
".",
"params",
".",
"map",
"]",
".",
"projection",
",",
"centralMeridian",
"=",
"proj",
".",
"centralMeridian",
",",
"insets",
"=",
"jvm",
".",
"WorldMap",
".",
"maps",
"[",
"this",
".",
"params",
".",
"map",
"]",
".",
"insets",
",",
"i",
",",
"inset",
",",
"bbox",
",",
"nx",
",",
"ny",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"insets",
".",
"length",
";",
"i",
"++",
")",
"{",
"inset",
"=",
"insets",
"[",
"i",
"]",
";",
"bbox",
"=",
"inset",
".",
"bbox",
";",
"nx",
"=",
"x",
"-",
"(",
"this",
".",
"transX",
"*",
"this",
".",
"scale",
"+",
"inset",
".",
"left",
"*",
"this",
".",
"scale",
")",
";",
"ny",
"=",
"y",
"-",
"(",
"this",
".",
"transY",
"*",
"this",
".",
"scale",
"+",
"inset",
".",
"top",
"*",
"this",
".",
"scale",
")",
";",
"nx",
"=",
"(",
"nx",
"/",
"(",
"inset",
".",
"width",
"*",
"this",
".",
"scale",
")",
")",
"*",
"(",
"bbox",
"[",
"1",
"]",
".",
"x",
"-",
"bbox",
"[",
"0",
"]",
".",
"x",
")",
"+",
"bbox",
"[",
"0",
"]",
".",
"x",
";",
"ny",
"=",
"(",
"ny",
"/",
"(",
"inset",
".",
"height",
"*",
"this",
".",
"scale",
")",
")",
"*",
"(",
"bbox",
"[",
"1",
"]",
".",
"y",
"-",
"bbox",
"[",
"0",
"]",
".",
"y",
")",
"+",
"bbox",
"[",
"0",
"]",
".",
"y",
";",
"if",
"(",
"nx",
">",
"bbox",
"[",
"0",
"]",
".",
"x",
"&&",
"nx",
"<",
"bbox",
"[",
"1",
"]",
".",
"x",
"&&",
"ny",
">",
"bbox",
"[",
"0",
"]",
".",
"y",
"&&",
"ny",
"<",
"bbox",
"[",
"1",
"]",
".",
"y",
")",
"{",
"return",
"jvm",
".",
"Proj",
"[",
"proj",
".",
"type",
"+",
"'_inv'",
"]",
"(",
"nx",
",",
"-",
"ny",
",",
"centralMeridian",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Converts cartesian coordinates into coordinates expressed as latitude and longitude.
@param {Number} x X-axis of point on map in pixels.
@param {Number} y Y-axis of point on map in pixels.
|
[
"Converts",
"cartesian",
"coordinates",
"into",
"coordinates",
"expressed",
"as",
"latitude",
"and",
"longitude",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L856-L882
|
train
|
|
ColorlibHQ/AdminLTE
|
plugins/input-mask/jquery.inputmask.date.extensions.js
|
function (chrs, buffer, pos, strict, opts) {
var isValid = opts.regex.val1.test(chrs);
if (!strict && !isValid) {
if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
isValid = opts.regex.val1.test("0" + chrs.charAt(0));
if (isValid) {
buffer[pos - 1] = "0";
return { "pos": pos, "c": chrs.charAt(0) };
}
}
}
return isValid;
}
|
javascript
|
function (chrs, buffer, pos, strict, opts) {
var isValid = opts.regex.val1.test(chrs);
if (!strict && !isValid) {
if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
isValid = opts.regex.val1.test("0" + chrs.charAt(0));
if (isValid) {
buffer[pos - 1] = "0";
return { "pos": pos, "c": chrs.charAt(0) };
}
}
}
return isValid;
}
|
[
"function",
"(",
"chrs",
",",
"buffer",
",",
"pos",
",",
"strict",
",",
"opts",
")",
"{",
"var",
"isValid",
"=",
"opts",
".",
"regex",
".",
"val1",
".",
"test",
"(",
"chrs",
")",
";",
"if",
"(",
"!",
"strict",
"&&",
"!",
"isValid",
")",
"{",
"if",
"(",
"chrs",
".",
"charAt",
"(",
"1",
")",
"==",
"opts",
".",
"separator",
"||",
"\"-./\"",
".",
"indexOf",
"(",
"chrs",
".",
"charAt",
"(",
"1",
")",
")",
"!=",
"-",
"1",
")",
"{",
"isValid",
"=",
"opts",
".",
"regex",
".",
"val1",
".",
"test",
"(",
"\"0\"",
"+",
"chrs",
".",
"charAt",
"(",
"0",
")",
")",
";",
"if",
"(",
"isValid",
")",
"{",
"buffer",
"[",
"pos",
"-",
"1",
"]",
"=",
"\"0\"",
";",
"return",
"{",
"\"pos\"",
":",
"pos",
",",
"\"c\"",
":",
"chrs",
".",
"charAt",
"(",
"0",
")",
"}",
";",
"}",
"}",
"}",
"return",
"isValid",
";",
"}"
] |
val1 ~ day or month
|
[
"val1",
"~",
"day",
"or",
"month"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/input-mask/jquery.inputmask.date.extensions.js#L86-L98
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (is_update) {
this.no_diapason = false;
this.coords.p_step = this.convertToPercent(this.options.step, true);
this.target = "base";
this.toggleInput();
this.append();
this.setMinMax();
if (is_update) {
this.force_redraw = true;
this.calc(true);
// callbacks called
this.callOnUpdate();
} else {
this.force_redraw = true;
this.calc(true);
// callbacks called
this.callOnStart();
}
this.updateScene();
}
|
javascript
|
function (is_update) {
this.no_diapason = false;
this.coords.p_step = this.convertToPercent(this.options.step, true);
this.target = "base";
this.toggleInput();
this.append();
this.setMinMax();
if (is_update) {
this.force_redraw = true;
this.calc(true);
// callbacks called
this.callOnUpdate();
} else {
this.force_redraw = true;
this.calc(true);
// callbacks called
this.callOnStart();
}
this.updateScene();
}
|
[
"function",
"(",
"is_update",
")",
"{",
"this",
".",
"no_diapason",
"=",
"false",
";",
"this",
".",
"coords",
".",
"p_step",
"=",
"this",
".",
"convertToPercent",
"(",
"this",
".",
"options",
".",
"step",
",",
"true",
")",
";",
"this",
".",
"target",
"=",
"\"base\"",
";",
"this",
".",
"toggleInput",
"(",
")",
";",
"this",
".",
"append",
"(",
")",
";",
"this",
".",
"setMinMax",
"(",
")",
";",
"if",
"(",
"is_update",
")",
"{",
"this",
".",
"force_redraw",
"=",
"true",
";",
"this",
".",
"calc",
"(",
"true",
")",
";",
"this",
".",
"callOnUpdate",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"force_redraw",
"=",
"true",
";",
"this",
".",
"calc",
"(",
"true",
")",
";",
"this",
".",
"callOnStart",
"(",
")",
";",
"}",
"this",
".",
"updateScene",
"(",
")",
";",
"}"
] |
Starts or updates the plugin instance
@param [is_update] {boolean}
|
[
"Starts",
"or",
"updates",
"the",
"plugin",
"instance"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L477-L502
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function () {
var min = this.options.min,
max = this.options.max,
from = this.options.from,
to = this.options.to;
if (from > min && to === max) {
this.$cache.s_from.addClass("type_last");
} else if (to < max) {
this.$cache.s_to.addClass("type_last");
}
}
|
javascript
|
function () {
var min = this.options.min,
max = this.options.max,
from = this.options.from,
to = this.options.to;
if (from > min && to === max) {
this.$cache.s_from.addClass("type_last");
} else if (to < max) {
this.$cache.s_to.addClass("type_last");
}
}
|
[
"function",
"(",
")",
"{",
"var",
"min",
"=",
"this",
".",
"options",
".",
"min",
",",
"max",
"=",
"this",
".",
"options",
".",
"max",
",",
"from",
"=",
"this",
".",
"options",
".",
"from",
",",
"to",
"=",
"this",
".",
"options",
".",
"to",
";",
"if",
"(",
"from",
">",
"min",
"&&",
"to",
"===",
"max",
")",
"{",
"this",
".",
"$cache",
".",
"s_from",
".",
"addClass",
"(",
"\"type_last\"",
")",
";",
"}",
"else",
"if",
"(",
"to",
"<",
"max",
")",
"{",
"this",
".",
"$cache",
".",
"s_to",
".",
"addClass",
"(",
"\"type_last\"",
")",
";",
"}",
"}"
] |
Determine which handler has a priority
works only for double slider type
|
[
"Determine",
"which",
"handler",
"has",
"a",
"priority",
"works",
"only",
"for",
"double",
"slider",
"type"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L578-L589
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (e) {
if (!this.target) {
var x;
var $handle;
if (this.options.type === "single") {
$handle = this.$cache.single;
} else {
$handle = this.$cache.from;
}
x = $handle.offset().left;
x += ($handle.width() / 2) - 1;
this.pointerClick("single", {preventDefault: function () {}, pageX: x});
}
}
|
javascript
|
function (e) {
if (!this.target) {
var x;
var $handle;
if (this.options.type === "single") {
$handle = this.$cache.single;
} else {
$handle = this.$cache.from;
}
x = $handle.offset().left;
x += ($handle.width() / 2) - 1;
this.pointerClick("single", {preventDefault: function () {}, pageX: x});
}
}
|
[
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"this",
".",
"target",
")",
"{",
"var",
"x",
";",
"var",
"$handle",
";",
"if",
"(",
"this",
".",
"options",
".",
"type",
"===",
"\"single\"",
")",
"{",
"$handle",
"=",
"this",
".",
"$cache",
".",
"single",
";",
"}",
"else",
"{",
"$handle",
"=",
"this",
".",
"$cache",
".",
"from",
";",
"}",
"x",
"=",
"$handle",
".",
"offset",
"(",
")",
".",
"left",
";",
"x",
"+=",
"(",
"$handle",
".",
"width",
"(",
")",
"/",
"2",
")",
"-",
"1",
";",
"this",
".",
"pointerClick",
"(",
"\"single\"",
",",
"{",
"preventDefault",
":",
"function",
"(",
")",
"{",
"}",
",",
"pageX",
":",
"x",
"}",
")",
";",
"}",
"}"
] |
Focus with tabIndex
@param e {Object} event object
|
[
"Focus",
"with",
"tabIndex"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L742-L758
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (e) {
if (!this.dragging) {
return;
}
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
this.coords.x_pointer = x - this.coords.x_gap;
this.calc();
}
|
javascript
|
function (e) {
if (!this.dragging) {
return;
}
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
this.coords.x_pointer = x - this.coords.x_gap;
this.calc();
}
|
[
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"this",
".",
"dragging",
")",
"{",
"return",
";",
"}",
"var",
"x",
"=",
"e",
".",
"pageX",
"||",
"e",
".",
"originalEvent",
".",
"touches",
"&&",
"e",
".",
"originalEvent",
".",
"touches",
"[",
"0",
"]",
".",
"pageX",
";",
"this",
".",
"coords",
".",
"x_pointer",
"=",
"x",
"-",
"this",
".",
"coords",
".",
"x_gap",
";",
"this",
".",
"calc",
"(",
")",
";",
"}"
] |
Mousemove or touchmove
only for handlers
@param e {Object} event object
|
[
"Mousemove",
"or",
"touchmove",
"only",
"for",
"handlers"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L766-L775
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (e) {
if (this.current_plugin !== this.plugin_count) {
return;
}
if (this.is_active) {
this.is_active = false;
} else {
return;
}
this.$cache.cont.find(".state_hover").removeClass("state_hover");
this.force_redraw = true;
if (is_old_ie) {
$("*").prop("unselectable", false);
}
this.updateScene();
this.restoreOriginalMinInterval();
// callbacks call
if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {
this.callOnFinish();
}
this.dragging = false;
}
|
javascript
|
function (e) {
if (this.current_plugin !== this.plugin_count) {
return;
}
if (this.is_active) {
this.is_active = false;
} else {
return;
}
this.$cache.cont.find(".state_hover").removeClass("state_hover");
this.force_redraw = true;
if (is_old_ie) {
$("*").prop("unselectable", false);
}
this.updateScene();
this.restoreOriginalMinInterval();
// callbacks call
if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {
this.callOnFinish();
}
this.dragging = false;
}
|
[
"function",
"(",
"e",
")",
"{",
"if",
"(",
"this",
".",
"current_plugin",
"!==",
"this",
".",
"plugin_count",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"is_active",
")",
"{",
"this",
".",
"is_active",
"=",
"false",
";",
"}",
"else",
"{",
"return",
";",
"}",
"this",
".",
"$cache",
".",
"cont",
".",
"find",
"(",
"\".state_hover\"",
")",
".",
"removeClass",
"(",
"\"state_hover\"",
")",
";",
"this",
".",
"force_redraw",
"=",
"true",
";",
"if",
"(",
"is_old_ie",
")",
"{",
"$",
"(",
"\"*\"",
")",
".",
"prop",
"(",
"\"unselectable\"",
",",
"false",
")",
";",
"}",
"this",
".",
"updateScene",
"(",
")",
";",
"this",
".",
"restoreOriginalMinInterval",
"(",
")",
";",
"if",
"(",
"$",
".",
"contains",
"(",
"this",
".",
"$cache",
".",
"cont",
"[",
"0",
"]",
",",
"e",
".",
"target",
")",
"||",
"this",
".",
"dragging",
")",
"{",
"this",
".",
"callOnFinish",
"(",
")",
";",
"}",
"this",
".",
"dragging",
"=",
"false",
";",
"}"
] |
Mouseup or touchend
only for handlers
@param e {Object} event object
|
[
"Mouseup",
"or",
"touchend",
"only",
"for",
"handlers"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L783-L811
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (target, e) {
e.preventDefault();
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
if (e.button === 2) {
return;
}
if (target === "both") {
this.setTempMinInterval();
}
if (!target) {
target = this.target || "from";
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_active = true;
this.dragging = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = x - this.coords.x_gap;
this.calcPointerPercent();
this.changeLevel(target);
if (is_old_ie) {
$("*").prop("unselectable", true);
}
this.$cache.line.trigger("focus");
this.updateScene();
}
|
javascript
|
function (target, e) {
e.preventDefault();
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
if (e.button === 2) {
return;
}
if (target === "both") {
this.setTempMinInterval();
}
if (!target) {
target = this.target || "from";
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_active = true;
this.dragging = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = x - this.coords.x_gap;
this.calcPointerPercent();
this.changeLevel(target);
if (is_old_ie) {
$("*").prop("unselectable", true);
}
this.$cache.line.trigger("focus");
this.updateScene();
}
|
[
"function",
"(",
"target",
",",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"x",
"=",
"e",
".",
"pageX",
"||",
"e",
".",
"originalEvent",
".",
"touches",
"&&",
"e",
".",
"originalEvent",
".",
"touches",
"[",
"0",
"]",
".",
"pageX",
";",
"if",
"(",
"e",
".",
"button",
"===",
"2",
")",
"{",
"return",
";",
"}",
"if",
"(",
"target",
"===",
"\"both\"",
")",
"{",
"this",
".",
"setTempMinInterval",
"(",
")",
";",
"}",
"if",
"(",
"!",
"target",
")",
"{",
"target",
"=",
"this",
".",
"target",
"||",
"\"from\"",
";",
"}",
"this",
".",
"current_plugin",
"=",
"this",
".",
"plugin_count",
";",
"this",
".",
"target",
"=",
"target",
";",
"this",
".",
"is_active",
"=",
"true",
";",
"this",
".",
"dragging",
"=",
"true",
";",
"this",
".",
"coords",
".",
"x_gap",
"=",
"this",
".",
"$cache",
".",
"rs",
".",
"offset",
"(",
")",
".",
"left",
";",
"this",
".",
"coords",
".",
"x_pointer",
"=",
"x",
"-",
"this",
".",
"coords",
".",
"x_gap",
";",
"this",
".",
"calcPointerPercent",
"(",
")",
";",
"this",
".",
"changeLevel",
"(",
"target",
")",
";",
"if",
"(",
"is_old_ie",
")",
"{",
"$",
"(",
"\"*\"",
")",
".",
"prop",
"(",
"\"unselectable\"",
",",
"true",
")",
";",
"}",
"this",
".",
"$cache",
".",
"line",
".",
"trigger",
"(",
"\"focus\"",
")",
";",
"this",
".",
"updateScene",
"(",
")",
";",
"}"
] |
Mousedown or touchstart
only for handlers
@param target {String|null}
@param e {Object} event object
|
[
"Mousedown",
"or",
"touchstart",
"only",
"for",
"handlers"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L820-L854
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (target, e) {
e.preventDefault();
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
if (e.button === 2) {
return;
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_click = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = +(x - this.coords.x_gap).toFixed();
this.force_redraw = true;
this.calc();
this.$cache.line.trigger("focus");
}
|
javascript
|
function (target, e) {
e.preventDefault();
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
if (e.button === 2) {
return;
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_click = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = +(x - this.coords.x_gap).toFixed();
this.force_redraw = true;
this.calc();
this.$cache.line.trigger("focus");
}
|
[
"function",
"(",
"target",
",",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"x",
"=",
"e",
".",
"pageX",
"||",
"e",
".",
"originalEvent",
".",
"touches",
"&&",
"e",
".",
"originalEvent",
".",
"touches",
"[",
"0",
"]",
".",
"pageX",
";",
"if",
"(",
"e",
".",
"button",
"===",
"2",
")",
"{",
"return",
";",
"}",
"this",
".",
"current_plugin",
"=",
"this",
".",
"plugin_count",
";",
"this",
".",
"target",
"=",
"target",
";",
"this",
".",
"is_click",
"=",
"true",
";",
"this",
".",
"coords",
".",
"x_gap",
"=",
"this",
".",
"$cache",
".",
"rs",
".",
"offset",
"(",
")",
".",
"left",
";",
"this",
".",
"coords",
".",
"x_pointer",
"=",
"+",
"(",
"x",
"-",
"this",
".",
"coords",
".",
"x_gap",
")",
".",
"toFixed",
"(",
")",
";",
"this",
".",
"force_redraw",
"=",
"true",
";",
"this",
".",
"calc",
"(",
")",
";",
"this",
".",
"$cache",
".",
"line",
".",
"trigger",
"(",
"\"focus\"",
")",
";",
"}"
] |
Mousedown or touchstart
for other slider elements, like diapason line
@param target {String}
@param e {Object} event object
|
[
"Mousedown",
"or",
"touchstart",
"for",
"other",
"slider",
"elements",
"like",
"diapason",
"line"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L863-L881
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (target, e) {
if (this.current_plugin !== this.plugin_count || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
return;
}
switch (e.which) {
case 83: // W
case 65: // A
case 40: // DOWN
case 37: // LEFT
e.preventDefault();
this.moveByKey(false);
break;
case 87: // S
case 68: // D
case 38: // UP
case 39: // RIGHT
e.preventDefault();
this.moveByKey(true);
break;
}
return true;
}
|
javascript
|
function (target, e) {
if (this.current_plugin !== this.plugin_count || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
return;
}
switch (e.which) {
case 83: // W
case 65: // A
case 40: // DOWN
case 37: // LEFT
e.preventDefault();
this.moveByKey(false);
break;
case 87: // S
case 68: // D
case 38: // UP
case 39: // RIGHT
e.preventDefault();
this.moveByKey(true);
break;
}
return true;
}
|
[
"function",
"(",
"target",
",",
"e",
")",
"{",
"if",
"(",
"this",
".",
"current_plugin",
"!==",
"this",
".",
"plugin_count",
"||",
"e",
".",
"altKey",
"||",
"e",
".",
"ctrlKey",
"||",
"e",
".",
"shiftKey",
"||",
"e",
".",
"metaKey",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"e",
".",
"which",
")",
"{",
"case",
"83",
":",
"case",
"65",
":",
"case",
"40",
":",
"case",
"37",
":",
"e",
".",
"preventDefault",
"(",
")",
";",
"this",
".",
"moveByKey",
"(",
"false",
")",
";",
"break",
";",
"case",
"87",
":",
"case",
"68",
":",
"case",
"38",
":",
"case",
"39",
":",
"e",
".",
"preventDefault",
"(",
")",
";",
"this",
".",
"moveByKey",
"(",
"true",
")",
";",
"break",
";",
"}",
"return",
"true",
";",
"}"
] |
Keyborard controls for focused slider
@param target {String}
@param e {Object} event object
@returns {boolean|undefined}
|
[
"Keyborard",
"controls",
"for",
"focused",
"slider"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L890-L914
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (right) {
var p = this.coords.p_pointer;
var p_step = (this.options.max - this.options.min) / 100;
p_step = this.options.step / p_step;
if (right) {
p += p_step;
} else {
p -= p_step;
}
this.coords.x_pointer = this.toFixed(this.coords.w_rs / 100 * p);
this.is_key = true;
this.calc();
}
|
javascript
|
function (right) {
var p = this.coords.p_pointer;
var p_step = (this.options.max - this.options.min) / 100;
p_step = this.options.step / p_step;
if (right) {
p += p_step;
} else {
p -= p_step;
}
this.coords.x_pointer = this.toFixed(this.coords.w_rs / 100 * p);
this.is_key = true;
this.calc();
}
|
[
"function",
"(",
"right",
")",
"{",
"var",
"p",
"=",
"this",
".",
"coords",
".",
"p_pointer",
";",
"var",
"p_step",
"=",
"(",
"this",
".",
"options",
".",
"max",
"-",
"this",
".",
"options",
".",
"min",
")",
"/",
"100",
";",
"p_step",
"=",
"this",
".",
"options",
".",
"step",
"/",
"p_step",
";",
"if",
"(",
"right",
")",
"{",
"p",
"+=",
"p_step",
";",
"}",
"else",
"{",
"p",
"-=",
"p_step",
";",
"}",
"this",
".",
"coords",
".",
"x_pointer",
"=",
"this",
".",
"toFixed",
"(",
"this",
".",
"coords",
".",
"w_rs",
"/",
"100",
"*",
"p",
")",
";",
"this",
".",
"is_key",
"=",
"true",
";",
"this",
".",
"calc",
"(",
")",
";",
"}"
] |
Move by key
@param right {boolean} direction to move
|
[
"Move",
"by",
"key"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L921-L935
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function () {
var interval = this.result.to - this.result.from;
if (this.old_min_interval === null) {
this.old_min_interval = this.options.min_interval;
}
this.options.min_interval = interval;
}
|
javascript
|
function () {
var interval = this.result.to - this.result.from;
if (this.old_min_interval === null) {
this.old_min_interval = this.options.min_interval;
}
this.options.min_interval = interval;
}
|
[
"function",
"(",
")",
"{",
"var",
"interval",
"=",
"this",
".",
"result",
".",
"to",
"-",
"this",
".",
"result",
".",
"from",
";",
"if",
"(",
"this",
".",
"old_min_interval",
"===",
"null",
")",
"{",
"this",
".",
"old_min_interval",
"=",
"this",
".",
"options",
".",
"min_interval",
";",
"}",
"this",
".",
"options",
".",
"min_interval",
"=",
"interval",
";",
"}"
] |
Then dragging interval, prevent interval collapsing
using min_interval option
|
[
"Then",
"dragging",
"interval",
"prevent",
"interval",
"collapsing",
"using",
"min_interval",
"option"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L974-L982
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function () {
if (!this.coords.w_rs) {
this.coords.p_pointer = 0;
return;
}
if (this.coords.x_pointer < 0 || isNaN(this.coords.x_pointer) ) {
this.coords.x_pointer = 0;
} else if (this.coords.x_pointer > this.coords.w_rs) {
this.coords.x_pointer = this.coords.w_rs;
}
this.coords.p_pointer = this.toFixed(this.coords.x_pointer / this.coords.w_rs * 100);
}
|
javascript
|
function () {
if (!this.coords.w_rs) {
this.coords.p_pointer = 0;
return;
}
if (this.coords.x_pointer < 0 || isNaN(this.coords.x_pointer) ) {
this.coords.x_pointer = 0;
} else if (this.coords.x_pointer > this.coords.w_rs) {
this.coords.x_pointer = this.coords.w_rs;
}
this.coords.p_pointer = this.toFixed(this.coords.x_pointer / this.coords.w_rs * 100);
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"coords",
".",
"w_rs",
")",
"{",
"this",
".",
"coords",
".",
"p_pointer",
"=",
"0",
";",
"return",
";",
"}",
"if",
"(",
"this",
".",
"coords",
".",
"x_pointer",
"<",
"0",
"||",
"isNaN",
"(",
"this",
".",
"coords",
".",
"x_pointer",
")",
")",
"{",
"this",
".",
"coords",
".",
"x_pointer",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"this",
".",
"coords",
".",
"x_pointer",
">",
"this",
".",
"coords",
".",
"w_rs",
")",
"{",
"this",
".",
"coords",
".",
"x_pointer",
"=",
"this",
".",
"coords",
".",
"w_rs",
";",
"}",
"this",
".",
"coords",
".",
"p_pointer",
"=",
"this",
".",
"toFixed",
"(",
"this",
".",
"coords",
".",
"x_pointer",
"/",
"this",
".",
"coords",
".",
"w_rs",
"*",
"100",
")",
";",
"}"
] |
calculates pointer X in percent
|
[
"calculates",
"pointer",
"X",
"in",
"percent"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1204-L1217
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (real_x) {
if (this.options.type === "single") {
return "single";
} else {
var m_point = this.coords.p_from_real + ((this.coords.p_to_real - this.coords.p_from_real) / 2);
if (real_x >= m_point) {
return this.options.to_fixed ? "from" : "to";
} else {
return this.options.from_fixed ? "to" : "from";
}
}
}
|
javascript
|
function (real_x) {
if (this.options.type === "single") {
return "single";
} else {
var m_point = this.coords.p_from_real + ((this.coords.p_to_real - this.coords.p_from_real) / 2);
if (real_x >= m_point) {
return this.options.to_fixed ? "from" : "to";
} else {
return this.options.from_fixed ? "to" : "from";
}
}
}
|
[
"function",
"(",
"real_x",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"type",
"===",
"\"single\"",
")",
"{",
"return",
"\"single\"",
";",
"}",
"else",
"{",
"var",
"m_point",
"=",
"this",
".",
"coords",
".",
"p_from_real",
"+",
"(",
"(",
"this",
".",
"coords",
".",
"p_to_real",
"-",
"this",
".",
"coords",
".",
"p_from_real",
")",
"/",
"2",
")",
";",
"if",
"(",
"real_x",
">=",
"m_point",
")",
"{",
"return",
"this",
".",
"options",
".",
"to_fixed",
"?",
"\"from\"",
":",
"\"to\"",
";",
"}",
"else",
"{",
"return",
"this",
".",
"options",
".",
"from_fixed",
"?",
"\"to\"",
":",
"\"from\"",
";",
"}",
"}",
"}"
] |
Find closest handle to pointer click
@param real_x {Number}
@returns {String}
|
[
"Find",
"closest",
"handle",
"to",
"pointer",
"click"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1258-L1269
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function () {
if (!this.coords.w_rs) {
return;
}
this.labels.p_min = this.labels.w_min / this.coords.w_rs * 100;
this.labels.p_max = this.labels.w_max / this.coords.w_rs * 100;
}
|
javascript
|
function () {
if (!this.coords.w_rs) {
return;
}
this.labels.p_min = this.labels.w_min / this.coords.w_rs * 100;
this.labels.p_max = this.labels.w_max / this.coords.w_rs * 100;
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"coords",
".",
"w_rs",
")",
"{",
"return",
";",
"}",
"this",
".",
"labels",
".",
"p_min",
"=",
"this",
".",
"labels",
".",
"w_min",
"/",
"this",
".",
"coords",
".",
"w_rs",
"*",
"100",
";",
"this",
".",
"labels",
".",
"p_max",
"=",
"this",
".",
"labels",
".",
"w_max",
"/",
"this",
".",
"coords",
".",
"w_rs",
"*",
"100",
";",
"}"
] |
Measure Min and Max labels width in percent
|
[
"Measure",
"Min",
"and",
"Max",
"labels",
"width",
"in",
"percent"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1274-L1281
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function () {
if (!this.coords.w_rs || this.options.hide_from_to) {
return;
}
if (this.options.type === "single") {
this.labels.w_single = this.$cache.single.outerWidth(false);
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
this.labels.p_single_left = this.coords.p_single_fake + (this.coords.p_handle / 2) - (this.labels.p_single_fake / 2);
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
} else {
this.labels.w_from = this.$cache.from.outerWidth(false);
this.labels.p_from_fake = this.labels.w_from / this.coords.w_rs * 100;
this.labels.p_from_left = this.coords.p_from_fake + (this.coords.p_handle / 2) - (this.labels.p_from_fake / 2);
this.labels.p_from_left = this.toFixed(this.labels.p_from_left);
this.labels.p_from_left = this.checkEdges(this.labels.p_from_left, this.labels.p_from_fake);
this.labels.w_to = this.$cache.to.outerWidth(false);
this.labels.p_to_fake = this.labels.w_to / this.coords.w_rs * 100;
this.labels.p_to_left = this.coords.p_to_fake + (this.coords.p_handle / 2) - (this.labels.p_to_fake / 2);
this.labels.p_to_left = this.toFixed(this.labels.p_to_left);
this.labels.p_to_left = this.checkEdges(this.labels.p_to_left, this.labels.p_to_fake);
this.labels.w_single = this.$cache.single.outerWidth(false);
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
this.labels.p_single_left = ((this.labels.p_from_left + this.labels.p_to_left + this.labels.p_to_fake) / 2) - (this.labels.p_single_fake / 2);
this.labels.p_single_left = this.toFixed(this.labels.p_single_left);
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
}
}
|
javascript
|
function () {
if (!this.coords.w_rs || this.options.hide_from_to) {
return;
}
if (this.options.type === "single") {
this.labels.w_single = this.$cache.single.outerWidth(false);
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
this.labels.p_single_left = this.coords.p_single_fake + (this.coords.p_handle / 2) - (this.labels.p_single_fake / 2);
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
} else {
this.labels.w_from = this.$cache.from.outerWidth(false);
this.labels.p_from_fake = this.labels.w_from / this.coords.w_rs * 100;
this.labels.p_from_left = this.coords.p_from_fake + (this.coords.p_handle / 2) - (this.labels.p_from_fake / 2);
this.labels.p_from_left = this.toFixed(this.labels.p_from_left);
this.labels.p_from_left = this.checkEdges(this.labels.p_from_left, this.labels.p_from_fake);
this.labels.w_to = this.$cache.to.outerWidth(false);
this.labels.p_to_fake = this.labels.w_to / this.coords.w_rs * 100;
this.labels.p_to_left = this.coords.p_to_fake + (this.coords.p_handle / 2) - (this.labels.p_to_fake / 2);
this.labels.p_to_left = this.toFixed(this.labels.p_to_left);
this.labels.p_to_left = this.checkEdges(this.labels.p_to_left, this.labels.p_to_fake);
this.labels.w_single = this.$cache.single.outerWidth(false);
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
this.labels.p_single_left = ((this.labels.p_from_left + this.labels.p_to_left + this.labels.p_to_fake) / 2) - (this.labels.p_single_fake / 2);
this.labels.p_single_left = this.toFixed(this.labels.p_single_left);
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"coords",
".",
"w_rs",
"||",
"this",
".",
"options",
".",
"hide_from_to",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"options",
".",
"type",
"===",
"\"single\"",
")",
"{",
"this",
".",
"labels",
".",
"w_single",
"=",
"this",
".",
"$cache",
".",
"single",
".",
"outerWidth",
"(",
"false",
")",
";",
"this",
".",
"labels",
".",
"p_single_fake",
"=",
"this",
".",
"labels",
".",
"w_single",
"/",
"this",
".",
"coords",
".",
"w_rs",
"*",
"100",
";",
"this",
".",
"labels",
".",
"p_single_left",
"=",
"this",
".",
"coords",
".",
"p_single_fake",
"+",
"(",
"this",
".",
"coords",
".",
"p_handle",
"/",
"2",
")",
"-",
"(",
"this",
".",
"labels",
".",
"p_single_fake",
"/",
"2",
")",
";",
"this",
".",
"labels",
".",
"p_single_left",
"=",
"this",
".",
"checkEdges",
"(",
"this",
".",
"labels",
".",
"p_single_left",
",",
"this",
".",
"labels",
".",
"p_single_fake",
")",
";",
"}",
"else",
"{",
"this",
".",
"labels",
".",
"w_from",
"=",
"this",
".",
"$cache",
".",
"from",
".",
"outerWidth",
"(",
"false",
")",
";",
"this",
".",
"labels",
".",
"p_from_fake",
"=",
"this",
".",
"labels",
".",
"w_from",
"/",
"this",
".",
"coords",
".",
"w_rs",
"*",
"100",
";",
"this",
".",
"labels",
".",
"p_from_left",
"=",
"this",
".",
"coords",
".",
"p_from_fake",
"+",
"(",
"this",
".",
"coords",
".",
"p_handle",
"/",
"2",
")",
"-",
"(",
"this",
".",
"labels",
".",
"p_from_fake",
"/",
"2",
")",
";",
"this",
".",
"labels",
".",
"p_from_left",
"=",
"this",
".",
"toFixed",
"(",
"this",
".",
"labels",
".",
"p_from_left",
")",
";",
"this",
".",
"labels",
".",
"p_from_left",
"=",
"this",
".",
"checkEdges",
"(",
"this",
".",
"labels",
".",
"p_from_left",
",",
"this",
".",
"labels",
".",
"p_from_fake",
")",
";",
"this",
".",
"labels",
".",
"w_to",
"=",
"this",
".",
"$cache",
".",
"to",
".",
"outerWidth",
"(",
"false",
")",
";",
"this",
".",
"labels",
".",
"p_to_fake",
"=",
"this",
".",
"labels",
".",
"w_to",
"/",
"this",
".",
"coords",
".",
"w_rs",
"*",
"100",
";",
"this",
".",
"labels",
".",
"p_to_left",
"=",
"this",
".",
"coords",
".",
"p_to_fake",
"+",
"(",
"this",
".",
"coords",
".",
"p_handle",
"/",
"2",
")",
"-",
"(",
"this",
".",
"labels",
".",
"p_to_fake",
"/",
"2",
")",
";",
"this",
".",
"labels",
".",
"p_to_left",
"=",
"this",
".",
"toFixed",
"(",
"this",
".",
"labels",
".",
"p_to_left",
")",
";",
"this",
".",
"labels",
".",
"p_to_left",
"=",
"this",
".",
"checkEdges",
"(",
"this",
".",
"labels",
".",
"p_to_left",
",",
"this",
".",
"labels",
".",
"p_to_fake",
")",
";",
"this",
".",
"labels",
".",
"w_single",
"=",
"this",
".",
"$cache",
".",
"single",
".",
"outerWidth",
"(",
"false",
")",
";",
"this",
".",
"labels",
".",
"p_single_fake",
"=",
"this",
".",
"labels",
".",
"w_single",
"/",
"this",
".",
"coords",
".",
"w_rs",
"*",
"100",
";",
"this",
".",
"labels",
".",
"p_single_left",
"=",
"(",
"(",
"this",
".",
"labels",
".",
"p_from_left",
"+",
"this",
".",
"labels",
".",
"p_to_left",
"+",
"this",
".",
"labels",
".",
"p_to_fake",
")",
"/",
"2",
")",
"-",
"(",
"this",
".",
"labels",
".",
"p_single_fake",
"/",
"2",
")",
";",
"this",
".",
"labels",
".",
"p_single_left",
"=",
"this",
".",
"toFixed",
"(",
"this",
".",
"labels",
".",
"p_single_left",
")",
";",
"this",
".",
"labels",
".",
"p_single_left",
"=",
"this",
".",
"checkEdges",
"(",
"this",
".",
"labels",
".",
"p_single_left",
",",
"this",
".",
"labels",
".",
"p_single_fake",
")",
";",
"}",
"}"
] |
Measure labels width and X in percent
|
[
"Measure",
"labels",
"width",
"and",
"X",
"in",
"percent"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1286-L1319
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function () {
if (this.options.type === "single") {
if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value);
} else {
this.$cache.input.prop("value", this.result.from);
}
this.$cache.input.data("from", this.result.from);
} else {
if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value + this.options.input_values_separator + this.result.to_value);
} else {
this.$cache.input.prop("value", this.result.from + this.options.input_values_separator + this.result.to);
}
this.$cache.input.data("from", this.result.from);
this.$cache.input.data("to", this.result.to);
}
}
|
javascript
|
function () {
if (this.options.type === "single") {
if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value);
} else {
this.$cache.input.prop("value", this.result.from);
}
this.$cache.input.data("from", this.result.from);
} else {
if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value + this.options.input_values_separator + this.result.to_value);
} else {
this.$cache.input.prop("value", this.result.from + this.options.input_values_separator + this.result.to);
}
this.$cache.input.data("from", this.result.from);
this.$cache.input.data("to", this.result.to);
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"type",
"===",
"\"single\"",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"values",
".",
"length",
")",
"{",
"this",
".",
"$cache",
".",
"input",
".",
"prop",
"(",
"\"value\"",
",",
"this",
".",
"result",
".",
"from_value",
")",
";",
"}",
"else",
"{",
"this",
".",
"$cache",
".",
"input",
".",
"prop",
"(",
"\"value\"",
",",
"this",
".",
"result",
".",
"from",
")",
";",
"}",
"this",
".",
"$cache",
".",
"input",
".",
"data",
"(",
"\"from\"",
",",
"this",
".",
"result",
".",
"from",
")",
";",
"}",
"else",
"{",
"if",
"(",
"this",
".",
"options",
".",
"values",
".",
"length",
")",
"{",
"this",
".",
"$cache",
".",
"input",
".",
"prop",
"(",
"\"value\"",
",",
"this",
".",
"result",
".",
"from_value",
"+",
"this",
".",
"options",
".",
"input_values_separator",
"+",
"this",
".",
"result",
".",
"to_value",
")",
";",
"}",
"else",
"{",
"this",
".",
"$cache",
".",
"input",
".",
"prop",
"(",
"\"value\"",
",",
"this",
".",
"result",
".",
"from",
"+",
"this",
".",
"options",
".",
"input_values_separator",
"+",
"this",
".",
"result",
".",
"to",
")",
";",
"}",
"this",
".",
"$cache",
".",
"input",
".",
"data",
"(",
"\"from\"",
",",
"this",
".",
"result",
".",
"from",
")",
";",
"this",
".",
"$cache",
".",
"input",
".",
"data",
"(",
"\"to\"",
",",
"this",
".",
"result",
".",
"to",
")",
";",
"}",
"}"
] |
Write values to input element
|
[
"Write",
"values",
"to",
"input",
"element"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1649-L1666
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (value, no_min) {
var diapason = this.options.max - this.options.min,
one_percent = diapason / 100,
val, percent;
if (!diapason) {
this.no_diapason = true;
return 0;
}
if (no_min) {
val = value;
} else {
val = value - this.options.min;
}
percent = val / one_percent;
return this.toFixed(percent);
}
|
javascript
|
function (value, no_min) {
var diapason = this.options.max - this.options.min,
one_percent = diapason / 100,
val, percent;
if (!diapason) {
this.no_diapason = true;
return 0;
}
if (no_min) {
val = value;
} else {
val = value - this.options.min;
}
percent = val / one_percent;
return this.toFixed(percent);
}
|
[
"function",
"(",
"value",
",",
"no_min",
")",
"{",
"var",
"diapason",
"=",
"this",
".",
"options",
".",
"max",
"-",
"this",
".",
"options",
".",
"min",
",",
"one_percent",
"=",
"diapason",
"/",
"100",
",",
"val",
",",
"percent",
";",
"if",
"(",
"!",
"diapason",
")",
"{",
"this",
".",
"no_diapason",
"=",
"true",
";",
"return",
"0",
";",
"}",
"if",
"(",
"no_min",
")",
"{",
"val",
"=",
"value",
";",
"}",
"else",
"{",
"val",
"=",
"value",
"-",
"this",
".",
"options",
".",
"min",
";",
"}",
"percent",
"=",
"val",
"/",
"one_percent",
";",
"return",
"this",
".",
"toFixed",
"(",
"percent",
")",
";",
"}"
] |
Convert real value to percent
@param value {Number} X in real
@param no_min {boolean=} don't use min value
@returns {Number} X in percent
|
[
"Convert",
"real",
"value",
"to",
"percent"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1743-L1762
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (percent) {
var min = this.options.min,
max = this.options.max,
min_decimals = min.toString().split(".")[1],
max_decimals = max.toString().split(".")[1],
min_length, max_length,
avg_decimals = 0,
abs = 0;
if (percent === 0) {
return this.options.min;
}
if (percent === 100) {
return this.options.max;
}
if (min_decimals) {
min_length = min_decimals.length;
avg_decimals = min_length;
}
if (max_decimals) {
max_length = max_decimals.length;
avg_decimals = max_length;
}
if (min_length && max_length) {
avg_decimals = (min_length >= max_length) ? min_length : max_length;
}
if (min < 0) {
abs = Math.abs(min);
min = +(min + abs).toFixed(avg_decimals);
max = +(max + abs).toFixed(avg_decimals);
}
var number = ((max - min) / 100 * percent) + min,
string = this.options.step.toString().split(".")[1],
result;
if (string) {
number = +number.toFixed(string.length);
} else {
number = number / this.options.step;
number = number * this.options.step;
number = +number.toFixed(0);
}
if (abs) {
number -= abs;
}
if (string) {
result = +number.toFixed(string.length);
} else {
result = this.toFixed(number);
}
if (result < this.options.min) {
result = this.options.min;
} else if (result > this.options.max) {
result = this.options.max;
}
return result;
}
|
javascript
|
function (percent) {
var min = this.options.min,
max = this.options.max,
min_decimals = min.toString().split(".")[1],
max_decimals = max.toString().split(".")[1],
min_length, max_length,
avg_decimals = 0,
abs = 0;
if (percent === 0) {
return this.options.min;
}
if (percent === 100) {
return this.options.max;
}
if (min_decimals) {
min_length = min_decimals.length;
avg_decimals = min_length;
}
if (max_decimals) {
max_length = max_decimals.length;
avg_decimals = max_length;
}
if (min_length && max_length) {
avg_decimals = (min_length >= max_length) ? min_length : max_length;
}
if (min < 0) {
abs = Math.abs(min);
min = +(min + abs).toFixed(avg_decimals);
max = +(max + abs).toFixed(avg_decimals);
}
var number = ((max - min) / 100 * percent) + min,
string = this.options.step.toString().split(".")[1],
result;
if (string) {
number = +number.toFixed(string.length);
} else {
number = number / this.options.step;
number = number * this.options.step;
number = +number.toFixed(0);
}
if (abs) {
number -= abs;
}
if (string) {
result = +number.toFixed(string.length);
} else {
result = this.toFixed(number);
}
if (result < this.options.min) {
result = this.options.min;
} else if (result > this.options.max) {
result = this.options.max;
}
return result;
}
|
[
"function",
"(",
"percent",
")",
"{",
"var",
"min",
"=",
"this",
".",
"options",
".",
"min",
",",
"max",
"=",
"this",
".",
"options",
".",
"max",
",",
"min_decimals",
"=",
"min",
".",
"toString",
"(",
")",
".",
"split",
"(",
"\".\"",
")",
"[",
"1",
"]",
",",
"max_decimals",
"=",
"max",
".",
"toString",
"(",
")",
".",
"split",
"(",
"\".\"",
")",
"[",
"1",
"]",
",",
"min_length",
",",
"max_length",
",",
"avg_decimals",
"=",
"0",
",",
"abs",
"=",
"0",
";",
"if",
"(",
"percent",
"===",
"0",
")",
"{",
"return",
"this",
".",
"options",
".",
"min",
";",
"}",
"if",
"(",
"percent",
"===",
"100",
")",
"{",
"return",
"this",
".",
"options",
".",
"max",
";",
"}",
"if",
"(",
"min_decimals",
")",
"{",
"min_length",
"=",
"min_decimals",
".",
"length",
";",
"avg_decimals",
"=",
"min_length",
";",
"}",
"if",
"(",
"max_decimals",
")",
"{",
"max_length",
"=",
"max_decimals",
".",
"length",
";",
"avg_decimals",
"=",
"max_length",
";",
"}",
"if",
"(",
"min_length",
"&&",
"max_length",
")",
"{",
"avg_decimals",
"=",
"(",
"min_length",
">=",
"max_length",
")",
"?",
"min_length",
":",
"max_length",
";",
"}",
"if",
"(",
"min",
"<",
"0",
")",
"{",
"abs",
"=",
"Math",
".",
"abs",
"(",
"min",
")",
";",
"min",
"=",
"+",
"(",
"min",
"+",
"abs",
")",
".",
"toFixed",
"(",
"avg_decimals",
")",
";",
"max",
"=",
"+",
"(",
"max",
"+",
"abs",
")",
".",
"toFixed",
"(",
"avg_decimals",
")",
";",
"}",
"var",
"number",
"=",
"(",
"(",
"max",
"-",
"min",
")",
"/",
"100",
"*",
"percent",
")",
"+",
"min",
",",
"string",
"=",
"this",
".",
"options",
".",
"step",
".",
"toString",
"(",
")",
".",
"split",
"(",
"\".\"",
")",
"[",
"1",
"]",
",",
"result",
";",
"if",
"(",
"string",
")",
"{",
"number",
"=",
"+",
"number",
".",
"toFixed",
"(",
"string",
".",
"length",
")",
";",
"}",
"else",
"{",
"number",
"=",
"number",
"/",
"this",
".",
"options",
".",
"step",
";",
"number",
"=",
"number",
"*",
"this",
".",
"options",
".",
"step",
";",
"number",
"=",
"+",
"number",
".",
"toFixed",
"(",
"0",
")",
";",
"}",
"if",
"(",
"abs",
")",
"{",
"number",
"-=",
"abs",
";",
"}",
"if",
"(",
"string",
")",
"{",
"result",
"=",
"+",
"number",
".",
"toFixed",
"(",
"string",
".",
"length",
")",
";",
"}",
"else",
"{",
"result",
"=",
"this",
".",
"toFixed",
"(",
"number",
")",
";",
"}",
"if",
"(",
"result",
"<",
"this",
".",
"options",
".",
"min",
")",
"{",
"result",
"=",
"this",
".",
"options",
".",
"min",
";",
"}",
"else",
"if",
"(",
"result",
">",
"this",
".",
"options",
".",
"max",
")",
"{",
"result",
"=",
"this",
".",
"options",
".",
"max",
";",
"}",
"return",
"result",
";",
"}"
] |
Convert percent to real values
@param percent {Number} X in percent
@returns {Number} X in real
|
[
"Convert",
"percent",
"to",
"real",
"values"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1770-L1835
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/ion.rangeSlider/js/ion.rangeSlider.js
|
function (percent) {
var rounded = Math.round(percent / this.coords.p_step) * this.coords.p_step;
if (rounded > 100) {
rounded = 100;
}
if (percent === 100) {
rounded = 100;
}
return this.toFixed(rounded);
}
|
javascript
|
function (percent) {
var rounded = Math.round(percent / this.coords.p_step) * this.coords.p_step;
if (rounded > 100) {
rounded = 100;
}
if (percent === 100) {
rounded = 100;
}
return this.toFixed(rounded);
}
|
[
"function",
"(",
"percent",
")",
"{",
"var",
"rounded",
"=",
"Math",
".",
"round",
"(",
"percent",
"/",
"this",
".",
"coords",
".",
"p_step",
")",
"*",
"this",
".",
"coords",
".",
"p_step",
";",
"if",
"(",
"rounded",
">",
"100",
")",
"{",
"rounded",
"=",
"100",
";",
"}",
"if",
"(",
"percent",
"===",
"100",
")",
"{",
"rounded",
"=",
"100",
";",
"}",
"return",
"this",
".",
"toFixed",
"(",
"rounded",
")",
";",
"}"
] |
Round percent value with step
@param percent {Number}
@returns percent {Number} rounded
|
[
"Round",
"percent",
"value",
"with",
"step"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L1843-L1854
|
train
|
|
ColorlibHQ/AdminLTE
|
plugins/timepicker/bootstrap-timepicker.js
|
function (segment, step) {
if (segment % step === 0) {
return segment;
}
if (Math.round((segment % step) / step)) {
return (segment + (step - segment % step)) % 60;
} else {
return segment - segment % step;
}
}
|
javascript
|
function (segment, step) {
if (segment % step === 0) {
return segment;
}
if (Math.round((segment % step) / step)) {
return (segment + (step - segment % step)) % 60;
} else {
return segment - segment % step;
}
}
|
[
"function",
"(",
"segment",
",",
"step",
")",
"{",
"if",
"(",
"segment",
"%",
"step",
"===",
"0",
")",
"{",
"return",
"segment",
";",
"}",
"if",
"(",
"Math",
".",
"round",
"(",
"(",
"segment",
"%",
"step",
")",
"/",
"step",
")",
")",
"{",
"return",
"(",
"segment",
"+",
"(",
"step",
"-",
"segment",
"%",
"step",
")",
")",
"%",
"60",
";",
"}",
"else",
"{",
"return",
"segment",
"-",
"segment",
"%",
"step",
";",
"}",
"}"
] |
Given a segment value like 43, will round and snap the segment
to the nearest "step", like 45 if step is 15. Segment will
"overflow" to 0 if it's larger than 59 or would otherwise
round up to 60.
|
[
"Given",
"a",
"segment",
"value",
"like",
"43",
"will",
"round",
"and",
"snap",
"the",
"segment",
"to",
"the",
"nearest",
"step",
"like",
"45",
"if",
"step",
"is",
"15",
".",
"Segment",
"will",
"overflow",
"to",
"0",
"if",
"it",
"s",
"larger",
"than",
"59",
"or",
"would",
"otherwise",
"round",
"up",
"to",
"60",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/timepicker/bootstrap-timepicker.js#L647-L656
|
train
|
|
ColorlibHQ/AdminLTE
|
plugins/timepicker/bootstrap-timepicker.js
|
function() {
if (this.isInline) {
return;
}
var widgetWidth = this.$widget.outerWidth(), widgetHeight = this.$widget.outerHeight(), visualPadding = 10, windowWidth =
$(window).width(), windowHeight = $(window).height(), scrollTop = $(window).scrollTop();
var zIndex = parseInt(this.$element.parents().filter(function() { return $(this).css('z-index') !== 'auto'; }).first().css('z-index'), 10) + 10;
var offset = this.component ? this.component.parent().offset() : this.$element.offset();
var height = this.component ? this.component.outerHeight(true) : this.$element.outerHeight(false);
var width = this.component ? this.component.outerWidth(true) : this.$element.outerWidth(false);
var left = offset.left, top = offset.top;
this.$widget.removeClass('timepicker-orient-top timepicker-orient-bottom timepicker-orient-right timepicker-orient-left');
if (this.orientation.x !== 'auto') {
this.$widget.addClass('timepicker-orient-' + this.orientation.x);
if (this.orientation.x === 'right') {
left -= widgetWidth - width;
}
} else{
// auto x orientation is best-placement: if it crosses a window edge, fudge it sideways
// Default to left
this.$widget.addClass('timepicker-orient-left');
if (offset.left < 0) {
left -= offset.left - visualPadding;
} else if (offset.left + widgetWidth > windowWidth) {
left = windowWidth - widgetWidth - visualPadding;
}
}
// auto y orientation is best-situation: top or bottom, no fudging, decision based on which shows more of the widget
var yorient = this.orientation.y, topOverflow, bottomOverflow;
if (yorient === 'auto') {
topOverflow = -scrollTop + offset.top - widgetHeight;
bottomOverflow = scrollTop + windowHeight - (offset.top + height + widgetHeight);
if (Math.max(topOverflow, bottomOverflow) === bottomOverflow) {
yorient = 'top';
} else {
yorient = 'bottom';
}
}
this.$widget.addClass('timepicker-orient-' + yorient);
if (yorient === 'top'){
top += height;
} else{
top -= widgetHeight + parseInt(this.$widget.css('padding-top'), 10);
}
this.$widget.css({
top : top,
left : left,
zIndex : zIndex
});
}
|
javascript
|
function() {
if (this.isInline) {
return;
}
var widgetWidth = this.$widget.outerWidth(), widgetHeight = this.$widget.outerHeight(), visualPadding = 10, windowWidth =
$(window).width(), windowHeight = $(window).height(), scrollTop = $(window).scrollTop();
var zIndex = parseInt(this.$element.parents().filter(function() { return $(this).css('z-index') !== 'auto'; }).first().css('z-index'), 10) + 10;
var offset = this.component ? this.component.parent().offset() : this.$element.offset();
var height = this.component ? this.component.outerHeight(true) : this.$element.outerHeight(false);
var width = this.component ? this.component.outerWidth(true) : this.$element.outerWidth(false);
var left = offset.left, top = offset.top;
this.$widget.removeClass('timepicker-orient-top timepicker-orient-bottom timepicker-orient-right timepicker-orient-left');
if (this.orientation.x !== 'auto') {
this.$widget.addClass('timepicker-orient-' + this.orientation.x);
if (this.orientation.x === 'right') {
left -= widgetWidth - width;
}
} else{
// auto x orientation is best-placement: if it crosses a window edge, fudge it sideways
// Default to left
this.$widget.addClass('timepicker-orient-left');
if (offset.left < 0) {
left -= offset.left - visualPadding;
} else if (offset.left + widgetWidth > windowWidth) {
left = windowWidth - widgetWidth - visualPadding;
}
}
// auto y orientation is best-situation: top or bottom, no fudging, decision based on which shows more of the widget
var yorient = this.orientation.y, topOverflow, bottomOverflow;
if (yorient === 'auto') {
topOverflow = -scrollTop + offset.top - widgetHeight;
bottomOverflow = scrollTop + windowHeight - (offset.top + height + widgetHeight);
if (Math.max(topOverflow, bottomOverflow) === bottomOverflow) {
yorient = 'top';
} else {
yorient = 'bottom';
}
}
this.$widget.addClass('timepicker-orient-' + yorient);
if (yorient === 'top'){
top += height;
} else{
top -= widgetHeight + parseInt(this.$widget.css('padding-top'), 10);
}
this.$widget.css({
top : top,
left : left,
zIndex : zIndex
});
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isInline",
")",
"{",
"return",
";",
"}",
"var",
"widgetWidth",
"=",
"this",
".",
"$widget",
".",
"outerWidth",
"(",
")",
",",
"widgetHeight",
"=",
"this",
".",
"$widget",
".",
"outerHeight",
"(",
")",
",",
"visualPadding",
"=",
"10",
",",
"windowWidth",
"=",
"$",
"(",
"window",
")",
".",
"width",
"(",
")",
",",
"windowHeight",
"=",
"$",
"(",
"window",
")",
".",
"height",
"(",
")",
",",
"scrollTop",
"=",
"$",
"(",
"window",
")",
".",
"scrollTop",
"(",
")",
";",
"var",
"zIndex",
"=",
"parseInt",
"(",
"this",
".",
"$element",
".",
"parents",
"(",
")",
".",
"filter",
"(",
"function",
"(",
")",
"{",
"return",
"$",
"(",
"this",
")",
".",
"css",
"(",
"'z-index'",
")",
"!==",
"'auto'",
";",
"}",
")",
".",
"first",
"(",
")",
".",
"css",
"(",
"'z-index'",
")",
",",
"10",
")",
"+",
"10",
";",
"var",
"offset",
"=",
"this",
".",
"component",
"?",
"this",
".",
"component",
".",
"parent",
"(",
")",
".",
"offset",
"(",
")",
":",
"this",
".",
"$element",
".",
"offset",
"(",
")",
";",
"var",
"height",
"=",
"this",
".",
"component",
"?",
"this",
".",
"component",
".",
"outerHeight",
"(",
"true",
")",
":",
"this",
".",
"$element",
".",
"outerHeight",
"(",
"false",
")",
";",
"var",
"width",
"=",
"this",
".",
"component",
"?",
"this",
".",
"component",
".",
"outerWidth",
"(",
"true",
")",
":",
"this",
".",
"$element",
".",
"outerWidth",
"(",
"false",
")",
";",
"var",
"left",
"=",
"offset",
".",
"left",
",",
"top",
"=",
"offset",
".",
"top",
";",
"this",
".",
"$widget",
".",
"removeClass",
"(",
"'timepicker-orient-top timepicker-orient-bottom timepicker-orient-right timepicker-orient-left'",
")",
";",
"if",
"(",
"this",
".",
"orientation",
".",
"x",
"!==",
"'auto'",
")",
"{",
"this",
".",
"$widget",
".",
"addClass",
"(",
"'timepicker-orient-'",
"+",
"this",
".",
"orientation",
".",
"x",
")",
";",
"if",
"(",
"this",
".",
"orientation",
".",
"x",
"===",
"'right'",
")",
"{",
"left",
"-=",
"widgetWidth",
"-",
"width",
";",
"}",
"}",
"else",
"{",
"this",
".",
"$widget",
".",
"addClass",
"(",
"'timepicker-orient-left'",
")",
";",
"if",
"(",
"offset",
".",
"left",
"<",
"0",
")",
"{",
"left",
"-=",
"offset",
".",
"left",
"-",
"visualPadding",
";",
"}",
"else",
"if",
"(",
"offset",
".",
"left",
"+",
"widgetWidth",
">",
"windowWidth",
")",
"{",
"left",
"=",
"windowWidth",
"-",
"widgetWidth",
"-",
"visualPadding",
";",
"}",
"}",
"var",
"yorient",
"=",
"this",
".",
"orientation",
".",
"y",
",",
"topOverflow",
",",
"bottomOverflow",
";",
"if",
"(",
"yorient",
"===",
"'auto'",
")",
"{",
"topOverflow",
"=",
"-",
"scrollTop",
"+",
"offset",
".",
"top",
"-",
"widgetHeight",
";",
"bottomOverflow",
"=",
"scrollTop",
"+",
"windowHeight",
"-",
"(",
"offset",
".",
"top",
"+",
"height",
"+",
"widgetHeight",
")",
";",
"if",
"(",
"Math",
".",
"max",
"(",
"topOverflow",
",",
"bottomOverflow",
")",
"===",
"bottomOverflow",
")",
"{",
"yorient",
"=",
"'top'",
";",
"}",
"else",
"{",
"yorient",
"=",
"'bottom'",
";",
"}",
"}",
"this",
".",
"$widget",
".",
"addClass",
"(",
"'timepicker-orient-'",
"+",
"yorient",
")",
";",
"if",
"(",
"yorient",
"===",
"'top'",
")",
"{",
"top",
"+=",
"height",
";",
"}",
"else",
"{",
"top",
"-=",
"widgetHeight",
"+",
"parseInt",
"(",
"this",
".",
"$widget",
".",
"css",
"(",
"'padding-top'",
")",
",",
"10",
")",
";",
"}",
"this",
".",
"$widget",
".",
"css",
"(",
"{",
"top",
":",
"top",
",",
"left",
":",
"left",
",",
"zIndex",
":",
"zIndex",
"}",
")",
";",
"}"
] |
This method was adapted from bootstrap-datepicker.
|
[
"This",
"method",
"was",
"adapted",
"from",
"bootstrap",
"-",
"datepicker",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/timepicker/bootstrap-timepicker.js#L659-L712
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/chart.js/Chart.js
|
function(element,dimension)
{
if (element['offset'+dimension])
{
return element['offset'+dimension];
}
else
{
return document.defaultView.getComputedStyle(element).getPropertyValue(dimension);
}
}
|
javascript
|
function(element,dimension)
{
if (element['offset'+dimension])
{
return element['offset'+dimension];
}
else
{
return document.defaultView.getComputedStyle(element).getPropertyValue(dimension);
}
}
|
[
"function",
"(",
"element",
",",
"dimension",
")",
"{",
"if",
"(",
"element",
"[",
"'offset'",
"+",
"dimension",
"]",
")",
"{",
"return",
"element",
"[",
"'offset'",
"+",
"dimension",
"]",
";",
"}",
"else",
"{",
"return",
"document",
".",
"defaultView",
".",
"getComputedStyle",
"(",
"element",
")",
".",
"getPropertyValue",
"(",
"dimension",
")",
";",
"}",
"}"
] |
Variables global to the chart
|
[
"Variables",
"global",
"to",
"the",
"chart"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/chart.js/Chart.js#L28-L38
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/chart.js/Chart.js
|
function(){
// First we need the width of the yLabels, assuming the xLabels aren't rotated
// To do that we need the base line at the top and base of the chart, assuming there is no x label rotation
this.startPoint = (this.display) ? this.fontSize : 0;
this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels
// Apply padding settings to the start and end point.
this.startPoint += this.padding;
this.endPoint -= this.padding;
// Cache the starting height, so can determine if we need to recalculate the scale yAxis
var cachedHeight = this.endPoint - this.startPoint,
cachedYLabelWidth;
// Build the current yLabels so we have an idea of what size they'll be to start
/*
* This sets what is returned from calculateScaleRange as static properties of this class:
*
this.steps;
this.stepValue;
this.min;
this.max;
*
*/
this.calculateYRange(cachedHeight);
// With these properties set we can now build the array of yLabels
// and also the width of the largest yLabel
this.buildYLabels();
this.calculateXLabelRotation();
while((cachedHeight > this.endPoint - this.startPoint)){
cachedHeight = this.endPoint - this.startPoint;
cachedYLabelWidth = this.yLabelWidth;
this.calculateYRange(cachedHeight);
this.buildYLabels();
// Only go through the xLabel loop again if the yLabel width has changed
if (cachedYLabelWidth < this.yLabelWidth){
this.calculateXLabelRotation();
}
}
}
|
javascript
|
function(){
// First we need the width of the yLabels, assuming the xLabels aren't rotated
// To do that we need the base line at the top and base of the chart, assuming there is no x label rotation
this.startPoint = (this.display) ? this.fontSize : 0;
this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels
// Apply padding settings to the start and end point.
this.startPoint += this.padding;
this.endPoint -= this.padding;
// Cache the starting height, so can determine if we need to recalculate the scale yAxis
var cachedHeight = this.endPoint - this.startPoint,
cachedYLabelWidth;
// Build the current yLabels so we have an idea of what size they'll be to start
/*
* This sets what is returned from calculateScaleRange as static properties of this class:
*
this.steps;
this.stepValue;
this.min;
this.max;
*
*/
this.calculateYRange(cachedHeight);
// With these properties set we can now build the array of yLabels
// and also the width of the largest yLabel
this.buildYLabels();
this.calculateXLabelRotation();
while((cachedHeight > this.endPoint - this.startPoint)){
cachedHeight = this.endPoint - this.startPoint;
cachedYLabelWidth = this.yLabelWidth;
this.calculateYRange(cachedHeight);
this.buildYLabels();
// Only go through the xLabel loop again if the yLabel width has changed
if (cachedYLabelWidth < this.yLabelWidth){
this.calculateXLabelRotation();
}
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"startPoint",
"=",
"(",
"this",
".",
"display",
")",
"?",
"this",
".",
"fontSize",
":",
"0",
";",
"this",
".",
"endPoint",
"=",
"(",
"this",
".",
"display",
")",
"?",
"this",
".",
"height",
"-",
"(",
"this",
".",
"fontSize",
"*",
"1.5",
")",
"-",
"5",
":",
"this",
".",
"height",
";",
"this",
".",
"startPoint",
"+=",
"this",
".",
"padding",
";",
"this",
".",
"endPoint",
"-=",
"this",
".",
"padding",
";",
"var",
"cachedHeight",
"=",
"this",
".",
"endPoint",
"-",
"this",
".",
"startPoint",
",",
"cachedYLabelWidth",
";",
"this",
".",
"calculateYRange",
"(",
"cachedHeight",
")",
";",
"this",
".",
"buildYLabels",
"(",
")",
";",
"this",
".",
"calculateXLabelRotation",
"(",
")",
";",
"while",
"(",
"(",
"cachedHeight",
">",
"this",
".",
"endPoint",
"-",
"this",
".",
"startPoint",
")",
")",
"{",
"cachedHeight",
"=",
"this",
".",
"endPoint",
"-",
"this",
".",
"startPoint",
";",
"cachedYLabelWidth",
"=",
"this",
".",
"yLabelWidth",
";",
"this",
".",
"calculateYRange",
"(",
"cachedHeight",
")",
";",
"this",
".",
"buildYLabels",
"(",
")",
";",
"if",
"(",
"cachedYLabelWidth",
"<",
"this",
".",
"yLabelWidth",
")",
"{",
"this",
".",
"calculateXLabelRotation",
"(",
")",
";",
"}",
"}",
"}"
] |
Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use
|
[
"Fitting",
"loop",
"to",
"rotate",
"x",
"Labels",
"and",
"figure",
"out",
"what",
"fits",
"there",
"and",
"also",
"calculate",
"how",
"many",
"Y",
"steps",
"to",
"use"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/chart.js/Chart.js#L1482-L1528
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jquery-sparkline/src/vcanvas-base.js
|
function (width, height, canvas) {
// XXX This should probably be a configurable option
var match;
match = this._pxregex.exec(height);
if (match) {
this.pixelHeight = match[1];
} else {
this.pixelHeight = $(canvas).height();
}
match = this._pxregex.exec(width);
if (match) {
this.pixelWidth = match[1];
} else {
this.pixelWidth = $(canvas).width();
}
}
|
javascript
|
function (width, height, canvas) {
// XXX This should probably be a configurable option
var match;
match = this._pxregex.exec(height);
if (match) {
this.pixelHeight = match[1];
} else {
this.pixelHeight = $(canvas).height();
}
match = this._pxregex.exec(width);
if (match) {
this.pixelWidth = match[1];
} else {
this.pixelWidth = $(canvas).width();
}
}
|
[
"function",
"(",
"width",
",",
"height",
",",
"canvas",
")",
"{",
"var",
"match",
";",
"match",
"=",
"this",
".",
"_pxregex",
".",
"exec",
"(",
"height",
")",
";",
"if",
"(",
"match",
")",
"{",
"this",
".",
"pixelHeight",
"=",
"match",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"this",
".",
"pixelHeight",
"=",
"$",
"(",
"canvas",
")",
".",
"height",
"(",
")",
";",
"}",
"match",
"=",
"this",
".",
"_pxregex",
".",
"exec",
"(",
"width",
")",
";",
"if",
"(",
"match",
")",
"{",
"this",
".",
"pixelWidth",
"=",
"match",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"this",
".",
"pixelWidth",
"=",
"$",
"(",
"canvas",
")",
".",
"width",
"(",
")",
";",
"}",
"}"
] |
Calculate the pixel dimensions of the canvas
|
[
"Calculate",
"the",
"pixel",
"dimensions",
"of",
"the",
"canvas"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jquery-sparkline/src/vcanvas-base.js#L79-L94
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/jquery-sparkline/src/vcanvas-base.js
|
function (shapetype, shapeargs) {
var id = shapeCount++;
shapeargs.unshift(id);
return new VShape(this, id, shapetype, shapeargs);
}
|
javascript
|
function (shapetype, shapeargs) {
var id = shapeCount++;
shapeargs.unshift(id);
return new VShape(this, id, shapetype, shapeargs);
}
|
[
"function",
"(",
"shapetype",
",",
"shapeargs",
")",
"{",
"var",
"id",
"=",
"shapeCount",
"++",
";",
"shapeargs",
".",
"unshift",
"(",
"id",
")",
";",
"return",
"new",
"VShape",
"(",
"this",
",",
"id",
",",
"shapetype",
",",
"shapeargs",
")",
";",
"}"
] |
Generate a shape object and id for later rendering
|
[
"Generate",
"a",
"shape",
"object",
"and",
"id",
"for",
"later",
"rendering"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jquery-sparkline/src/vcanvas-base.js#L99-L103
|
train
|
|
ColorlibHQ/AdminLTE
|
bower_components/moment/src/lib/duration/humanize.js
|
substituteTimeAgo
|
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
|
javascript
|
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
|
[
"function",
"substituteTimeAgo",
"(",
"string",
",",
"number",
",",
"withoutSuffix",
",",
"isFuture",
",",
"locale",
")",
"{",
"return",
"locale",
".",
"relativeTime",
"(",
"number",
"||",
"1",
",",
"!",
"!",
"withoutSuffix",
",",
"string",
",",
"isFuture",
")",
";",
"}"
] |
helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
|
[
"helper",
"function",
"for",
"moment",
".",
"fn",
".",
"from",
"moment",
".",
"fn",
".",
"fromNow",
"and",
"moment",
".",
"duration",
".",
"fn",
".",
"humanize"
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/moment/src/lib/duration/humanize.js#L14-L16
|
train
|
ColorlibHQ/AdminLTE
|
bower_components/jquery/src/css.js
|
finalPropName
|
function finalPropName( name ) {
var ret = jQuery.cssProps[ name ];
if ( !ret ) {
ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
}
return ret;
}
|
javascript
|
function finalPropName( name ) {
var ret = jQuery.cssProps[ name ];
if ( !ret ) {
ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
}
return ret;
}
|
[
"function",
"finalPropName",
"(",
"name",
")",
"{",
"var",
"ret",
"=",
"jQuery",
".",
"cssProps",
"[",
"name",
"]",
";",
"if",
"(",
"!",
"ret",
")",
"{",
"ret",
"=",
"jQuery",
".",
"cssProps",
"[",
"name",
"]",
"=",
"vendorPropName",
"(",
"name",
")",
"||",
"name",
";",
"}",
"return",
"ret",
";",
"}"
] |
Return a property mapped along what jQuery.cssProps suggests or to a vendor prefixed property.
|
[
"Return",
"a",
"property",
"mapped",
"along",
"what",
"jQuery",
".",
"cssProps",
"suggests",
"or",
"to",
"a",
"vendor",
"prefixed",
"property",
"."
] |
19113c3cbc19a7afe0cfd3158d647064d2d30661
|
https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jquery/src/css.js#L63-L69
|
train
|
NervJS/taro
|
packages/taro-h5/src/api/interactive/index.js
|
init
|
function init (doc) {
if (status === 'ready') return
const taroStyle = doc.createElement('style')
taroStyle.textContent = '@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJWs0t/AAABfAAAAFZjbWFwqVgGvgAAAeAAAAGGZ2x5Zph7qG0AAANwAAAAdGhlYWQRFoGhAAAA4AAAADZoaGVhCCsD7AAAALwAAAAkaG10eAg0AAAAAAHUAAAADGxvY2EADAA6AAADaAAAAAhtYXhwAQ4AJAAAARgAAAAgbmFtZYrphEEAAAPkAAACVXBvc3S3shtSAAAGPAAAADUAAQAAA+gAAABaA+gAAAAAA+gAAQAAAAAAAAAAAAAAAAAAAAMAAQAAAAEAAADih+FfDzz1AAsD6AAAAADXB57LAAAAANcHnssAAP/sA+gDOgAAAAgAAgAAAAAAAAABAAAAAwAYAAEAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQK8AZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABAAHjqCAPoAAAAWgPoABQAAAABAAAAAAAAA+gAAABkAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAV4AAQAAAAAAWAADAAEAAAAsAAMACgAAAV4ABAAsAAAABgAEAAEAAgB46gj//wAAAHjqCP//AAAAAAABAAYABgAAAAEAAgAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAKAAAAAAAAAACAAAAeAAAAHgAAAABAADqCAAA6ggAAAACAAAAAAAAAAwAOgABAAD/7AAyABQAAgAANzMVFB4UKAAAAAABAAAAAAO7AzoAFwAAEy4BPwE+AR8BFjY3ATYWFycWFAcBBiInPQoGBwUHGgzLDCELAh0LHwsNCgr9uQoeCgGzCyEOCw0HCZMJAQoBvgkCCg0LHQv9sQsKAAAAAAAAEgDeAAEAAAAAAAAAHQAAAAEAAAAAAAEABAAdAAEAAAAAAAIABwAhAAEAAAAAAAMABAAoAAEAAAAAAAQABAAsAAEAAAAAAAUACwAwAAEAAAAAAAYABAA7AAEAAAAAAAoAKwA/AAEAAAAAAAsAEwBqAAMAAQQJAAAAOgB9AAMAAQQJAAEACAC3AAMAAQQJAAIADgC/AAMAAQQJAAMACADNAAMAAQQJAAQACADVAAMAAQQJAAUAFgDdAAMAAQQJAAYACADzAAMAAQQJAAoAVgD7AAMAAQQJAAsAJgFRCiAgQ3JlYXRlZCBieSBmb250LWNhcnJpZXIKICB3ZXVpUmVndWxhcndldWl3ZXVpVmVyc2lvbiAxLjB3ZXVpR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgAgACAAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGYAbwBuAHQALQBjAGEAcgByAGkAZQByAAoAIAAgAHcAZQB1AGkAUgBlAGcAdQBsAGEAcgB3AGUAdQBpAHcAZQB1AGkAVgBlAHIAcwBpAG8AbgAgADEALgAwAHcAZQB1AGkARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwECAQMBBAABeAd1bmlFQTA4AAAAAAA=") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}'
doc.querySelector('head').appendChild(taroStyle)
status = 'ready'
}
|
javascript
|
function init (doc) {
if (status === 'ready') return
const taroStyle = doc.createElement('style')
taroStyle.textContent = '@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJWs0t/AAABfAAAAFZjbWFwqVgGvgAAAeAAAAGGZ2x5Zph7qG0AAANwAAAAdGhlYWQRFoGhAAAA4AAAADZoaGVhCCsD7AAAALwAAAAkaG10eAg0AAAAAAHUAAAADGxvY2EADAA6AAADaAAAAAhtYXhwAQ4AJAAAARgAAAAgbmFtZYrphEEAAAPkAAACVXBvc3S3shtSAAAGPAAAADUAAQAAA+gAAABaA+gAAAAAA+gAAQAAAAAAAAAAAAAAAAAAAAMAAQAAAAEAAADih+FfDzz1AAsD6AAAAADXB57LAAAAANcHnssAAP/sA+gDOgAAAAgAAgAAAAAAAAABAAAAAwAYAAEAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQK8AZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABAAHjqCAPoAAAAWgPoABQAAAABAAAAAAAAA+gAAABkAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAV4AAQAAAAAAWAADAAEAAAAsAAMACgAAAV4ABAAsAAAABgAEAAEAAgB46gj//wAAAHjqCP//AAAAAAABAAYABgAAAAEAAgAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAKAAAAAAAAAACAAAAeAAAAHgAAAABAADqCAAA6ggAAAACAAAAAAAAAAwAOgABAAD/7AAyABQAAgAANzMVFB4UKAAAAAABAAAAAAO7AzoAFwAAEy4BPwE+AR8BFjY3ATYWFycWFAcBBiInPQoGBwUHGgzLDCELAh0LHwsNCgr9uQoeCgGzCyEOCw0HCZMJAQoBvgkCCg0LHQv9sQsKAAAAAAAAEgDeAAEAAAAAAAAAHQAAAAEAAAAAAAEABAAdAAEAAAAAAAIABwAhAAEAAAAAAAMABAAoAAEAAAAAAAQABAAsAAEAAAAAAAUACwAwAAEAAAAAAAYABAA7AAEAAAAAAAoAKwA/AAEAAAAAAAsAEwBqAAMAAQQJAAAAOgB9AAMAAQQJAAEACAC3AAMAAQQJAAIADgC/AAMAAQQJAAMACADNAAMAAQQJAAQACADVAAMAAQQJAAUAFgDdAAMAAQQJAAYACADzAAMAAQQJAAoAVgD7AAMAAQQJAAsAJgFRCiAgQ3JlYXRlZCBieSBmb250LWNhcnJpZXIKICB3ZXVpUmVndWxhcndldWl3ZXVpVmVyc2lvbiAxLjB3ZXVpR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgAgACAAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGYAbwBuAHQALQBjAGEAcgByAGkAZQByAAoAIAAgAHcAZQB1AGkAUgBlAGcAdQBsAGEAcgB3AGUAdQBpAHcAZQB1AGkAVgBlAHIAcwBpAG8AbgAgADEALgAwAHcAZQB1AGkARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwECAQMBBAABeAd1bmlFQTA4AAAAAAA=") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}'
doc.querySelector('head').appendChild(taroStyle)
status = 'ready'
}
|
[
"function",
"init",
"(",
"doc",
")",
"{",
"if",
"(",
"status",
"===",
"'ready'",
")",
"return",
"const",
"taroStyle",
"=",
"doc",
".",
"createElement",
"(",
"'style'",
")",
"taroStyle",
".",
"textContent",
"=",
"'@font-face{font-weight:normal;font-style:normal;font-family:\"taro\";src:url(\"data:application/x-font-ttf;charset=utf-8;base64, AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJWs0t/AAABfAAAAFZjbWFwqVgGvgAAAeAAAAGGZ2x5Zph7qG0AAANwAAAAdGhlYWQRFoGhAAAA4AAAADZoaGVhCCsD7AAAALwAAAAkaG10eAg0AAAAAAHUAAAADGxvY2EADAA6AAADaAAAAAhtYXhwAQ4AJAAAARgAAAAgbmFtZYrphEEAAAPkAAACVXBvc3S3shtSAAAGPAAAADUAAQAAA+gAAABaA+gAAAAAA+gAAQAAAAAAAAAAAAAAAAAAAAMAAQAAAAEAAADih+FfDzz1AAsD6AAAAADXB57LAAAAANcHnssAAP/sA+gDOgAAAAgAAgAAAAAAAAABAAAAAwAYAAEAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQK8AZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABAAHjqCAPoAAAAWgPoABQAAAABAAAAAAAAA+gAAABkAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAV4AAQAAAAAAWAADAAEAAAAsAAMACgAAAV4ABAAsAAAABgAEAAEAAgB46gj//wAAAHjqCP//AAAAAAABAAYABgAAAAEAAgAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAKAAAAAAAAAACAAAAeAAAAHgAAAABAADqCAAA6ggAAAACAAAAAAAAAAwAOgABAAD/7AAyABQAAgAANzMVFB4UKAAAAAABAAAAAAO7AzoAFwAAEy4BPwE+AR8BFjY3ATYWFycWFAcBBiInPQoGBwUHGgzLDCELAh0LHwsNCgr9uQoeCgGzCyEOCw0HCZMJAQoBvgkCCg0LHQv9sQsKAAAAAAAAEgDeAAEAAAAAAAAAHQAAAAEAAAAAAAEABAAdAAEAAAAAAAIABwAhAAEAAAAAAAMABAAoAAEAAAAAAAQABAAsAAEAAAAAAAUACwAwAAEAAAAAAAYABAA7AAEAAAAAAAoAKwA/AAEAAAAAAAsAEwBqAAMAAQQJAAAAOgB9AAMAAQQJAAEACAC3AAMAAQQJAAIADgC/AAMAAQQJAAMACADNAAMAAQQJAAQACADVAAMAAQQJAAUAFgDdAAMAAQQJAAYACADzAAMAAQQJAAoAVgD7AAMAAQQJAAsAJgFRCiAgQ3JlYXRlZCBieSBmb250LWNhcnJpZXIKICB3ZXVpUmVndWxhcndldWl3ZXVpVmVyc2lvbiAxLjB3ZXVpR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgAgACAAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGYAbwBuAHQALQBjAGEAcgByAGkAZQByAAoAIAAgAHcAZQB1AGkAUgBlAGcAdQBsAGEAcgB3AGUAdQBpAHcAZQB1AGkAVgBlAHIAcwBpAG8AbgAgADEALgAwAHcAZQB1AGkARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwECAQMBBAABeAd1bmlFQTA4AAAAAAA=\") format(\"truetype\");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: \"\";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: \"\";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: \"\";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}'",
"doc",
".",
"querySelector",
"(",
"'head'",
")",
".",
"appendChild",
"(",
"taroStyle",
")",
"status",
"=",
"'ready'",
"}"
] |
inject necessary style
|
[
"inject",
"necessary",
"style"
] |
274e76d731d7f158141287e31cbd51f092d472c5
|
https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro-h5/src/api/interactive/index.js#L10-L18
|
train
|
NervJS/taro
|
packages/taro/src/internal/_common.js
|
listCacheDelete
|
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key)
if (index < 0) {
return false
}
var lastIndex = data.length - 1
if (index == lastIndex) {
data.pop()
} else {
splice.call(data, index, 1)
}
return true
}
|
javascript
|
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key)
if (index < 0) {
return false
}
var lastIndex = data.length - 1
if (index == lastIndex) {
data.pop()
} else {
splice.call(data, index, 1)
}
return true
}
|
[
"function",
"listCacheDelete",
"(",
"key",
")",
"{",
"var",
"data",
"=",
"this",
".",
"__data__",
",",
"index",
"=",
"assocIndexOf",
"(",
"data",
",",
"key",
")",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"false",
"}",
"var",
"lastIndex",
"=",
"data",
".",
"length",
"-",
"1",
"if",
"(",
"index",
"==",
"lastIndex",
")",
"{",
"data",
".",
"pop",
"(",
")",
"}",
"else",
"{",
"splice",
".",
"call",
"(",
"data",
",",
"index",
",",
"1",
")",
"}",
"return",
"true",
"}"
] |
Removes `key` and its value from the list cache.
@private
@name delete
@memberOf ListCache
@param {string} key The key of the value to remove.
@returns {boolean} Returns `true` if the entry was removed, else `false`.
|
[
"Removes",
"key",
"and",
"its",
"value",
"from",
"the",
"list",
"cache",
"."
] |
274e76d731d7f158141287e31cbd51f092d472c5
|
https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro/src/internal/_common.js#L273-L287
|
train
|
mui-org/material-ui
|
scripts/sizeSnapshot/create.js
|
getWebpackSizes
|
async function getWebpackSizes() {
await fse.mkdirp(path.join(__dirname, 'build'));
const configPath = path.join(__dirname, 'webpack.config.js');
const statsPath = path.join(__dirname, 'build', 'stats.json');
await exec(`webpack --config ${configPath} --json > ${statsPath}`);
const stats = await fse.readJSON(statsPath);
const assets = new Map(stats.assets.map(asset => [asset.name, asset]));
return Object.entries(stats.assetsByChunkName).map(([chunkName, assetName]) => {
const parsedSize = assets.get(assetName).size;
const gzipSize = assets.get(`${assetName}.gz`).size;
return [chunkName, { parsed: parsedSize, gzip: gzipSize }];
});
}
|
javascript
|
async function getWebpackSizes() {
await fse.mkdirp(path.join(__dirname, 'build'));
const configPath = path.join(__dirname, 'webpack.config.js');
const statsPath = path.join(__dirname, 'build', 'stats.json');
await exec(`webpack --config ${configPath} --json > ${statsPath}`);
const stats = await fse.readJSON(statsPath);
const assets = new Map(stats.assets.map(asset => [asset.name, asset]));
return Object.entries(stats.assetsByChunkName).map(([chunkName, assetName]) => {
const parsedSize = assets.get(assetName).size;
const gzipSize = assets.get(`${assetName}.gz`).size;
return [chunkName, { parsed: parsedSize, gzip: gzipSize }];
});
}
|
[
"async",
"function",
"getWebpackSizes",
"(",
")",
"{",
"await",
"fse",
".",
"mkdirp",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'build'",
")",
")",
";",
"const",
"configPath",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'webpack.config.js'",
")",
";",
"const",
"statsPath",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'build'",
",",
"'stats.json'",
")",
";",
"await",
"exec",
"(",
"`",
"${",
"configPath",
"}",
"${",
"statsPath",
"}",
"`",
")",
";",
"const",
"stats",
"=",
"await",
"fse",
".",
"readJSON",
"(",
"statsPath",
")",
";",
"const",
"assets",
"=",
"new",
"Map",
"(",
"stats",
".",
"assets",
".",
"map",
"(",
"asset",
"=>",
"[",
"asset",
".",
"name",
",",
"asset",
"]",
")",
")",
";",
"return",
"Object",
".",
"entries",
"(",
"stats",
".",
"assetsByChunkName",
")",
".",
"map",
"(",
"(",
"[",
"chunkName",
",",
"assetName",
"]",
")",
"=>",
"{",
"const",
"parsedSize",
"=",
"assets",
".",
"get",
"(",
"assetName",
")",
".",
"size",
";",
"const",
"gzipSize",
"=",
"assets",
".",
"get",
"(",
"`",
"${",
"assetName",
"}",
"`",
")",
".",
"size",
";",
"return",
"[",
"chunkName",
",",
"{",
"parsed",
":",
"parsedSize",
",",
"gzip",
":",
"gzipSize",
"}",
"]",
";",
"}",
")",
";",
"}"
] |
creates size snapshot for every bundle that built with webpack
|
[
"creates",
"size",
"snapshot",
"for",
"every",
"bundle",
"that",
"built",
"with",
"webpack"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/scripts/sizeSnapshot/create.js#L34-L49
|
train
|
mui-org/material-ui
|
packages/material-ui/src/Hidden/Hidden.js
|
Hidden
|
function Hidden(props) {
const { implementation, ...other } = props;
if (implementation === 'js') {
return <HiddenJs {...other} />;
}
return <HiddenCss {...other} />;
}
|
javascript
|
function Hidden(props) {
const { implementation, ...other } = props;
if (implementation === 'js') {
return <HiddenJs {...other} />;
}
return <HiddenCss {...other} />;
}
|
[
"function",
"Hidden",
"(",
"props",
")",
"{",
"const",
"{",
"implementation",
",",
"...",
"other",
"}",
"=",
"props",
";",
"if",
"(",
"implementation",
"===",
"'js'",
")",
"{",
"return",
"<",
"HiddenJs",
"{",
"...",
"other",
"}",
"/",
">",
";",
"}",
"return",
"<",
"HiddenCss",
"{",
"...",
"other",
"}",
"/",
">",
";",
"}"
] |
Responsively hides children based on the selected implementation.
|
[
"Responsively",
"hides",
"children",
"based",
"on",
"the",
"selected",
"implementation",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/Hidden/Hidden.js#L9-L17
|
train
|
mui-org/material-ui
|
packages/material-ui-codemod/src/v1.0.0/svg-icon-imports.js
|
transformSVGIconImports
|
function transformSVGIconImports(j, root) {
const pathMatchRegex = /^material-ui\/svg-icons\/.+\/(.+)$/;
root
.find(j.Literal)
.filter(path => pathMatchRegex.test(path.node.value))
.forEach(path => {
const [, iconName] = path.node.value.match(pathMatchRegex);
// update to new path
path.node.value = `@material-ui/icons/${pascalize(iconName)}`;
});
}
|
javascript
|
function transformSVGIconImports(j, root) {
const pathMatchRegex = /^material-ui\/svg-icons\/.+\/(.+)$/;
root
.find(j.Literal)
.filter(path => pathMatchRegex.test(path.node.value))
.forEach(path => {
const [, iconName] = path.node.value.match(pathMatchRegex);
// update to new path
path.node.value = `@material-ui/icons/${pascalize(iconName)}`;
});
}
|
[
"function",
"transformSVGIconImports",
"(",
"j",
",",
"root",
")",
"{",
"const",
"pathMatchRegex",
"=",
"/",
"^material-ui\\/svg-icons\\/.+\\/(.+)$",
"/",
";",
"root",
".",
"find",
"(",
"j",
".",
"Literal",
")",
".",
"filter",
"(",
"path",
"=>",
"pathMatchRegex",
".",
"test",
"(",
"path",
".",
"node",
".",
"value",
")",
")",
".",
"forEach",
"(",
"path",
"=>",
"{",
"const",
"[",
",",
"iconName",
"]",
"=",
"path",
".",
"node",
".",
"value",
".",
"match",
"(",
"pathMatchRegex",
")",
";",
"path",
".",
"node",
".",
"value",
"=",
"`",
"${",
"pascalize",
"(",
"iconName",
")",
"}",
"`",
";",
"}",
")",
";",
"}"
] |
Update all `svg-icons` import references to use `@material-ui/icons` package.
Find and replace string literal AST nodes to ensure all svg-icon paths get updated, regardless
of being in an import declaration, or a require() call, etc.
https://github.com/mui-org/material-ui/tree/master/packages/@material-ui/icons
@param {jscodeshift_api_object} j
@param {jscodeshift_ast_object} root
|
[
"Update",
"all",
"svg",
"-",
"icons",
"import",
"references",
"to",
"use"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-codemod/src/v1.0.0/svg-icon-imports.js#L29-L40
|
train
|
mui-org/material-ui
|
packages/material-ui-icons/scripts/create-typings.js
|
run
|
async function run() {
console.log(`\u{1f52c} Searching for modules inside "${chalk.dim(SRC_DIR)}".`);
const files = glob.sync('!(index)*.js', { cwd: SRC_DIR });
const typings = files.map(file => createIconTyping(file));
await Promise.all([...typings, createIndexTyping(files)]);
console.log(`\u{1F5C4} Written typings to ${chalk.dim(TARGET_DIR)}.`);
}
|
javascript
|
async function run() {
console.log(`\u{1f52c} Searching for modules inside "${chalk.dim(SRC_DIR)}".`);
const files = glob.sync('!(index)*.js', { cwd: SRC_DIR });
const typings = files.map(file => createIconTyping(file));
await Promise.all([...typings, createIndexTyping(files)]);
console.log(`\u{1F5C4} Written typings to ${chalk.dim(TARGET_DIR)}.`);
}
|
[
"async",
"function",
"run",
"(",
")",
"{",
"console",
".",
"log",
"(",
"`",
"\\u{1f52c}",
"${",
"chalk",
".",
"dim",
"(",
"SRC_DIR",
")",
"}",
"`",
")",
";",
"const",
"files",
"=",
"glob",
".",
"sync",
"(",
"'!(index)*.js'",
",",
"{",
"cwd",
":",
"SRC_DIR",
"}",
")",
";",
"const",
"typings",
"=",
"files",
".",
"map",
"(",
"file",
"=>",
"createIconTyping",
"(",
"file",
")",
")",
";",
"await",
"Promise",
".",
"all",
"(",
"[",
"...",
"typings",
",",
"createIndexTyping",
"(",
"files",
")",
"]",
")",
";",
"console",
".",
"log",
"(",
"`",
"\\u{1F5C4}",
"${",
"chalk",
".",
"dim",
"(",
"TARGET_DIR",
")",
"}",
"`",
")",
";",
"}"
] |
Generate TypeScript.
|
[
"Generate",
"TypeScript",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-icons/scripts/create-typings.js#L33-L39
|
train
|
mui-org/material-ui
|
docs/src/pages/getting-started/page-layout-examples/dashboard/Orders.js
|
createData
|
function createData(id, date, name, shipTo, paymentMethod, amount) {
return { id, date, name, shipTo, paymentMethod, amount };
}
|
javascript
|
function createData(id, date, name, shipTo, paymentMethod, amount) {
return { id, date, name, shipTo, paymentMethod, amount };
}
|
[
"function",
"createData",
"(",
"id",
",",
"date",
",",
"name",
",",
"shipTo",
",",
"paymentMethod",
",",
"amount",
")",
"{",
"return",
"{",
"id",
",",
"date",
",",
"name",
",",
"shipTo",
",",
"paymentMethod",
",",
"amount",
"}",
";",
"}"
] |
Generate Order Data
|
[
"Generate",
"Order",
"Data"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/pages/getting-started/page-layout-examples/dashboard/Orders.js#L14-L16
|
train
|
mui-org/material-ui
|
dangerfile.js
|
git
|
function git(args) {
return new Promise((resolve, reject) => {
exec(`git ${args}`, (err, stdout) => {
if (err) {
reject(err);
} else {
resolve(stdout.trim());
}
});
});
}
|
javascript
|
function git(args) {
return new Promise((resolve, reject) => {
exec(`git ${args}`, (err, stdout) => {
if (err) {
reject(err);
} else {
resolve(stdout.trim());
}
});
});
}
|
[
"function",
"git",
"(",
"args",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"exec",
"(",
"`",
"${",
"args",
"}",
"`",
",",
"(",
"err",
",",
"stdout",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
"stdout",
".",
"trim",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] |
executes a git subcommand
@param {any} args
|
[
"executes",
"a",
"git",
"subcommand"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/dangerfile.js#L15-L25
|
train
|
mui-org/material-ui
|
dangerfile.js
|
addPercent
|
function addPercent(change, goodEmoji = '', badEmooji = ':small_red_triangle:') {
const formatted = (change * 100).toFixed(2);
if (/^-|^0(?:\.0+)$/.test(formatted)) {
return `${formatted}% ${goodEmoji}`;
}
return `+${formatted}% ${badEmooji}`;
}
|
javascript
|
function addPercent(change, goodEmoji = '', badEmooji = ':small_red_triangle:') {
const formatted = (change * 100).toFixed(2);
if (/^-|^0(?:\.0+)$/.test(formatted)) {
return `${formatted}% ${goodEmoji}`;
}
return `+${formatted}% ${badEmooji}`;
}
|
[
"function",
"addPercent",
"(",
"change",
",",
"goodEmoji",
"=",
"''",
",",
"badEmooji",
"=",
"':small_red_triangle:'",
")",
"{",
"const",
"formatted",
"=",
"(",
"change",
"*",
"100",
")",
".",
"toFixed",
"(",
"2",
")",
";",
"if",
"(",
"/",
"^-|^0(?:\\.0+)$",
"/",
".",
"test",
"(",
"formatted",
")",
")",
"{",
"return",
"`",
"${",
"formatted",
"}",
"${",
"goodEmoji",
"}",
"`",
";",
"}",
"return",
"`",
"${",
"formatted",
"}",
"${",
"badEmooji",
"}",
"`",
";",
"}"
] |
Generates a user-readable string from a percentage change
@param {number} change
@param {string} goodEmoji emoji on reduction
@param {string} badEmooji emoji on increase
|
[
"Generates",
"a",
"user",
"-",
"readable",
"string",
"from",
"a",
"percentage",
"change"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/dangerfile.js#L71-L77
|
train
|
mui-org/material-ui
|
dangerfile.js
|
generateMDTable
|
function generateMDTable(headers, body) {
const headerRow = headers.map(header => header.label);
const alignmentRow = headers.map(header => {
if (header.align === 'right') {
return ' ---:';
}
if (header.align === 'center') {
return ':---:';
}
return ' --- ';
});
return [headerRow, alignmentRow, ...body].map(row => row.join(' | ')).join('\n');
}
|
javascript
|
function generateMDTable(headers, body) {
const headerRow = headers.map(header => header.label);
const alignmentRow = headers.map(header => {
if (header.align === 'right') {
return ' ---:';
}
if (header.align === 'center') {
return ':---:';
}
return ' --- ';
});
return [headerRow, alignmentRow, ...body].map(row => row.join(' | ')).join('\n');
}
|
[
"function",
"generateMDTable",
"(",
"headers",
",",
"body",
")",
"{",
"const",
"headerRow",
"=",
"headers",
".",
"map",
"(",
"header",
"=>",
"header",
".",
"label",
")",
";",
"const",
"alignmentRow",
"=",
"headers",
".",
"map",
"(",
"header",
"=>",
"{",
"if",
"(",
"header",
".",
"align",
"===",
"'right'",
")",
"{",
"return",
"' ---:'",
";",
"}",
"if",
"(",
"header",
".",
"align",
"===",
"'center'",
")",
"{",
"return",
"':---:'",
";",
"}",
"return",
"' --- '",
";",
"}",
")",
";",
"return",
"[",
"headerRow",
",",
"alignmentRow",
",",
"...",
"body",
"]",
".",
"map",
"(",
"row",
"=>",
"row",
".",
"join",
"(",
"' | '",
")",
")",
".",
"join",
"(",
"'\\n'",
")",
";",
"}"
] |
Generates a Markdown table
@param {{ label: string, align: 'left' | 'center' | 'right'}[]} headers
@param {string[][]} body
@returns {string}
|
[
"Generates",
"a",
"Markdown",
"table"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/dangerfile.js#L85-L98
|
train
|
mui-org/material-ui
|
docs/src/modules/utils/find.js
|
findComponents
|
function findComponents(directory, components = []) {
const items = fs.readdirSync(directory);
items.forEach(item => {
const itemPath = path.resolve(directory, item);
if (fs.statSync(itemPath).isDirectory()) {
findComponents(itemPath, components);
return;
}
if (!componentRegex.test(item)) {
return;
}
components.push({
filename: itemPath,
});
});
return components;
}
|
javascript
|
function findComponents(directory, components = []) {
const items = fs.readdirSync(directory);
items.forEach(item => {
const itemPath = path.resolve(directory, item);
if (fs.statSync(itemPath).isDirectory()) {
findComponents(itemPath, components);
return;
}
if (!componentRegex.test(item)) {
return;
}
components.push({
filename: itemPath,
});
});
return components;
}
|
[
"function",
"findComponents",
"(",
"directory",
",",
"components",
"=",
"[",
"]",
")",
"{",
"const",
"items",
"=",
"fs",
".",
"readdirSync",
"(",
"directory",
")",
";",
"items",
".",
"forEach",
"(",
"item",
"=>",
"{",
"const",
"itemPath",
"=",
"path",
".",
"resolve",
"(",
"directory",
",",
"item",
")",
";",
"if",
"(",
"fs",
".",
"statSync",
"(",
"itemPath",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"findComponents",
"(",
"itemPath",
",",
"components",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"componentRegex",
".",
"test",
"(",
"item",
")",
")",
"{",
"return",
";",
"}",
"components",
".",
"push",
"(",
"{",
"filename",
":",
"itemPath",
",",
"}",
")",
";",
"}",
")",
";",
"return",
"components",
";",
"}"
] |
Returns the component source in a flat array.
|
[
"Returns",
"the",
"component",
"source",
"in",
"a",
"flat",
"array",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/modules/utils/find.js#L54-L75
|
train
|
mui-org/material-ui
|
docs/src/modules/utils/find.js
|
findPages
|
function findPages(
options = {},
directory = path.resolve(__dirname, '../../../../pages'),
pages = [],
) {
fs.readdirSync(directory).forEach(item => {
const itemPath = path.resolve(directory, item);
const pathname = itemPath
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
.replace(/^.*\/pages/, '')
.replace('.js', '')
.replace(/^\/index$/, '/') // Replace `index` by `/`.
.replace(/\/index$/, '');
if (pathname.indexOf('.eslintrc') !== -1) {
return;
}
if (
options.front &&
pathname.indexOf('/components') === -1 &&
pathname.indexOf('/api') === -1
) {
return;
}
if (fs.statSync(itemPath).isDirectory()) {
const children = [];
pages.push({
pathname,
children,
});
findPages(options, itemPath, children);
return;
}
if (!jsRegex.test(item) || blackList.includes(pathname)) {
return;
}
pages.push({
pathname,
});
});
// sort by pathnames without '-' so that e.g. card comes before card-action
pages.sort((a, b) => {
const pathnameA = a.pathname.replace(/-/g, '');
const pathnameB = b.pathname.replace(/-/g, '');
if (pathnameA < pathnameB) return -1;
if (pathnameA > pathnameB) return 1;
return 0;
});
return pages;
}
|
javascript
|
function findPages(
options = {},
directory = path.resolve(__dirname, '../../../../pages'),
pages = [],
) {
fs.readdirSync(directory).forEach(item => {
const itemPath = path.resolve(directory, item);
const pathname = itemPath
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
.replace(/^.*\/pages/, '')
.replace('.js', '')
.replace(/^\/index$/, '/') // Replace `index` by `/`.
.replace(/\/index$/, '');
if (pathname.indexOf('.eslintrc') !== -1) {
return;
}
if (
options.front &&
pathname.indexOf('/components') === -1 &&
pathname.indexOf('/api') === -1
) {
return;
}
if (fs.statSync(itemPath).isDirectory()) {
const children = [];
pages.push({
pathname,
children,
});
findPages(options, itemPath, children);
return;
}
if (!jsRegex.test(item) || blackList.includes(pathname)) {
return;
}
pages.push({
pathname,
});
});
// sort by pathnames without '-' so that e.g. card comes before card-action
pages.sort((a, b) => {
const pathnameA = a.pathname.replace(/-/g, '');
const pathnameB = b.pathname.replace(/-/g, '');
if (pathnameA < pathnameB) return -1;
if (pathnameA > pathnameB) return 1;
return 0;
});
return pages;
}
|
[
"function",
"findPages",
"(",
"options",
"=",
"{",
"}",
",",
"directory",
"=",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'../../../../pages'",
")",
",",
"pages",
"=",
"[",
"]",
",",
")",
"{",
"fs",
".",
"readdirSync",
"(",
"directory",
")",
".",
"forEach",
"(",
"item",
"=>",
"{",
"const",
"itemPath",
"=",
"path",
".",
"resolve",
"(",
"directory",
",",
"item",
")",
";",
"const",
"pathname",
"=",
"itemPath",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"`",
"\\\\",
"${",
"path",
".",
"sep",
"}",
"`",
",",
"'g'",
")",
",",
"'/'",
")",
".",
"replace",
"(",
"/",
"^.*\\/pages",
"/",
",",
"''",
")",
".",
"replace",
"(",
"'.js'",
",",
"''",
")",
".",
"replace",
"(",
"/",
"^\\/index$",
"/",
",",
"'/'",
")",
".",
"replace",
"(",
"/",
"\\/index$",
"/",
",",
"''",
")",
";",
"if",
"(",
"pathname",
".",
"indexOf",
"(",
"'.eslintrc'",
")",
"!==",
"-",
"1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"options",
".",
"front",
"&&",
"pathname",
".",
"indexOf",
"(",
"'/components'",
")",
"===",
"-",
"1",
"&&",
"pathname",
".",
"indexOf",
"(",
"'/api'",
")",
"===",
"-",
"1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"fs",
".",
"statSync",
"(",
"itemPath",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"const",
"children",
"=",
"[",
"]",
";",
"pages",
".",
"push",
"(",
"{",
"pathname",
",",
"children",
",",
"}",
")",
";",
"findPages",
"(",
"options",
",",
"itemPath",
",",
"children",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"jsRegex",
".",
"test",
"(",
"item",
")",
"||",
"blackList",
".",
"includes",
"(",
"pathname",
")",
")",
"{",
"return",
";",
"}",
"pages",
".",
"push",
"(",
"{",
"pathname",
",",
"}",
")",
";",
"}",
")",
";",
"pages",
".",
"sort",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"{",
"const",
"pathnameA",
"=",
"a",
".",
"pathname",
".",
"replace",
"(",
"/",
"-",
"/",
"g",
",",
"''",
")",
";",
"const",
"pathnameB",
"=",
"b",
".",
"pathname",
".",
"replace",
"(",
"/",
"-",
"/",
"g",
",",
"''",
")",
";",
"if",
"(",
"pathnameA",
"<",
"pathnameB",
")",
"return",
"-",
"1",
";",
"if",
"(",
"pathnameA",
">",
"pathnameB",
")",
"return",
"1",
";",
"return",
"0",
";",
"}",
")",
";",
"return",
"pages",
";",
"}"
] |
Returns the Next.js pages available in a nested format. The output is in the next.js format. Each pathname is a route you can navigate to.
|
[
"Returns",
"the",
"Next",
".",
"js",
"pages",
"available",
"in",
"a",
"nested",
"format",
".",
"The",
"output",
"is",
"in",
"the",
"next",
".",
"js",
"format",
".",
"Each",
"pathname",
"is",
"a",
"route",
"you",
"can",
"navigate",
"to",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/modules/utils/find.js#L83-L138
|
train
|
mui-org/material-ui
|
docs/src/pages/components/slider/CustomValueReducerSlider.js
|
valueReducer
|
function valueReducer(rawValue, props, event) {
const { disabled, max, min, step } = props;
function roundToStep(number) {
return Math.round(number / step) * step;
}
if (!disabled && step) {
if (rawValue > min && rawValue < max) {
if (rawValue === max - step) {
// If moving the Slider using arrow keys and value is formerly an maximum edge value
return roundToStep(rawValue + step / 2);
}
if (rawValue === min + step) {
// Same for minimum edge value
return roundToStep(rawValue - step / 2);
}
return roundToStep(rawValue);
}
return rawValue;
}
return defaultValueReducer(rawValue, props, event);
}
|
javascript
|
function valueReducer(rawValue, props, event) {
const { disabled, max, min, step } = props;
function roundToStep(number) {
return Math.round(number / step) * step;
}
if (!disabled && step) {
if (rawValue > min && rawValue < max) {
if (rawValue === max - step) {
// If moving the Slider using arrow keys and value is formerly an maximum edge value
return roundToStep(rawValue + step / 2);
}
if (rawValue === min + step) {
// Same for minimum edge value
return roundToStep(rawValue - step / 2);
}
return roundToStep(rawValue);
}
return rawValue;
}
return defaultValueReducer(rawValue, props, event);
}
|
[
"function",
"valueReducer",
"(",
"rawValue",
",",
"props",
",",
"event",
")",
"{",
"const",
"{",
"disabled",
",",
"max",
",",
"min",
",",
"step",
"}",
"=",
"props",
";",
"function",
"roundToStep",
"(",
"number",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"number",
"/",
"step",
")",
"*",
"step",
";",
"}",
"if",
"(",
"!",
"disabled",
"&&",
"step",
")",
"{",
"if",
"(",
"rawValue",
">",
"min",
"&&",
"rawValue",
"<",
"max",
")",
"{",
"if",
"(",
"rawValue",
"===",
"max",
"-",
"step",
")",
"{",
"return",
"roundToStep",
"(",
"rawValue",
"+",
"step",
"/",
"2",
")",
";",
"}",
"if",
"(",
"rawValue",
"===",
"min",
"+",
"step",
")",
"{",
"return",
"roundToStep",
"(",
"rawValue",
"-",
"step",
"/",
"2",
")",
";",
"}",
"return",
"roundToStep",
"(",
"rawValue",
")",
";",
"}",
"return",
"rawValue",
";",
"}",
"return",
"defaultValueReducer",
"(",
"rawValue",
",",
"props",
",",
"event",
")",
";",
"}"
] |
a value reducer that will snap to multiple of 10 but also to the edge value
Useful here because the max=104 is not a multiple of 10
|
[
"a",
"value",
"reducer",
"that",
"will",
"snap",
"to",
"multiple",
"of",
"10",
"but",
"also",
"to",
"the",
"edge",
"value",
"Useful",
"here",
"because",
"the",
"max",
"=",
"104",
"is",
"not",
"a",
"multiple",
"of",
"10"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/pages/components/slider/CustomValueReducerSlider.js#L16-L39
|
train
|
mui-org/material-ui
|
packages/material-ui-styles/src/jssPreset/jssPreset.js
|
jssPreset
|
function jssPreset() {
return {
plugins: [
functions(),
global(),
nested(),
camelCase(),
defaultUnit(),
// Disable the vendor prefixer server-side, it does nothing.
// This way, we can get a performance boost.
// In the documentation, we are using `autoprefixer` to solve this problem.
typeof window === 'undefined' ? null : vendorPrefixer(),
propsSort(),
],
};
}
|
javascript
|
function jssPreset() {
return {
plugins: [
functions(),
global(),
nested(),
camelCase(),
defaultUnit(),
// Disable the vendor prefixer server-side, it does nothing.
// This way, we can get a performance boost.
// In the documentation, we are using `autoprefixer` to solve this problem.
typeof window === 'undefined' ? null : vendorPrefixer(),
propsSort(),
],
};
}
|
[
"function",
"jssPreset",
"(",
")",
"{",
"return",
"{",
"plugins",
":",
"[",
"functions",
"(",
")",
",",
"global",
"(",
")",
",",
"nested",
"(",
")",
",",
"camelCase",
"(",
")",
",",
"defaultUnit",
"(",
")",
",",
"typeof",
"window",
"===",
"'undefined'",
"?",
"null",
":",
"vendorPrefixer",
"(",
")",
",",
"propsSort",
"(",
")",
",",
"]",
",",
"}",
";",
"}"
] |
Subset of jss-preset-default with only the plugins the Material-UI components are using.
|
[
"Subset",
"of",
"jss",
"-",
"preset",
"-",
"default",
"with",
"only",
"the",
"plugins",
"the",
"Material",
"-",
"UI",
"components",
"are",
"using",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-styles/src/jssPreset/jssPreset.js#L10-L25
|
train
|
mui-org/material-ui
|
packages/material-ui/src/ClickAwayListener/ClickAwayListener.js
|
ClickAwayListener
|
function ClickAwayListener(props) {
const { children, mouseEvent = 'onMouseUp', touchEvent = 'onTouchEnd', onClickAway } = props;
const mountedRef = useMountedRef();
const movedRef = React.useRef(false);
const nodeRef = React.useRef(null);
// can be removed once we drop support for non ref forwarding class components
const handleOwnRef = React.useCallback(instance => {
// #StrictMode ready
nodeRef.current = ReactDOM.findDOMNode(instance);
}, []);
const handleRef = useForkRef(children.ref, handleOwnRef);
const handleClickAway = React.useCallback(
event => {
// Ignore events that have been `event.preventDefault()` marked.
if (event.defaultPrevented) {
return;
}
// IE 11 support, which trigger the handleClickAway even after the unbind
if (!mountedRef.current) {
return;
}
// Do not act if user performed touchmove
if (movedRef.current) {
movedRef.current = false;
return;
}
const { current: node } = nodeRef;
// The child might render null.
if (!node) {
return;
}
const doc = ownerDocument(node);
if (
doc.documentElement &&
doc.documentElement.contains(event.target) &&
!node.contains(event.target)
) {
onClickAway(event);
}
},
[mountedRef, onClickAway],
);
const handleTouchMove = React.useCallback(() => {
movedRef.current = true;
}, []);
const listenerProps = {};
if (mouseEvent !== false) {
listenerProps[mouseEvent] = handleClickAway;
}
if (touchEvent !== false) {
listenerProps[touchEvent] = handleClickAway;
listenerProps.onTouchMove = handleTouchMove;
}
return (
<React.Fragment>
{React.cloneElement(children, { ref: handleRef })}
<EventListener target="document" {...listenerProps} />
</React.Fragment>
);
}
|
javascript
|
function ClickAwayListener(props) {
const { children, mouseEvent = 'onMouseUp', touchEvent = 'onTouchEnd', onClickAway } = props;
const mountedRef = useMountedRef();
const movedRef = React.useRef(false);
const nodeRef = React.useRef(null);
// can be removed once we drop support for non ref forwarding class components
const handleOwnRef = React.useCallback(instance => {
// #StrictMode ready
nodeRef.current = ReactDOM.findDOMNode(instance);
}, []);
const handleRef = useForkRef(children.ref, handleOwnRef);
const handleClickAway = React.useCallback(
event => {
// Ignore events that have been `event.preventDefault()` marked.
if (event.defaultPrevented) {
return;
}
// IE 11 support, which trigger the handleClickAway even after the unbind
if (!mountedRef.current) {
return;
}
// Do not act if user performed touchmove
if (movedRef.current) {
movedRef.current = false;
return;
}
const { current: node } = nodeRef;
// The child might render null.
if (!node) {
return;
}
const doc = ownerDocument(node);
if (
doc.documentElement &&
doc.documentElement.contains(event.target) &&
!node.contains(event.target)
) {
onClickAway(event);
}
},
[mountedRef, onClickAway],
);
const handleTouchMove = React.useCallback(() => {
movedRef.current = true;
}, []);
const listenerProps = {};
if (mouseEvent !== false) {
listenerProps[mouseEvent] = handleClickAway;
}
if (touchEvent !== false) {
listenerProps[touchEvent] = handleClickAway;
listenerProps.onTouchMove = handleTouchMove;
}
return (
<React.Fragment>
{React.cloneElement(children, { ref: handleRef })}
<EventListener target="document" {...listenerProps} />
</React.Fragment>
);
}
|
[
"function",
"ClickAwayListener",
"(",
"props",
")",
"{",
"const",
"{",
"children",
",",
"mouseEvent",
"=",
"'onMouseUp'",
",",
"touchEvent",
"=",
"'onTouchEnd'",
",",
"onClickAway",
"}",
"=",
"props",
";",
"const",
"mountedRef",
"=",
"useMountedRef",
"(",
")",
";",
"const",
"movedRef",
"=",
"React",
".",
"useRef",
"(",
"false",
")",
";",
"const",
"nodeRef",
"=",
"React",
".",
"useRef",
"(",
"null",
")",
";",
"const",
"handleOwnRef",
"=",
"React",
".",
"useCallback",
"(",
"instance",
"=>",
"{",
"nodeRef",
".",
"current",
"=",
"ReactDOM",
".",
"findDOMNode",
"(",
"instance",
")",
";",
"}",
",",
"[",
"]",
")",
";",
"const",
"handleRef",
"=",
"useForkRef",
"(",
"children",
".",
"ref",
",",
"handleOwnRef",
")",
";",
"const",
"handleClickAway",
"=",
"React",
".",
"useCallback",
"(",
"event",
"=>",
"{",
"if",
"(",
"event",
".",
"defaultPrevented",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"mountedRef",
".",
"current",
")",
"{",
"return",
";",
"}",
"if",
"(",
"movedRef",
".",
"current",
")",
"{",
"movedRef",
".",
"current",
"=",
"false",
";",
"return",
";",
"}",
"const",
"{",
"current",
":",
"node",
"}",
"=",
"nodeRef",
";",
"if",
"(",
"!",
"node",
")",
"{",
"return",
";",
"}",
"const",
"doc",
"=",
"ownerDocument",
"(",
"node",
")",
";",
"if",
"(",
"doc",
".",
"documentElement",
"&&",
"doc",
".",
"documentElement",
".",
"contains",
"(",
"event",
".",
"target",
")",
"&&",
"!",
"node",
".",
"contains",
"(",
"event",
".",
"target",
")",
")",
"{",
"onClickAway",
"(",
"event",
")",
";",
"}",
"}",
",",
"[",
"mountedRef",
",",
"onClickAway",
"]",
",",
")",
";",
"const",
"handleTouchMove",
"=",
"React",
".",
"useCallback",
"(",
"(",
")",
"=>",
"{",
"movedRef",
".",
"current",
"=",
"true",
";",
"}",
",",
"[",
"]",
")",
";",
"const",
"listenerProps",
"=",
"{",
"}",
";",
"if",
"(",
"mouseEvent",
"!==",
"false",
")",
"{",
"listenerProps",
"[",
"mouseEvent",
"]",
"=",
"handleClickAway",
";",
"}",
"if",
"(",
"touchEvent",
"!==",
"false",
")",
"{",
"listenerProps",
"[",
"touchEvent",
"]",
"=",
"handleClickAway",
";",
"listenerProps",
".",
"onTouchMove",
"=",
"handleTouchMove",
";",
"}",
"return",
"(",
"<",
"React",
".",
"Fragment",
">",
" ",
"{",
"React",
".",
"cloneElement",
"(",
"children",
",",
"{",
"ref",
":",
"handleRef",
"}",
")",
"}",
" ",
"<",
"EventListener",
"target",
"=",
"\"document\"",
"{",
"...",
"listenerProps",
"}",
"/",
">",
" ",
"<",
"/",
"React",
".",
"Fragment",
">",
")",
";",
"}"
] |
Listen for click events that occur somewhere in the document, outside of the element itself.
For instance, if you need to hide a menu when people click anywhere else on your page.
|
[
"Listen",
"for",
"click",
"events",
"that",
"occur",
"somewhere",
"in",
"the",
"document",
"outside",
"of",
"the",
"element",
"itself",
".",
"For",
"instance",
"if",
"you",
"need",
"to",
"hide",
"a",
"menu",
"when",
"people",
"click",
"anywhere",
"else",
"on",
"your",
"page",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/ClickAwayListener/ClickAwayListener.js#L25-L94
|
train
|
mui-org/material-ui
|
docs/src/pages/discover-more/showcase/Showcase.js
|
sortFactory
|
function sortFactory(key) {
return function sortNumeric(a, b) {
if (b[key] < a[key]) {
return -1;
}
if (b[key] > a[key]) {
return 1;
}
return 0;
};
}
|
javascript
|
function sortFactory(key) {
return function sortNumeric(a, b) {
if (b[key] < a[key]) {
return -1;
}
if (b[key] > a[key]) {
return 1;
}
return 0;
};
}
|
[
"function",
"sortFactory",
"(",
"key",
")",
"{",
"return",
"function",
"sortNumeric",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"b",
"[",
"key",
"]",
"<",
"a",
"[",
"key",
"]",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"b",
"[",
"key",
"]",
">",
"a",
"[",
"key",
"]",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}",
";",
"}"
] |
Returns a function that sorts reverse numerically by value of `key`
|
[
"Returns",
"a",
"function",
"that",
"sorts",
"reverse",
"numerically",
"by",
"value",
"of",
"key"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/pages/discover-more/showcase/Showcase.js#L60-L70
|
train
|
mui-org/material-ui
|
docs/src/pages/guides/interoperability/EmotionCSS.js
|
EmotionCSS
|
function EmotionCSS() {
return (
<div>
<Button>Material-UI</Button>
<Button
css={css`
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
`}
>
Emotion
</Button>
</div>
);
}
|
javascript
|
function EmotionCSS() {
return (
<div>
<Button>Material-UI</Button>
<Button
css={css`
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
`}
>
Emotion
</Button>
</div>
);
}
|
[
"function",
"EmotionCSS",
"(",
")",
"{",
"return",
"(",
"<",
"div",
">",
" ",
"<",
"Button",
">",
"Material-UI",
"<",
"/",
"Button",
">",
" ",
"<",
"Button",
"css",
"=",
"{",
"css",
"`",
"`",
"}",
">",
" Emotion ",
"<",
"/",
"Button",
">",
" ",
"<",
"/",
"div",
">",
")",
";",
"}"
] |
We just assign them the Button's className attribute
|
[
"We",
"just",
"assign",
"them",
"the",
"Button",
"s",
"className",
"attribute"
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/pages/guides/interoperability/EmotionCSS.js#L6-L25
|
train
|
mui-org/material-ui
|
packages/material-ui-icons/builder.js
|
getComponentName
|
function getComponentName(destPath) {
const splitregex = new RegExp(`[\\${path.sep}-]+`);
const parts = destPath
.replace('.js', '')
.split(splitregex)
.map(part => part.charAt(0).toUpperCase() + part.substring(1));
return parts.join('');
}
|
javascript
|
function getComponentName(destPath) {
const splitregex = new RegExp(`[\\${path.sep}-]+`);
const parts = destPath
.replace('.js', '')
.split(splitregex)
.map(part => part.charAt(0).toUpperCase() + part.substring(1));
return parts.join('');
}
|
[
"function",
"getComponentName",
"(",
"destPath",
")",
"{",
"const",
"splitregex",
"=",
"new",
"RegExp",
"(",
"`",
"\\\\",
"${",
"path",
".",
"sep",
"}",
"`",
")",
";",
"const",
"parts",
"=",
"destPath",
".",
"replace",
"(",
"'.js'",
",",
"''",
")",
".",
"split",
"(",
"splitregex",
")",
".",
"map",
"(",
"part",
"=>",
"part",
".",
"charAt",
"(",
"0",
")",
".",
"toUpperCase",
"(",
")",
"+",
"part",
".",
"substring",
"(",
"1",
")",
")",
";",
"return",
"parts",
".",
"join",
"(",
"''",
")",
";",
"}"
] |
Return Pascal-Cased component name.
@param {string} destPath
@returns {string} class name
|
[
"Return",
"Pascal",
"-",
"Cased",
"component",
"name",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-icons/builder.js#L70-L79
|
train
|
mui-org/material-ui
|
packages/material-ui/src/CssBaseline/CssBaseline.js
|
CssBaseline
|
function CssBaseline(props) {
const { children = null } = props;
useStyles();
return <React.Fragment>{children}</React.Fragment>;
}
|
javascript
|
function CssBaseline(props) {
const { children = null } = props;
useStyles();
return <React.Fragment>{children}</React.Fragment>;
}
|
[
"function",
"CssBaseline",
"(",
"props",
")",
"{",
"const",
"{",
"children",
"=",
"null",
"}",
"=",
"props",
";",
"useStyles",
"(",
")",
";",
"return",
"<",
"React",
".",
"Fragment",
">",
"{",
"children",
"}",
"<",
"/",
"React",
".",
"Fragment",
">",
";",
"}"
] |
Kickstart an elegant, consistent, and simple baseline to build upon.
|
[
"Kickstart",
"an",
"elegant",
"consistent",
"and",
"simple",
"baseline",
"to",
"build",
"upon",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/CssBaseline/CssBaseline.js#L37-L41
|
train
|
mui-org/material-ui
|
packages/material-ui-styles/src/ThemeProvider/ThemeProvider.js
|
mergeOuterLocalTheme
|
function mergeOuterLocalTheme(outerTheme, localTheme) {
if (typeof localTheme === 'function') {
const mergedTheme = localTheme(outerTheme);
warning(
mergedTheme,
[
'Material-UI: you should return an object from your theme function, i.e.',
'<ThemeProvider theme={() => ({})} />',
].join('\n'),
);
return mergedTheme;
}
return { ...outerTheme, ...localTheme };
}
|
javascript
|
function mergeOuterLocalTheme(outerTheme, localTheme) {
if (typeof localTheme === 'function') {
const mergedTheme = localTheme(outerTheme);
warning(
mergedTheme,
[
'Material-UI: you should return an object from your theme function, i.e.',
'<ThemeProvider theme={() => ({})} />',
].join('\n'),
);
return mergedTheme;
}
return { ...outerTheme, ...localTheme };
}
|
[
"function",
"mergeOuterLocalTheme",
"(",
"outerTheme",
",",
"localTheme",
")",
"{",
"if",
"(",
"typeof",
"localTheme",
"===",
"'function'",
")",
"{",
"const",
"mergedTheme",
"=",
"localTheme",
"(",
"outerTheme",
")",
";",
"warning",
"(",
"mergedTheme",
",",
"[",
"'Material-UI: you should return an object from your theme function, i.e.'",
",",
"'<ThemeProvider theme={() => ({})} />'",
",",
"]",
".",
"join",
"(",
"'\\n'",
")",
",",
")",
";",
"\\n",
"}",
"return",
"mergedTheme",
";",
"}"
] |
To support composition of theme.
|
[
"To",
"support",
"composition",
"of",
"theme",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-styles/src/ThemeProvider/ThemeProvider.js#L10-L26
|
train
|
mui-org/material-ui
|
packages/material-ui/src/Popover/Popover.js
|
getScrollParent
|
function getScrollParent(parent, child) {
let element = child;
let scrollTop = 0;
while (element && element !== parent) {
element = element.parentNode;
scrollTop += element.scrollTop;
}
return scrollTop;
}
|
javascript
|
function getScrollParent(parent, child) {
let element = child;
let scrollTop = 0;
while (element && element !== parent) {
element = element.parentNode;
scrollTop += element.scrollTop;
}
return scrollTop;
}
|
[
"function",
"getScrollParent",
"(",
"parent",
",",
"child",
")",
"{",
"let",
"element",
"=",
"child",
";",
"let",
"scrollTop",
"=",
"0",
";",
"while",
"(",
"element",
"&&",
"element",
"!==",
"parent",
")",
"{",
"element",
"=",
"element",
".",
"parentNode",
";",
"scrollTop",
"+=",
"element",
".",
"scrollTop",
";",
"}",
"return",
"scrollTop",
";",
"}"
] |
Sum the scrollTop between two elements.
|
[
"Sum",
"the",
"scrollTop",
"between",
"two",
"elements",
"."
] |
1555e52367835946382fbf2a8f681de71318915d
|
https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/Popover/Popover.js#L53-L62
|
train
|
jaywcjlove/linux-command
|
build/build.js
|
emptyDir
|
function emptyDir(dir) {
return new Promise((resolve, reject) => {
FS.emptyDir(dir, err => {
err ? reject(err) : resolve(dir);
})
});
}
|
javascript
|
function emptyDir(dir) {
return new Promise((resolve, reject) => {
FS.emptyDir(dir, err => {
err ? reject(err) : resolve(dir);
})
});
}
|
[
"function",
"emptyDir",
"(",
"dir",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"FS",
".",
"emptyDir",
"(",
"dir",
",",
"err",
"=>",
"{",
"err",
"?",
"reject",
"(",
"err",
")",
":",
"resolve",
"(",
"dir",
")",
";",
"}",
")",
"}",
")",
";",
"}"
] |
Empty a directory
@param {String} dir
|
[
"Empty",
"a",
"directory"
] |
7d6c8c6b3468a0dd5311ee68934c9b8db64469f7
|
https://github.com/jaywcjlove/linux-command/blob/7d6c8c6b3468a0dd5311ee68934c9b8db64469f7/build/build.js#L158-L164
|
train
|
apache/incubator-echarts
|
src/scale/Log.js
|
function (approxTickNum) {
approxTickNum = approxTickNum || 10;
var extent = this._extent;
var span = extent[1] - extent[0];
if (span === Infinity || span <= 0) {
return;
}
var interval = numberUtil.quantity(span);
var err = approxTickNum / span * interval;
// Filter ticks to get closer to the desired count.
if (err <= 0.5) {
interval *= 10;
}
// Interval should be integer
while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
interval *= 10;
}
var niceExtent = [
numberUtil.round(mathCeil(extent[0] / interval) * interval),
numberUtil.round(mathFloor(extent[1] / interval) * interval)
];
this._interval = interval;
this._niceExtent = niceExtent;
}
|
javascript
|
function (approxTickNum) {
approxTickNum = approxTickNum || 10;
var extent = this._extent;
var span = extent[1] - extent[0];
if (span === Infinity || span <= 0) {
return;
}
var interval = numberUtil.quantity(span);
var err = approxTickNum / span * interval;
// Filter ticks to get closer to the desired count.
if (err <= 0.5) {
interval *= 10;
}
// Interval should be integer
while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
interval *= 10;
}
var niceExtent = [
numberUtil.round(mathCeil(extent[0] / interval) * interval),
numberUtil.round(mathFloor(extent[1] / interval) * interval)
];
this._interval = interval;
this._niceExtent = niceExtent;
}
|
[
"function",
"(",
"approxTickNum",
")",
"{",
"approxTickNum",
"=",
"approxTickNum",
"||",
"10",
";",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"span",
"=",
"extent",
"[",
"1",
"]",
"-",
"extent",
"[",
"0",
"]",
";",
"if",
"(",
"span",
"===",
"Infinity",
"||",
"span",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"var",
"interval",
"=",
"numberUtil",
".",
"quantity",
"(",
"span",
")",
";",
"var",
"err",
"=",
"approxTickNum",
"/",
"span",
"*",
"interval",
";",
"if",
"(",
"err",
"<=",
"0.5",
")",
"{",
"interval",
"*=",
"10",
";",
"}",
"while",
"(",
"!",
"isNaN",
"(",
"interval",
")",
"&&",
"Math",
".",
"abs",
"(",
"interval",
")",
"<",
"1",
"&&",
"Math",
".",
"abs",
"(",
"interval",
")",
">",
"0",
")",
"{",
"interval",
"*=",
"10",
";",
"}",
"var",
"niceExtent",
"=",
"[",
"numberUtil",
".",
"round",
"(",
"mathCeil",
"(",
"extent",
"[",
"0",
"]",
"/",
"interval",
")",
"*",
"interval",
")",
",",
"numberUtil",
".",
"round",
"(",
"mathFloor",
"(",
"extent",
"[",
"1",
"]",
"/",
"interval",
")",
"*",
"interval",
")",
"]",
";",
"this",
".",
"_interval",
"=",
"interval",
";",
"this",
".",
"_niceExtent",
"=",
"niceExtent",
";",
"}"
] |
Update interval and extent of intervals for nice ticks
@param {number} [approxTickNum = 10] Given approx tick number
|
[
"Update",
"interval",
"and",
"extent",
"of",
"intervals",
"for",
"nice",
"ticks"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/scale/Log.js#L147-L175
|
train
|
|
apache/incubator-echarts
|
src/scale/Log.js
|
function (opt) {
intervalScaleProto.niceExtent.call(this, opt);
var originalScale = this._originalScale;
originalScale.__fixMin = opt.fixMin;
originalScale.__fixMax = opt.fixMax;
}
|
javascript
|
function (opt) {
intervalScaleProto.niceExtent.call(this, opt);
var originalScale = this._originalScale;
originalScale.__fixMin = opt.fixMin;
originalScale.__fixMax = opt.fixMax;
}
|
[
"function",
"(",
"opt",
")",
"{",
"intervalScaleProto",
".",
"niceExtent",
".",
"call",
"(",
"this",
",",
"opt",
")",
";",
"var",
"originalScale",
"=",
"this",
".",
"_originalScale",
";",
"originalScale",
".",
"__fixMin",
"=",
"opt",
".",
"fixMin",
";",
"originalScale",
".",
"__fixMax",
"=",
"opt",
".",
"fixMax",
";",
"}"
] |
Nice extent.
@override
|
[
"Nice",
"extent",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/scale/Log.js#L181-L187
|
train
|
|
apache/incubator-echarts
|
src/data/Tree.js
|
function (depth) {
var height = 0;
this.depth = depth;
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
child.updateDepthAndHeight(depth + 1);
if (child.height > height) {
height = child.height;
}
}
this.height = height + 1;
}
|
javascript
|
function (depth) {
var height = 0;
this.depth = depth;
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
child.updateDepthAndHeight(depth + 1);
if (child.height > height) {
height = child.height;
}
}
this.height = height + 1;
}
|
[
"function",
"(",
"depth",
")",
"{",
"var",
"height",
"=",
"0",
";",
"this",
".",
"depth",
"=",
"depth",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"child",
"=",
"this",
".",
"children",
"[",
"i",
"]",
";",
"child",
".",
"updateDepthAndHeight",
"(",
"depth",
"+",
"1",
")",
";",
"if",
"(",
"child",
".",
"height",
">",
"height",
")",
"{",
"height",
"=",
"child",
".",
"height",
";",
"}",
"}",
"this",
".",
"height",
"=",
"height",
"+",
"1",
";",
"}"
] |
Update depth and height of this subtree.
@param {number} depth
|
[
"Update",
"depth",
"and",
"height",
"of",
"this",
"subtree",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/Tree.js#L155-L166
|
train
|
|
apache/incubator-echarts
|
src/data/Tree.js
|
function (node) {
var parent = node.parentNode;
while (parent) {
if (parent === this) {
return true;
}
parent = parent.parentNode;
}
return false;
}
|
javascript
|
function (node) {
var parent = node.parentNode;
while (parent) {
if (parent === this) {
return true;
}
parent = parent.parentNode;
}
return false;
}
|
[
"function",
"(",
"node",
")",
"{",
"var",
"parent",
"=",
"node",
".",
"parentNode",
";",
"while",
"(",
"parent",
")",
"{",
"if",
"(",
"parent",
"===",
"this",
")",
"{",
"return",
"true",
";",
"}",
"parent",
"=",
"parent",
".",
"parentNode",
";",
"}",
"return",
"false",
";",
"}"
] |
if this is an ancestor of another node
@public
@param {TreeNode} node another node
@return {boolean} if is ancestor
|
[
"if",
"this",
"is",
"an",
"ancestor",
"of",
"another",
"node"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/Tree.js#L314-L323
|
train
|
|
apache/incubator-echarts
|
src/data/Tree.js
|
function () {
var data = this.data;
var nodes = this._nodes;
for (var i = 0, len = nodes.length; i < len; i++) {
nodes[i].dataIndex = -1;
}
for (var i = 0, len = data.count(); i < len; i++) {
nodes[data.getRawIndex(i)].dataIndex = i;
}
}
|
javascript
|
function () {
var data = this.data;
var nodes = this._nodes;
for (var i = 0, len = nodes.length; i < len; i++) {
nodes[i].dataIndex = -1;
}
for (var i = 0, len = data.count(); i < len; i++) {
nodes[data.getRawIndex(i)].dataIndex = i;
}
}
|
[
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"nodes",
"=",
"this",
".",
"_nodes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"nodes",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"nodes",
"[",
"i",
"]",
".",
"dataIndex",
"=",
"-",
"1",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"data",
".",
"count",
"(",
")",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"nodes",
"[",
"data",
".",
"getRawIndex",
"(",
"i",
")",
"]",
".",
"dataIndex",
"=",
"i",
";",
"}",
"}"
] |
Update item available by list,
when list has been performed options like 'filterSelf' or 'map'.
|
[
"Update",
"item",
"available",
"by",
"list",
"when",
"list",
"has",
"been",
"performed",
"options",
"like",
"filterSelf",
"or",
"map",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/Tree.js#L431-L442
|
train
|
|
apache/incubator-echarts
|
src/data/Tree.js
|
addChild
|
function addChild(child, node) {
var children = node.children;
if (child.parentNode === node) {
return;
}
children.push(child);
child.parentNode = node;
}
|
javascript
|
function addChild(child, node) {
var children = node.children;
if (child.parentNode === node) {
return;
}
children.push(child);
child.parentNode = node;
}
|
[
"function",
"addChild",
"(",
"child",
",",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"if",
"(",
"child",
".",
"parentNode",
"===",
"node",
")",
"{",
"return",
";",
"}",
"children",
".",
"push",
"(",
"child",
")",
";",
"child",
".",
"parentNode",
"=",
"node",
";",
"}"
] |
It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote,
so this function is not ready and not necessary to be public.
@param {(module:echarts/data/Tree~TreeNode|Object)} child
|
[
"It",
"is",
"needed",
"to",
"consider",
"the",
"mess",
"of",
"list",
"hostModel",
"when",
"creating",
"a",
"TreeNote",
"so",
"this",
"function",
"is",
"not",
"ready",
"and",
"not",
"necessary",
"to",
"be",
"public",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/Tree.js#L531-L539
|
train
|
apache/incubator-echarts
|
src/ExtensionAPI.js
|
ExtensionAPI
|
function ExtensionAPI(chartInstance) {
zrUtil.each(echartsAPIList, function (name) {
this[name] = zrUtil.bind(chartInstance[name], chartInstance);
}, this);
}
|
javascript
|
function ExtensionAPI(chartInstance) {
zrUtil.each(echartsAPIList, function (name) {
this[name] = zrUtil.bind(chartInstance[name], chartInstance);
}, this);
}
|
[
"function",
"ExtensionAPI",
"(",
"chartInstance",
")",
"{",
"zrUtil",
".",
"each",
"(",
"echartsAPIList",
",",
"function",
"(",
"name",
")",
"{",
"this",
"[",
"name",
"]",
"=",
"zrUtil",
".",
"bind",
"(",
"chartInstance",
"[",
"name",
"]",
",",
"chartInstance",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] |
And `getCoordinateSystems` and `getComponentByElement` will be injected in echarts.js
|
[
"And",
"getCoordinateSystems",
"and",
"getComponentByElement",
"will",
"be",
"injected",
"in",
"echarts",
".",
"js"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/ExtensionAPI.js#L29-L33
|
train
|
apache/incubator-echarts
|
src/chart/boxplot/boxplotLayout.js
|
groupSeriesByAxis
|
function groupSeriesByAxis(ecModel) {
var result = [];
var axisList = [];
ecModel.eachSeriesByType('boxplot', function (seriesModel) {
var baseAxis = seriesModel.getBaseAxis();
var idx = zrUtil.indexOf(axisList, baseAxis);
if (idx < 0) {
idx = axisList.length;
axisList[idx] = baseAxis;
result[idx] = {axis: baseAxis, seriesModels: []};
}
result[idx].seriesModels.push(seriesModel);
});
return result;
}
|
javascript
|
function groupSeriesByAxis(ecModel) {
var result = [];
var axisList = [];
ecModel.eachSeriesByType('boxplot', function (seriesModel) {
var baseAxis = seriesModel.getBaseAxis();
var idx = zrUtil.indexOf(axisList, baseAxis);
if (idx < 0) {
idx = axisList.length;
axisList[idx] = baseAxis;
result[idx] = {axis: baseAxis, seriesModels: []};
}
result[idx].seriesModels.push(seriesModel);
});
return result;
}
|
[
"function",
"groupSeriesByAxis",
"(",
"ecModel",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"axisList",
"=",
"[",
"]",
";",
"ecModel",
".",
"eachSeriesByType",
"(",
"'boxplot'",
",",
"function",
"(",
"seriesModel",
")",
"{",
"var",
"baseAxis",
"=",
"seriesModel",
".",
"getBaseAxis",
"(",
")",
";",
"var",
"idx",
"=",
"zrUtil",
".",
"indexOf",
"(",
"axisList",
",",
"baseAxis",
")",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"idx",
"=",
"axisList",
".",
"length",
";",
"axisList",
"[",
"idx",
"]",
"=",
"baseAxis",
";",
"result",
"[",
"idx",
"]",
"=",
"{",
"axis",
":",
"baseAxis",
",",
"seriesModels",
":",
"[",
"]",
"}",
";",
"}",
"result",
"[",
"idx",
"]",
".",
"seriesModels",
".",
"push",
"(",
"seriesModel",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Group series by axis.
|
[
"Group",
"series",
"by",
"axis",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/boxplot/boxplotLayout.js#L51-L69
|
train
|
apache/incubator-echarts
|
src/chart/boxplot/boxplotLayout.js
|
calculateBase
|
function calculateBase(groupItem) {
var extent;
var baseAxis = groupItem.axis;
var seriesModels = groupItem.seriesModels;
var seriesCount = seriesModels.length;
var boxWidthList = groupItem.boxWidthList = [];
var boxOffsetList = groupItem.boxOffsetList = [];
var boundList = [];
var bandWidth;
if (baseAxis.type === 'category') {
bandWidth = baseAxis.getBandWidth();
}
else {
var maxDataCount = 0;
each(seriesModels, function (seriesModel) {
maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
});
extent = baseAxis.getExtent(),
Math.abs(extent[1] - extent[0]) / maxDataCount;
}
each(seriesModels, function (seriesModel) {
var boxWidthBound = seriesModel.get('boxWidth');
if (!zrUtil.isArray(boxWidthBound)) {
boxWidthBound = [boxWidthBound, boxWidthBound];
}
boundList.push([
parsePercent(boxWidthBound[0], bandWidth) || 0,
parsePercent(boxWidthBound[1], bandWidth) || 0
]);
});
var availableWidth = bandWidth * 0.8 - 2;
var boxGap = availableWidth / seriesCount * 0.3;
var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
var base = boxWidth / 2 - availableWidth / 2;
each(seriesModels, function (seriesModel, idx) {
boxOffsetList.push(base);
base += boxGap + boxWidth;
boxWidthList.push(
Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
);
});
}
|
javascript
|
function calculateBase(groupItem) {
var extent;
var baseAxis = groupItem.axis;
var seriesModels = groupItem.seriesModels;
var seriesCount = seriesModels.length;
var boxWidthList = groupItem.boxWidthList = [];
var boxOffsetList = groupItem.boxOffsetList = [];
var boundList = [];
var bandWidth;
if (baseAxis.type === 'category') {
bandWidth = baseAxis.getBandWidth();
}
else {
var maxDataCount = 0;
each(seriesModels, function (seriesModel) {
maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
});
extent = baseAxis.getExtent(),
Math.abs(extent[1] - extent[0]) / maxDataCount;
}
each(seriesModels, function (seriesModel) {
var boxWidthBound = seriesModel.get('boxWidth');
if (!zrUtil.isArray(boxWidthBound)) {
boxWidthBound = [boxWidthBound, boxWidthBound];
}
boundList.push([
parsePercent(boxWidthBound[0], bandWidth) || 0,
parsePercent(boxWidthBound[1], bandWidth) || 0
]);
});
var availableWidth = bandWidth * 0.8 - 2;
var boxGap = availableWidth / seriesCount * 0.3;
var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
var base = boxWidth / 2 - availableWidth / 2;
each(seriesModels, function (seriesModel, idx) {
boxOffsetList.push(base);
base += boxGap + boxWidth;
boxWidthList.push(
Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
);
});
}
|
[
"function",
"calculateBase",
"(",
"groupItem",
")",
"{",
"var",
"extent",
";",
"var",
"baseAxis",
"=",
"groupItem",
".",
"axis",
";",
"var",
"seriesModels",
"=",
"groupItem",
".",
"seriesModels",
";",
"var",
"seriesCount",
"=",
"seriesModels",
".",
"length",
";",
"var",
"boxWidthList",
"=",
"groupItem",
".",
"boxWidthList",
"=",
"[",
"]",
";",
"var",
"boxOffsetList",
"=",
"groupItem",
".",
"boxOffsetList",
"=",
"[",
"]",
";",
"var",
"boundList",
"=",
"[",
"]",
";",
"var",
"bandWidth",
";",
"if",
"(",
"baseAxis",
".",
"type",
"===",
"'category'",
")",
"{",
"bandWidth",
"=",
"baseAxis",
".",
"getBandWidth",
"(",
")",
";",
"}",
"else",
"{",
"var",
"maxDataCount",
"=",
"0",
";",
"each",
"(",
"seriesModels",
",",
"function",
"(",
"seriesModel",
")",
"{",
"maxDataCount",
"=",
"Math",
".",
"max",
"(",
"maxDataCount",
",",
"seriesModel",
".",
"getData",
"(",
")",
".",
"count",
"(",
")",
")",
";",
"}",
")",
";",
"extent",
"=",
"baseAxis",
".",
"getExtent",
"(",
")",
",",
"Math",
".",
"abs",
"(",
"extent",
"[",
"1",
"]",
"-",
"extent",
"[",
"0",
"]",
")",
"/",
"maxDataCount",
";",
"}",
"each",
"(",
"seriesModels",
",",
"function",
"(",
"seriesModel",
")",
"{",
"var",
"boxWidthBound",
"=",
"seriesModel",
".",
"get",
"(",
"'boxWidth'",
")",
";",
"if",
"(",
"!",
"zrUtil",
".",
"isArray",
"(",
"boxWidthBound",
")",
")",
"{",
"boxWidthBound",
"=",
"[",
"boxWidthBound",
",",
"boxWidthBound",
"]",
";",
"}",
"boundList",
".",
"push",
"(",
"[",
"parsePercent",
"(",
"boxWidthBound",
"[",
"0",
"]",
",",
"bandWidth",
")",
"||",
"0",
",",
"parsePercent",
"(",
"boxWidthBound",
"[",
"1",
"]",
",",
"bandWidth",
")",
"||",
"0",
"]",
")",
";",
"}",
")",
";",
"var",
"availableWidth",
"=",
"bandWidth",
"*",
"0.8",
"-",
"2",
";",
"var",
"boxGap",
"=",
"availableWidth",
"/",
"seriesCount",
"*",
"0.3",
";",
"var",
"boxWidth",
"=",
"(",
"availableWidth",
"-",
"boxGap",
"*",
"(",
"seriesCount",
"-",
"1",
")",
")",
"/",
"seriesCount",
";",
"var",
"base",
"=",
"boxWidth",
"/",
"2",
"-",
"availableWidth",
"/",
"2",
";",
"each",
"(",
"seriesModels",
",",
"function",
"(",
"seriesModel",
",",
"idx",
")",
"{",
"boxOffsetList",
".",
"push",
"(",
"base",
")",
";",
"base",
"+=",
"boxGap",
"+",
"boxWidth",
";",
"boxWidthList",
".",
"push",
"(",
"Math",
".",
"min",
"(",
"Math",
".",
"max",
"(",
"boxWidth",
",",
"boundList",
"[",
"idx",
"]",
"[",
"0",
"]",
")",
",",
"boundList",
"[",
"idx",
"]",
"[",
"1",
"]",
")",
")",
";",
"}",
")",
";",
"}"
] |
Calculate offset and box width for each series.
|
[
"Calculate",
"offset",
"and",
"box",
"width",
"for",
"each",
"series",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/boxplot/boxplotLayout.js#L74-L121
|
train
|
apache/incubator-echarts
|
src/chart/boxplot/boxplotLayout.js
|
layoutSingleSeries
|
function layoutSingleSeries(seriesModel, offset, boxWidth) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var halfWidth = boxWidth / 2;
var cDimIdx = seriesModel.get('layout') === 'horizontal' ? 0 : 1;
var vDimIdx = 1 - cDimIdx;
var coordDims = ['x', 'y'];
var cDim = data.mapDimension(coordDims[cDimIdx]);
var vDims = data.mapDimension(coordDims[vDimIdx], true);
if (cDim == null || vDims.length < 5) {
return;
}
for (var dataIndex = 0; dataIndex < data.count(); dataIndex++) {
var axisDimVal = data.get(cDim, dataIndex);
var median = getPoint(axisDimVal, vDims[2], dataIndex);
var end1 = getPoint(axisDimVal, vDims[0], dataIndex);
var end2 = getPoint(axisDimVal, vDims[1], dataIndex);
var end4 = getPoint(axisDimVal, vDims[3], dataIndex);
var end5 = getPoint(axisDimVal, vDims[4], dataIndex);
var ends = [];
addBodyEnd(ends, end2, 0);
addBodyEnd(ends, end4, 1);
ends.push(end1, end2, end5, end4);
layEndLine(ends, end1);
layEndLine(ends, end5);
layEndLine(ends, median);
data.setItemLayout(dataIndex, {
initBaseline: median[vDimIdx],
ends: ends
});
}
function getPoint(axisDimVal, dimIdx, dataIndex) {
var val = data.get(dimIdx, dataIndex);
var p = [];
p[cDimIdx] = axisDimVal;
p[vDimIdx] = val;
var point;
if (isNaN(axisDimVal) || isNaN(val)) {
point = [NaN, NaN];
}
else {
point = coordSys.dataToPoint(p);
point[cDimIdx] += offset;
}
return point;
}
function addBodyEnd(ends, point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[cDimIdx] += halfWidth;
point2[cDimIdx] -= halfWidth;
start
? ends.push(point1, point2)
: ends.push(point2, point1);
}
function layEndLine(ends, endCenter) {
var from = endCenter.slice();
var to = endCenter.slice();
from[cDimIdx] -= halfWidth;
to[cDimIdx] += halfWidth;
ends.push(from, to);
}
}
|
javascript
|
function layoutSingleSeries(seriesModel, offset, boxWidth) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var halfWidth = boxWidth / 2;
var cDimIdx = seriesModel.get('layout') === 'horizontal' ? 0 : 1;
var vDimIdx = 1 - cDimIdx;
var coordDims = ['x', 'y'];
var cDim = data.mapDimension(coordDims[cDimIdx]);
var vDims = data.mapDimension(coordDims[vDimIdx], true);
if (cDim == null || vDims.length < 5) {
return;
}
for (var dataIndex = 0; dataIndex < data.count(); dataIndex++) {
var axisDimVal = data.get(cDim, dataIndex);
var median = getPoint(axisDimVal, vDims[2], dataIndex);
var end1 = getPoint(axisDimVal, vDims[0], dataIndex);
var end2 = getPoint(axisDimVal, vDims[1], dataIndex);
var end4 = getPoint(axisDimVal, vDims[3], dataIndex);
var end5 = getPoint(axisDimVal, vDims[4], dataIndex);
var ends = [];
addBodyEnd(ends, end2, 0);
addBodyEnd(ends, end4, 1);
ends.push(end1, end2, end5, end4);
layEndLine(ends, end1);
layEndLine(ends, end5);
layEndLine(ends, median);
data.setItemLayout(dataIndex, {
initBaseline: median[vDimIdx],
ends: ends
});
}
function getPoint(axisDimVal, dimIdx, dataIndex) {
var val = data.get(dimIdx, dataIndex);
var p = [];
p[cDimIdx] = axisDimVal;
p[vDimIdx] = val;
var point;
if (isNaN(axisDimVal) || isNaN(val)) {
point = [NaN, NaN];
}
else {
point = coordSys.dataToPoint(p);
point[cDimIdx] += offset;
}
return point;
}
function addBodyEnd(ends, point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[cDimIdx] += halfWidth;
point2[cDimIdx] -= halfWidth;
start
? ends.push(point1, point2)
: ends.push(point2, point1);
}
function layEndLine(ends, endCenter) {
var from = endCenter.slice();
var to = endCenter.slice();
from[cDimIdx] -= halfWidth;
to[cDimIdx] += halfWidth;
ends.push(from, to);
}
}
|
[
"function",
"layoutSingleSeries",
"(",
"seriesModel",
",",
"offset",
",",
"boxWidth",
")",
"{",
"var",
"coordSys",
"=",
"seriesModel",
".",
"coordinateSystem",
";",
"var",
"data",
"=",
"seriesModel",
".",
"getData",
"(",
")",
";",
"var",
"halfWidth",
"=",
"boxWidth",
"/",
"2",
";",
"var",
"cDimIdx",
"=",
"seriesModel",
".",
"get",
"(",
"'layout'",
")",
"===",
"'horizontal'",
"?",
"0",
":",
"1",
";",
"var",
"vDimIdx",
"=",
"1",
"-",
"cDimIdx",
";",
"var",
"coordDims",
"=",
"[",
"'x'",
",",
"'y'",
"]",
";",
"var",
"cDim",
"=",
"data",
".",
"mapDimension",
"(",
"coordDims",
"[",
"cDimIdx",
"]",
")",
";",
"var",
"vDims",
"=",
"data",
".",
"mapDimension",
"(",
"coordDims",
"[",
"vDimIdx",
"]",
",",
"true",
")",
";",
"if",
"(",
"cDim",
"==",
"null",
"||",
"vDims",
".",
"length",
"<",
"5",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"dataIndex",
"=",
"0",
";",
"dataIndex",
"<",
"data",
".",
"count",
"(",
")",
";",
"dataIndex",
"++",
")",
"{",
"var",
"axisDimVal",
"=",
"data",
".",
"get",
"(",
"cDim",
",",
"dataIndex",
")",
";",
"var",
"median",
"=",
"getPoint",
"(",
"axisDimVal",
",",
"vDims",
"[",
"2",
"]",
",",
"dataIndex",
")",
";",
"var",
"end1",
"=",
"getPoint",
"(",
"axisDimVal",
",",
"vDims",
"[",
"0",
"]",
",",
"dataIndex",
")",
";",
"var",
"end2",
"=",
"getPoint",
"(",
"axisDimVal",
",",
"vDims",
"[",
"1",
"]",
",",
"dataIndex",
")",
";",
"var",
"end4",
"=",
"getPoint",
"(",
"axisDimVal",
",",
"vDims",
"[",
"3",
"]",
",",
"dataIndex",
")",
";",
"var",
"end5",
"=",
"getPoint",
"(",
"axisDimVal",
",",
"vDims",
"[",
"4",
"]",
",",
"dataIndex",
")",
";",
"var",
"ends",
"=",
"[",
"]",
";",
"addBodyEnd",
"(",
"ends",
",",
"end2",
",",
"0",
")",
";",
"addBodyEnd",
"(",
"ends",
",",
"end4",
",",
"1",
")",
";",
"ends",
".",
"push",
"(",
"end1",
",",
"end2",
",",
"end5",
",",
"end4",
")",
";",
"layEndLine",
"(",
"ends",
",",
"end1",
")",
";",
"layEndLine",
"(",
"ends",
",",
"end5",
")",
";",
"layEndLine",
"(",
"ends",
",",
"median",
")",
";",
"data",
".",
"setItemLayout",
"(",
"dataIndex",
",",
"{",
"initBaseline",
":",
"median",
"[",
"vDimIdx",
"]",
",",
"ends",
":",
"ends",
"}",
")",
";",
"}",
"function",
"getPoint",
"(",
"axisDimVal",
",",
"dimIdx",
",",
"dataIndex",
")",
"{",
"var",
"val",
"=",
"data",
".",
"get",
"(",
"dimIdx",
",",
"dataIndex",
")",
";",
"var",
"p",
"=",
"[",
"]",
";",
"p",
"[",
"cDimIdx",
"]",
"=",
"axisDimVal",
";",
"p",
"[",
"vDimIdx",
"]",
"=",
"val",
";",
"var",
"point",
";",
"if",
"(",
"isNaN",
"(",
"axisDimVal",
")",
"||",
"isNaN",
"(",
"val",
")",
")",
"{",
"point",
"=",
"[",
"NaN",
",",
"NaN",
"]",
";",
"}",
"else",
"{",
"point",
"=",
"coordSys",
".",
"dataToPoint",
"(",
"p",
")",
";",
"point",
"[",
"cDimIdx",
"]",
"+=",
"offset",
";",
"}",
"return",
"point",
";",
"}",
"function",
"addBodyEnd",
"(",
"ends",
",",
"point",
",",
"start",
")",
"{",
"var",
"point1",
"=",
"point",
".",
"slice",
"(",
")",
";",
"var",
"point2",
"=",
"point",
".",
"slice",
"(",
")",
";",
"point1",
"[",
"cDimIdx",
"]",
"+=",
"halfWidth",
";",
"point2",
"[",
"cDimIdx",
"]",
"-=",
"halfWidth",
";",
"start",
"?",
"ends",
".",
"push",
"(",
"point1",
",",
"point2",
")",
":",
"ends",
".",
"push",
"(",
"point2",
",",
"point1",
")",
";",
"}",
"function",
"layEndLine",
"(",
"ends",
",",
"endCenter",
")",
"{",
"var",
"from",
"=",
"endCenter",
".",
"slice",
"(",
")",
";",
"var",
"to",
"=",
"endCenter",
".",
"slice",
"(",
")",
";",
"from",
"[",
"cDimIdx",
"]",
"-=",
"halfWidth",
";",
"to",
"[",
"cDimIdx",
"]",
"+=",
"halfWidth",
";",
"ends",
".",
"push",
"(",
"from",
",",
"to",
")",
";",
"}",
"}"
] |
Calculate points location for each series.
|
[
"Calculate",
"points",
"location",
"for",
"each",
"series",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/boxplot/boxplotLayout.js#L126-L197
|
train
|
apache/incubator-echarts
|
src/component/axisPointer/viewHelper.js
|
confineInContainer
|
function confineInContainer(position, width, height, api) {
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
position[0] = Math.min(position[0] + width, viewWidth) - width;
position[1] = Math.min(position[1] + height, viewHeight) - height;
position[0] = Math.max(position[0], 0);
position[1] = Math.max(position[1], 0);
}
|
javascript
|
function confineInContainer(position, width, height, api) {
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
position[0] = Math.min(position[0] + width, viewWidth) - width;
position[1] = Math.min(position[1] + height, viewHeight) - height;
position[0] = Math.max(position[0], 0);
position[1] = Math.max(position[1], 0);
}
|
[
"function",
"confineInContainer",
"(",
"position",
",",
"width",
",",
"height",
",",
"api",
")",
"{",
"var",
"viewWidth",
"=",
"api",
".",
"getWidth",
"(",
")",
";",
"var",
"viewHeight",
"=",
"api",
".",
"getHeight",
"(",
")",
";",
"position",
"[",
"0",
"]",
"=",
"Math",
".",
"min",
"(",
"position",
"[",
"0",
"]",
"+",
"width",
",",
"viewWidth",
")",
"-",
"width",
";",
"position",
"[",
"1",
"]",
"=",
"Math",
".",
"min",
"(",
"position",
"[",
"1",
"]",
"+",
"height",
",",
"viewHeight",
")",
"-",
"height",
";",
"position",
"[",
"0",
"]",
"=",
"Math",
".",
"max",
"(",
"position",
"[",
"0",
"]",
",",
"0",
")",
";",
"position",
"[",
"1",
"]",
"=",
"Math",
".",
"max",
"(",
"position",
"[",
"1",
"]",
",",
"0",
")",
";",
"}"
] |
Do not overflow ec container
|
[
"Do",
"not",
"overflow",
"ec",
"container"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/axisPointer/viewHelper.js#L110-L117
|
train
|
apache/incubator-echarts
|
src/component/marker/markerHelper.js
|
markerTypeCalculatorWithExtent
|
function markerTypeCalculatorWithExtent(
mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
) {
var coordArr = [];
var stacked = isDimensionStacked(data, targetDataDim /*, otherDataDim*/);
var calcDataDim = stacked
? data.getCalculationInfo('stackResultDimension')
: targetDataDim;
var value = numCalculate(data, calcDataDim, mlType);
var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex);
// Make it simple, do not visit all stacked value to count precision.
var precision = numberUtil.getPrecision(data.get(targetDataDim, dataIndex));
precision = Math.min(precision, 20);
if (precision >= 0) {
coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
}
return coordArr;
}
|
javascript
|
function markerTypeCalculatorWithExtent(
mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
) {
var coordArr = [];
var stacked = isDimensionStacked(data, targetDataDim /*, otherDataDim*/);
var calcDataDim = stacked
? data.getCalculationInfo('stackResultDimension')
: targetDataDim;
var value = numCalculate(data, calcDataDim, mlType);
var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex);
// Make it simple, do not visit all stacked value to count precision.
var precision = numberUtil.getPrecision(data.get(targetDataDim, dataIndex));
precision = Math.min(precision, 20);
if (precision >= 0) {
coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
}
return coordArr;
}
|
[
"function",
"markerTypeCalculatorWithExtent",
"(",
"mlType",
",",
"data",
",",
"otherDataDim",
",",
"targetDataDim",
",",
"otherCoordIndex",
",",
"targetCoordIndex",
")",
"{",
"var",
"coordArr",
"=",
"[",
"]",
";",
"var",
"stacked",
"=",
"isDimensionStacked",
"(",
"data",
",",
"targetDataDim",
")",
";",
"var",
"calcDataDim",
"=",
"stacked",
"?",
"data",
".",
"getCalculationInfo",
"(",
"'stackResultDimension'",
")",
":",
"targetDataDim",
";",
"var",
"value",
"=",
"numCalculate",
"(",
"data",
",",
"calcDataDim",
",",
"mlType",
")",
";",
"var",
"dataIndex",
"=",
"data",
".",
"indicesOfNearest",
"(",
"calcDataDim",
",",
"value",
")",
"[",
"0",
"]",
";",
"coordArr",
"[",
"otherCoordIndex",
"]",
"=",
"data",
".",
"get",
"(",
"otherDataDim",
",",
"dataIndex",
")",
";",
"coordArr",
"[",
"targetCoordIndex",
"]",
"=",
"data",
".",
"get",
"(",
"targetDataDim",
",",
"dataIndex",
")",
";",
"var",
"precision",
"=",
"numberUtil",
".",
"getPrecision",
"(",
"data",
".",
"get",
"(",
"targetDataDim",
",",
"dataIndex",
")",
")",
";",
"precision",
"=",
"Math",
".",
"min",
"(",
"precision",
",",
"20",
")",
";",
"if",
"(",
"precision",
">=",
"0",
")",
"{",
"coordArr",
"[",
"targetCoordIndex",
"]",
"=",
"+",
"coordArr",
"[",
"targetCoordIndex",
"]",
".",
"toFixed",
"(",
"precision",
")",
";",
"}",
"return",
"coordArr",
";",
"}"
] |
return precision; }
|
[
"return",
"precision",
";",
"}"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/marker/markerHelper.js#L58-L82
|
train
|
apache/incubator-echarts
|
src/model/Series.js
|
function (option, ecModel) {
var layoutMode = this.layoutMode;
var inputPositionParams = layoutMode
? getLayoutParams(option) : {};
// Backward compat: using subType on theme.
// But if name duplicate between series subType
// (for example: parallel) add component mainType,
// add suffix 'Series'.
var themeSubType = this.subType;
if (ComponentModel.hasClass(themeSubType)) {
themeSubType += 'Series';
}
zrUtil.merge(
option,
ecModel.getTheme().get(this.subType)
);
zrUtil.merge(option, this.getDefaultOption());
// Default label emphasis `show`
modelUtil.defaultEmphasis(option, 'label', ['show']);
this.fillDataTextStyle(option.data);
if (layoutMode) {
mergeLayoutParam(option, inputPositionParams, layoutMode);
}
}
|
javascript
|
function (option, ecModel) {
var layoutMode = this.layoutMode;
var inputPositionParams = layoutMode
? getLayoutParams(option) : {};
// Backward compat: using subType on theme.
// But if name duplicate between series subType
// (for example: parallel) add component mainType,
// add suffix 'Series'.
var themeSubType = this.subType;
if (ComponentModel.hasClass(themeSubType)) {
themeSubType += 'Series';
}
zrUtil.merge(
option,
ecModel.getTheme().get(this.subType)
);
zrUtil.merge(option, this.getDefaultOption());
// Default label emphasis `show`
modelUtil.defaultEmphasis(option, 'label', ['show']);
this.fillDataTextStyle(option.data);
if (layoutMode) {
mergeLayoutParam(option, inputPositionParams, layoutMode);
}
}
|
[
"function",
"(",
"option",
",",
"ecModel",
")",
"{",
"var",
"layoutMode",
"=",
"this",
".",
"layoutMode",
";",
"var",
"inputPositionParams",
"=",
"layoutMode",
"?",
"getLayoutParams",
"(",
"option",
")",
":",
"{",
"}",
";",
"var",
"themeSubType",
"=",
"this",
".",
"subType",
";",
"if",
"(",
"ComponentModel",
".",
"hasClass",
"(",
"themeSubType",
")",
")",
"{",
"themeSubType",
"+=",
"'Series'",
";",
"}",
"zrUtil",
".",
"merge",
"(",
"option",
",",
"ecModel",
".",
"getTheme",
"(",
")",
".",
"get",
"(",
"this",
".",
"subType",
")",
")",
";",
"zrUtil",
".",
"merge",
"(",
"option",
",",
"this",
".",
"getDefaultOption",
"(",
")",
")",
";",
"modelUtil",
".",
"defaultEmphasis",
"(",
"option",
",",
"'label'",
",",
"[",
"'show'",
"]",
")",
";",
"this",
".",
"fillDataTextStyle",
"(",
"option",
".",
"data",
")",
";",
"if",
"(",
"layoutMode",
")",
"{",
"mergeLayoutParam",
"(",
"option",
",",
"inputPositionParams",
",",
"layoutMode",
")",
";",
"}",
"}"
] |
Util for merge default and theme to option
@param {Object} option
@param {module:echarts/model/Global} ecModel
|
[
"Util",
"for",
"merge",
"default",
"and",
"theme",
"to",
"option"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Series.js#L137-L164
|
train
|
|
apache/incubator-echarts
|
src/model/Series.js
|
autoSeriesName
|
function autoSeriesName(seriesModel) {
// User specified name has higher priority, otherwise it may cause
// series can not be queried unexpectedly.
var name = seriesModel.name;
if (!modelUtil.isNameSpecified(seriesModel)) {
seriesModel.name = getSeriesAutoName(seriesModel) || name;
}
}
|
javascript
|
function autoSeriesName(seriesModel) {
// User specified name has higher priority, otherwise it may cause
// series can not be queried unexpectedly.
var name = seriesModel.name;
if (!modelUtil.isNameSpecified(seriesModel)) {
seriesModel.name = getSeriesAutoName(seriesModel) || name;
}
}
|
[
"function",
"autoSeriesName",
"(",
"seriesModel",
")",
"{",
"var",
"name",
"=",
"seriesModel",
".",
"name",
";",
"if",
"(",
"!",
"modelUtil",
".",
"isNameSpecified",
"(",
"seriesModel",
")",
")",
"{",
"seriesModel",
".",
"name",
"=",
"getSeriesAutoName",
"(",
"seriesModel",
")",
"||",
"name",
";",
"}",
"}"
] |
MUST be called after `prepareSource` called
Here we need to make auto series, especially for auto legend. But we
do not modify series.name in option to avoid side effects.
|
[
"MUST",
"be",
"called",
"after",
"prepareSource",
"called",
"Here",
"we",
"need",
"to",
"make",
"auto",
"series",
"especially",
"for",
"auto",
"legend",
".",
"But",
"we",
"do",
"not",
"modify",
"series",
".",
"name",
"in",
"option",
"to",
"avoid",
"side",
"effects",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Series.js#L550-L557
|
train
|
apache/incubator-echarts
|
src/chart/bar/BarView.js
|
getLineWidth
|
function getLineWidth(itemModel, rawLayout) {
var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
}
|
javascript
|
function getLineWidth(itemModel, rawLayout) {
var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
}
|
[
"function",
"getLineWidth",
"(",
"itemModel",
",",
"rawLayout",
")",
"{",
"var",
"lineWidth",
"=",
"itemModel",
".",
"get",
"(",
"BAR_BORDER_WIDTH_QUERY",
")",
"||",
"0",
";",
"return",
"Math",
".",
"min",
"(",
"lineWidth",
",",
"Math",
".",
"abs",
"(",
"rawLayout",
".",
"width",
")",
",",
"Math",
".",
"abs",
"(",
"rawLayout",
".",
"height",
")",
")",
";",
"}"
] |
In case width or height are too small.
|
[
"In",
"case",
"width",
"or",
"height",
"are",
"too",
"small",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/bar/BarView.js#L335-L338
|
train
|
apache/incubator-echarts
|
src/coord/geo/geoCreator.js
|
resizeGeo
|
function resizeGeo(geoModel, api) {
var boundingCoords = geoModel.get('boundingCoords');
if (boundingCoords != null) {
var leftTop = boundingCoords[0];
var rightBottom = boundingCoords[1];
if (isNaN(leftTop[0]) || isNaN(leftTop[1]) || isNaN(rightBottom[0]) || isNaN(rightBottom[1])) {
if (__DEV__) {
console.error('Invalid boundingCoords');
}
}
else {
this.setBoundingRect(leftTop[0], leftTop[1], rightBottom[0] - leftTop[0], rightBottom[1] - leftTop[1]);
}
}
var rect = this.getBoundingRect();
var boxLayoutOption;
var center = geoModel.get('layoutCenter');
var size = geoModel.get('layoutSize');
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
var aspect = rect.width / rect.height * this.aspectScale;
var useCenterAndSize = false;
if (center && size) {
center = [
numberUtil.parsePercent(center[0], viewWidth),
numberUtil.parsePercent(center[1], viewHeight)
];
size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
useCenterAndSize = true;
}
else {
if (__DEV__) {
console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
}
}
}
var viewRect;
if (useCenterAndSize) {
var viewRect = {};
if (aspect > 1) {
// Width is same with size
viewRect.width = size;
viewRect.height = size / aspect;
}
else {
viewRect.height = size;
viewRect.width = size * aspect;
}
viewRect.y = center[1] - viewRect.height / 2;
viewRect.x = center[0] - viewRect.width / 2;
}
else {
// Use left/top/width/height
boxLayoutOption = geoModel.getBoxLayoutParams();
// 0.75 rate
boxLayoutOption.aspect = aspect;
viewRect = layout.getLayoutRect(boxLayoutOption, {
width: viewWidth,
height: viewHeight
});
}
this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
this.setCenter(geoModel.get('center'));
this.setZoom(geoModel.get('zoom'));
}
|
javascript
|
function resizeGeo(geoModel, api) {
var boundingCoords = geoModel.get('boundingCoords');
if (boundingCoords != null) {
var leftTop = boundingCoords[0];
var rightBottom = boundingCoords[1];
if (isNaN(leftTop[0]) || isNaN(leftTop[1]) || isNaN(rightBottom[0]) || isNaN(rightBottom[1])) {
if (__DEV__) {
console.error('Invalid boundingCoords');
}
}
else {
this.setBoundingRect(leftTop[0], leftTop[1], rightBottom[0] - leftTop[0], rightBottom[1] - leftTop[1]);
}
}
var rect = this.getBoundingRect();
var boxLayoutOption;
var center = geoModel.get('layoutCenter');
var size = geoModel.get('layoutSize');
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
var aspect = rect.width / rect.height * this.aspectScale;
var useCenterAndSize = false;
if (center && size) {
center = [
numberUtil.parsePercent(center[0], viewWidth),
numberUtil.parsePercent(center[1], viewHeight)
];
size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
useCenterAndSize = true;
}
else {
if (__DEV__) {
console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
}
}
}
var viewRect;
if (useCenterAndSize) {
var viewRect = {};
if (aspect > 1) {
// Width is same with size
viewRect.width = size;
viewRect.height = size / aspect;
}
else {
viewRect.height = size;
viewRect.width = size * aspect;
}
viewRect.y = center[1] - viewRect.height / 2;
viewRect.x = center[0] - viewRect.width / 2;
}
else {
// Use left/top/width/height
boxLayoutOption = geoModel.getBoxLayoutParams();
// 0.75 rate
boxLayoutOption.aspect = aspect;
viewRect = layout.getLayoutRect(boxLayoutOption, {
width: viewWidth,
height: viewHeight
});
}
this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
this.setCenter(geoModel.get('center'));
this.setZoom(geoModel.get('zoom'));
}
|
[
"function",
"resizeGeo",
"(",
"geoModel",
",",
"api",
")",
"{",
"var",
"boundingCoords",
"=",
"geoModel",
".",
"get",
"(",
"'boundingCoords'",
")",
";",
"if",
"(",
"boundingCoords",
"!=",
"null",
")",
"{",
"var",
"leftTop",
"=",
"boundingCoords",
"[",
"0",
"]",
";",
"var",
"rightBottom",
"=",
"boundingCoords",
"[",
"1",
"]",
";",
"if",
"(",
"isNaN",
"(",
"leftTop",
"[",
"0",
"]",
")",
"||",
"isNaN",
"(",
"leftTop",
"[",
"1",
"]",
")",
"||",
"isNaN",
"(",
"rightBottom",
"[",
"0",
"]",
")",
"||",
"isNaN",
"(",
"rightBottom",
"[",
"1",
"]",
")",
")",
"{",
"if",
"(",
"__DEV__",
")",
"{",
"console",
".",
"error",
"(",
"'Invalid boundingCoords'",
")",
";",
"}",
"}",
"else",
"{",
"this",
".",
"setBoundingRect",
"(",
"leftTop",
"[",
"0",
"]",
",",
"leftTop",
"[",
"1",
"]",
",",
"rightBottom",
"[",
"0",
"]",
"-",
"leftTop",
"[",
"0",
"]",
",",
"rightBottom",
"[",
"1",
"]",
"-",
"leftTop",
"[",
"1",
"]",
")",
";",
"}",
"}",
"var",
"rect",
"=",
"this",
".",
"getBoundingRect",
"(",
")",
";",
"var",
"boxLayoutOption",
";",
"var",
"center",
"=",
"geoModel",
".",
"get",
"(",
"'layoutCenter'",
")",
";",
"var",
"size",
"=",
"geoModel",
".",
"get",
"(",
"'layoutSize'",
")",
";",
"var",
"viewWidth",
"=",
"api",
".",
"getWidth",
"(",
")",
";",
"var",
"viewHeight",
"=",
"api",
".",
"getHeight",
"(",
")",
";",
"var",
"aspect",
"=",
"rect",
".",
"width",
"/",
"rect",
".",
"height",
"*",
"this",
".",
"aspectScale",
";",
"var",
"useCenterAndSize",
"=",
"false",
";",
"if",
"(",
"center",
"&&",
"size",
")",
"{",
"center",
"=",
"[",
"numberUtil",
".",
"parsePercent",
"(",
"center",
"[",
"0",
"]",
",",
"viewWidth",
")",
",",
"numberUtil",
".",
"parsePercent",
"(",
"center",
"[",
"1",
"]",
",",
"viewHeight",
")",
"]",
";",
"size",
"=",
"numberUtil",
".",
"parsePercent",
"(",
"size",
",",
"Math",
".",
"min",
"(",
"viewWidth",
",",
"viewHeight",
")",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"center",
"[",
"0",
"]",
")",
"&&",
"!",
"isNaN",
"(",
"center",
"[",
"1",
"]",
")",
"&&",
"!",
"isNaN",
"(",
"size",
")",
")",
"{",
"useCenterAndSize",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"__DEV__",
")",
"{",
"console",
".",
"warn",
"(",
"'Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.'",
")",
";",
"}",
"}",
"}",
"var",
"viewRect",
";",
"if",
"(",
"useCenterAndSize",
")",
"{",
"var",
"viewRect",
"=",
"{",
"}",
";",
"if",
"(",
"aspect",
">",
"1",
")",
"{",
"viewRect",
".",
"width",
"=",
"size",
";",
"viewRect",
".",
"height",
"=",
"size",
"/",
"aspect",
";",
"}",
"else",
"{",
"viewRect",
".",
"height",
"=",
"size",
";",
"viewRect",
".",
"width",
"=",
"size",
"*",
"aspect",
";",
"}",
"viewRect",
".",
"y",
"=",
"center",
"[",
"1",
"]",
"-",
"viewRect",
".",
"height",
"/",
"2",
";",
"viewRect",
".",
"x",
"=",
"center",
"[",
"0",
"]",
"-",
"viewRect",
".",
"width",
"/",
"2",
";",
"}",
"else",
"{",
"boxLayoutOption",
"=",
"geoModel",
".",
"getBoxLayoutParams",
"(",
")",
";",
"boxLayoutOption",
".",
"aspect",
"=",
"aspect",
";",
"viewRect",
"=",
"layout",
".",
"getLayoutRect",
"(",
"boxLayoutOption",
",",
"{",
"width",
":",
"viewWidth",
",",
"height",
":",
"viewHeight",
"}",
")",
";",
"}",
"this",
".",
"setViewRect",
"(",
"viewRect",
".",
"x",
",",
"viewRect",
".",
"y",
",",
"viewRect",
".",
"width",
",",
"viewRect",
".",
"height",
")",
";",
"this",
".",
"setCenter",
"(",
"geoModel",
".",
"get",
"(",
"'center'",
")",
")",
";",
"this",
".",
"setZoom",
"(",
"geoModel",
".",
"get",
"(",
"'zoom'",
")",
")",
";",
"}"
] |
Resize method bound to the geo
@param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
@param {module:echarts/ExtensionAPI} api
|
[
"Resize",
"method",
"bound",
"to",
"the",
"geo"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/geo/geoCreator.js#L34-L113
|
train
|
apache/incubator-echarts
|
src/coord/geo/geoCreator.js
|
function (originRegionArr, mapName, nameMap) {
// Not use the original
var regionsArr = (originRegionArr || []).slice();
var dataNameMap = zrUtil.createHashMap();
for (var i = 0; i < regionsArr.length; i++) {
dataNameMap.set(regionsArr[i].name, regionsArr[i]);
}
var source = geoSourceManager.load(mapName, nameMap);
zrUtil.each(source.regions, function (region) {
var name = region.name;
!dataNameMap.get(name) && regionsArr.push({name: name});
});
return regionsArr;
}
|
javascript
|
function (originRegionArr, mapName, nameMap) {
// Not use the original
var regionsArr = (originRegionArr || []).slice();
var dataNameMap = zrUtil.createHashMap();
for (var i = 0; i < regionsArr.length; i++) {
dataNameMap.set(regionsArr[i].name, regionsArr[i]);
}
var source = geoSourceManager.load(mapName, nameMap);
zrUtil.each(source.regions, function (region) {
var name = region.name;
!dataNameMap.get(name) && regionsArr.push({name: name});
});
return regionsArr;
}
|
[
"function",
"(",
"originRegionArr",
",",
"mapName",
",",
"nameMap",
")",
"{",
"var",
"regionsArr",
"=",
"(",
"originRegionArr",
"||",
"[",
"]",
")",
".",
"slice",
"(",
")",
";",
"var",
"dataNameMap",
"=",
"zrUtil",
".",
"createHashMap",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"regionsArr",
".",
"length",
";",
"i",
"++",
")",
"{",
"dataNameMap",
".",
"set",
"(",
"regionsArr",
"[",
"i",
"]",
".",
"name",
",",
"regionsArr",
"[",
"i",
"]",
")",
";",
"}",
"var",
"source",
"=",
"geoSourceManager",
".",
"load",
"(",
"mapName",
",",
"nameMap",
")",
";",
"zrUtil",
".",
"each",
"(",
"source",
".",
"regions",
",",
"function",
"(",
"region",
")",
"{",
"var",
"name",
"=",
"region",
".",
"name",
";",
"!",
"dataNameMap",
".",
"get",
"(",
"name",
")",
"&&",
"regionsArr",
".",
"push",
"(",
"{",
"name",
":",
"name",
"}",
")",
";",
"}",
")",
";",
"return",
"regionsArr",
";",
"}"
] |
Fill given regions array
@param {Array.<Object>} originRegionArr
@param {string} mapName
@param {Object} [nameMap]
@return {Array}
|
[
"Fill",
"given",
"regions",
"array"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/geo/geoCreator.js#L219-L235
|
train
|
|
apache/incubator-echarts
|
src/chart/sankey/SankeyView.js
|
createGridClipShape
|
function createGridClipShape(rect, seriesModel, cb) {
var rectEl = new graphic.Rect({
shape: {
x: rect.x - 10,
y: rect.y - 10,
width: 0,
height: rect.height + 20
}
});
graphic.initProps(rectEl, {
shape: {
width: rect.width + 20,
height: rect.height + 20
}
}, seriesModel, cb);
return rectEl;
}
|
javascript
|
function createGridClipShape(rect, seriesModel, cb) {
var rectEl = new graphic.Rect({
shape: {
x: rect.x - 10,
y: rect.y - 10,
width: 0,
height: rect.height + 20
}
});
graphic.initProps(rectEl, {
shape: {
width: rect.width + 20,
height: rect.height + 20
}
}, seriesModel, cb);
return rectEl;
}
|
[
"function",
"createGridClipShape",
"(",
"rect",
",",
"seriesModel",
",",
"cb",
")",
"{",
"var",
"rectEl",
"=",
"new",
"graphic",
".",
"Rect",
"(",
"{",
"shape",
":",
"{",
"x",
":",
"rect",
".",
"x",
"-",
"10",
",",
"y",
":",
"rect",
".",
"y",
"-",
"10",
",",
"width",
":",
"0",
",",
"height",
":",
"rect",
".",
"height",
"+",
"20",
"}",
"}",
")",
";",
"graphic",
".",
"initProps",
"(",
"rectEl",
",",
"{",
"shape",
":",
"{",
"width",
":",
"rect",
".",
"width",
"+",
"20",
",",
"height",
":",
"rect",
".",
"height",
"+",
"20",
"}",
"}",
",",
"seriesModel",
",",
"cb",
")",
";",
"return",
"rectEl",
";",
"}"
] |
Add animation to the view
|
[
"Add",
"animation",
"to",
"the",
"view"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/SankeyView.js#L409-L426
|
train
|
apache/incubator-echarts
|
src/component/marker/MarkAreaView.js
|
ifMarkLineHasOnlyDim
|
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
}
|
javascript
|
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
}
|
[
"function",
"ifMarkLineHasOnlyDim",
"(",
"dimIndex",
",",
"fromCoord",
",",
"toCoord",
",",
"coordSys",
")",
"{",
"var",
"otherDimIndex",
"=",
"1",
"-",
"dimIndex",
";",
"return",
"isInifinity",
"(",
"fromCoord",
"[",
"otherDimIndex",
"]",
")",
"&&",
"isInifinity",
"(",
"toCoord",
"[",
"otherDimIndex",
"]",
")",
";",
"}"
] |
If a markArea has one dim
|
[
"If",
"a",
"markArea",
"has",
"one",
"dim"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/marker/MarkAreaView.js#L63-L66
|
train
|
apache/incubator-echarts
|
src/chart/treemap/TreemapSeries.js
|
function (dataIndex) {
var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
var node = this.getData().tree.getNodeByDataIndex(dataIndex);
params.treePathInfo = wrapTreePathInfo(node, this);
return params;
}
|
javascript
|
function (dataIndex) {
var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
var node = this.getData().tree.getNodeByDataIndex(dataIndex);
params.treePathInfo = wrapTreePathInfo(node, this);
return params;
}
|
[
"function",
"(",
"dataIndex",
")",
"{",
"var",
"params",
"=",
"SeriesModel",
".",
"prototype",
".",
"getDataParams",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"node",
"=",
"this",
".",
"getData",
"(",
")",
".",
"tree",
".",
"getNodeByDataIndex",
"(",
"dataIndex",
")",
";",
"params",
".",
"treePathInfo",
"=",
"wrapTreePathInfo",
"(",
"node",
",",
"this",
")",
";",
"return",
"params",
";",
"}"
] |
Add tree path to tooltip param
@override
@param {number} dataIndex
@return {Object}
|
[
"Add",
"tree",
"path",
"to",
"tooltip",
"param"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/TreemapSeries.js#L222-L229
|
train
|
|
apache/incubator-echarts
|
src/chart/treemap/TreemapSeries.js
|
setDefault
|
function setDefault(levels, ecModel) {
var globalColorList = ecModel.get('color');
if (!globalColorList) {
return;
}
levels = levels || [];
var hasColorDefine;
zrUtil.each(levels, function (levelDefine) {
var model = new Model(levelDefine);
var modelColor = model.get('color');
if (model.get('itemStyle.color')
|| (modelColor && modelColor !== 'none')
) {
hasColorDefine = true;
}
});
if (!hasColorDefine) {
var level0 = levels[0] || (levels[0] = {});
level0.color = globalColorList.slice();
}
return levels;
}
|
javascript
|
function setDefault(levels, ecModel) {
var globalColorList = ecModel.get('color');
if (!globalColorList) {
return;
}
levels = levels || [];
var hasColorDefine;
zrUtil.each(levels, function (levelDefine) {
var model = new Model(levelDefine);
var modelColor = model.get('color');
if (model.get('itemStyle.color')
|| (modelColor && modelColor !== 'none')
) {
hasColorDefine = true;
}
});
if (!hasColorDefine) {
var level0 = levels[0] || (levels[0] = {});
level0.color = globalColorList.slice();
}
return levels;
}
|
[
"function",
"setDefault",
"(",
"levels",
",",
"ecModel",
")",
"{",
"var",
"globalColorList",
"=",
"ecModel",
".",
"get",
"(",
"'color'",
")",
";",
"if",
"(",
"!",
"globalColorList",
")",
"{",
"return",
";",
"}",
"levels",
"=",
"levels",
"||",
"[",
"]",
";",
"var",
"hasColorDefine",
";",
"zrUtil",
".",
"each",
"(",
"levels",
",",
"function",
"(",
"levelDefine",
")",
"{",
"var",
"model",
"=",
"new",
"Model",
"(",
"levelDefine",
")",
";",
"var",
"modelColor",
"=",
"model",
".",
"get",
"(",
"'color'",
")",
";",
"if",
"(",
"model",
".",
"get",
"(",
"'itemStyle.color'",
")",
"||",
"(",
"modelColor",
"&&",
"modelColor",
"!==",
"'none'",
")",
")",
"{",
"hasColorDefine",
"=",
"true",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"hasColorDefine",
")",
"{",
"var",
"level0",
"=",
"levels",
"[",
"0",
"]",
"||",
"(",
"levels",
"[",
"0",
"]",
"=",
"{",
"}",
")",
";",
"level0",
".",
"color",
"=",
"globalColorList",
".",
"slice",
"(",
")",
";",
"}",
"return",
"levels",
";",
"}"
] |
set default to level configuration
|
[
"set",
"default",
"to",
"level",
"configuration"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/TreemapSeries.js#L347-L373
|
train
|
apache/incubator-echarts
|
src/component/marker/MarkLineView.js
|
ifMarkLineHasOnlyDim
|
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
var dimName = coordSys.dimensions[dimIndex];
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
&& fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
}
|
javascript
|
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
var dimName = coordSys.dimensions[dimIndex];
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
&& fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
}
|
[
"function",
"ifMarkLineHasOnlyDim",
"(",
"dimIndex",
",",
"fromCoord",
",",
"toCoord",
",",
"coordSys",
")",
"{",
"var",
"otherDimIndex",
"=",
"1",
"-",
"dimIndex",
";",
"var",
"dimName",
"=",
"coordSys",
".",
"dimensions",
"[",
"dimIndex",
"]",
";",
"return",
"isInifinity",
"(",
"fromCoord",
"[",
"otherDimIndex",
"]",
")",
"&&",
"isInifinity",
"(",
"toCoord",
"[",
"otherDimIndex",
"]",
")",
"&&",
"fromCoord",
"[",
"dimIndex",
"]",
"===",
"toCoord",
"[",
"dimIndex",
"]",
"&&",
"coordSys",
".",
"getAxis",
"(",
"dimName",
")",
".",
"containData",
"(",
"fromCoord",
"[",
"dimIndex",
"]",
")",
";",
"}"
] |
If a markLine has one dim
|
[
"If",
"a",
"markLine",
"has",
"one",
"dim"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/marker/MarkLineView.js#L107-L112
|
train
|
apache/incubator-echarts
|
src/component/marker/MarkLineView.js
|
function (markLineModel, ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
var mlModel = seriesModel.markLineModel;
if (mlModel) {
var mlData = mlModel.getData();
var fromData = mlModel.__from;
var toData = mlModel.__to;
// Update visual and layout of from symbol and to symbol
fromData.each(function (idx) {
updateSingleMarkerEndLayout(fromData, idx, true, seriesModel, api);
updateSingleMarkerEndLayout(toData, idx, false, seriesModel, api);
});
// Update layout of line
mlData.each(function (idx) {
mlData.setItemLayout(idx, [
fromData.getItemLayout(idx),
toData.getItemLayout(idx)
]);
});
this.markerGroupMap.get(seriesModel.id).updateLayout();
}
}, this);
}
|
javascript
|
function (markLineModel, ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
var mlModel = seriesModel.markLineModel;
if (mlModel) {
var mlData = mlModel.getData();
var fromData = mlModel.__from;
var toData = mlModel.__to;
// Update visual and layout of from symbol and to symbol
fromData.each(function (idx) {
updateSingleMarkerEndLayout(fromData, idx, true, seriesModel, api);
updateSingleMarkerEndLayout(toData, idx, false, seriesModel, api);
});
// Update layout of line
mlData.each(function (idx) {
mlData.setItemLayout(idx, [
fromData.getItemLayout(idx),
toData.getItemLayout(idx)
]);
});
this.markerGroupMap.get(seriesModel.id).updateLayout();
}
}, this);
}
|
[
"function",
"(",
"markLineModel",
",",
"ecModel",
",",
"api",
")",
"{",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"var",
"mlModel",
"=",
"seriesModel",
".",
"markLineModel",
";",
"if",
"(",
"mlModel",
")",
"{",
"var",
"mlData",
"=",
"mlModel",
".",
"getData",
"(",
")",
";",
"var",
"fromData",
"=",
"mlModel",
".",
"__from",
";",
"var",
"toData",
"=",
"mlModel",
".",
"__to",
";",
"fromData",
".",
"each",
"(",
"function",
"(",
"idx",
")",
"{",
"updateSingleMarkerEndLayout",
"(",
"fromData",
",",
"idx",
",",
"true",
",",
"seriesModel",
",",
"api",
")",
";",
"updateSingleMarkerEndLayout",
"(",
"toData",
",",
"idx",
",",
"false",
",",
"seriesModel",
",",
"api",
")",
";",
"}",
")",
";",
"mlData",
".",
"each",
"(",
"function",
"(",
"idx",
")",
"{",
"mlData",
".",
"setItemLayout",
"(",
"idx",
",",
"[",
"fromData",
".",
"getItemLayout",
"(",
"idx",
")",
",",
"toData",
".",
"getItemLayout",
"(",
"idx",
")",
"]",
")",
";",
"}",
")",
";",
"this",
".",
"markerGroupMap",
".",
"get",
"(",
"seriesModel",
".",
"id",
")",
".",
"updateLayout",
"(",
")",
";",
"}",
"}",
",",
"this",
")",
";",
"}"
] |
} }, this); },
|
[
"}",
"}",
"this",
")",
";",
"}"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/marker/MarkLineView.js#L225-L249
|
train
|
|
apache/incubator-echarts
|
src/util/symbol.js
|
symbolPathSetColor
|
function symbolPathSetColor(color, innerColor) {
if (this.type !== 'image') {
var symbolStyle = this.style;
var symbolShape = this.shape;
if (symbolShape && symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = innerColor || '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
symbolStyle.fill && (symbolStyle.fill = color);
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty(false);
}
}
|
javascript
|
function symbolPathSetColor(color, innerColor) {
if (this.type !== 'image') {
var symbolStyle = this.style;
var symbolShape = this.shape;
if (symbolShape && symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = innerColor || '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
symbolStyle.fill && (symbolStyle.fill = color);
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty(false);
}
}
|
[
"function",
"symbolPathSetColor",
"(",
"color",
",",
"innerColor",
")",
"{",
"if",
"(",
"this",
".",
"type",
"!==",
"'image'",
")",
"{",
"var",
"symbolStyle",
"=",
"this",
".",
"style",
";",
"var",
"symbolShape",
"=",
"this",
".",
"shape",
";",
"if",
"(",
"symbolShape",
"&&",
"symbolShape",
".",
"symbolType",
"===",
"'line'",
")",
"{",
"symbolStyle",
".",
"stroke",
"=",
"color",
";",
"}",
"else",
"if",
"(",
"this",
".",
"__isEmptyBrush",
")",
"{",
"symbolStyle",
".",
"stroke",
"=",
"color",
";",
"symbolStyle",
".",
"fill",
"=",
"innerColor",
"||",
"'#fff'",
";",
"}",
"else",
"{",
"symbolStyle",
".",
"fill",
"&&",
"(",
"symbolStyle",
".",
"fill",
"=",
"color",
")",
";",
"symbolStyle",
".",
"stroke",
"&&",
"(",
"symbolStyle",
".",
"stroke",
"=",
"color",
")",
";",
"}",
"this",
".",
"dirty",
"(",
"false",
")",
";",
"}",
"}"
] |
Provide setColor helper method to avoid determine if set the fill or stroke outside
|
[
"Provide",
"setColor",
"helper",
"method",
"to",
"avoid",
"determine",
"if",
"set",
"the",
"fill",
"or",
"stroke",
"outside"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/util/symbol.js#L301-L319
|
train
|
apache/incubator-echarts
|
build/amd2common.js
|
parse
|
function parse(raw) {
var output = '';
var ast = esprima.parse(raw, {
range: true,
raw: true
});
var defines = ast.body.filter(isDefine);
if (defines.length > 1) {
throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
}
else if (!defines.length) {
return raw;
}
var def = defines[0];
var args = def.expression['arguments'];
var factory = getFactory(args);
var useStrict = getUseStrict(factory);
// do replacements in-place to avoid modifying the code more than needed
if (useStrict) {
output += useStrict.expression.raw + ';\n';
}
output += raw.substring(0, def.range[0]); // anything before define
output += getRequires(args, factory); // add requires
output += getBody(raw, factory.body, useStrict); // module body
output += raw.substring(def.range[1], raw.length); // anything after define
return output;
}
|
javascript
|
function parse(raw) {
var output = '';
var ast = esprima.parse(raw, {
range: true,
raw: true
});
var defines = ast.body.filter(isDefine);
if (defines.length > 1) {
throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
}
else if (!defines.length) {
return raw;
}
var def = defines[0];
var args = def.expression['arguments'];
var factory = getFactory(args);
var useStrict = getUseStrict(factory);
// do replacements in-place to avoid modifying the code more than needed
if (useStrict) {
output += useStrict.expression.raw + ';\n';
}
output += raw.substring(0, def.range[0]); // anything before define
output += getRequires(args, factory); // add requires
output += getBody(raw, factory.body, useStrict); // module body
output += raw.substring(def.range[1], raw.length); // anything after define
return output;
}
|
[
"function",
"parse",
"(",
"raw",
")",
"{",
"var",
"output",
"=",
"''",
";",
"var",
"ast",
"=",
"esprima",
".",
"parse",
"(",
"raw",
",",
"{",
"range",
":",
"true",
",",
"raw",
":",
"true",
"}",
")",
";",
"var",
"defines",
"=",
"ast",
".",
"body",
".",
"filter",
"(",
"isDefine",
")",
";",
"if",
"(",
"defines",
".",
"length",
">",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Each file can have only a single define call. Found \"'",
"+",
"defines",
".",
"length",
"+",
"'\"'",
")",
";",
"}",
"else",
"if",
"(",
"!",
"defines",
".",
"length",
")",
"{",
"return",
"raw",
";",
"}",
"var",
"def",
"=",
"defines",
"[",
"0",
"]",
";",
"var",
"args",
"=",
"def",
".",
"expression",
"[",
"'arguments'",
"]",
";",
"var",
"factory",
"=",
"getFactory",
"(",
"args",
")",
";",
"var",
"useStrict",
"=",
"getUseStrict",
"(",
"factory",
")",
";",
"if",
"(",
"useStrict",
")",
"{",
"output",
"+=",
"useStrict",
".",
"expression",
".",
"raw",
"+",
"';\\n'",
";",
"}",
"\\n",
"output",
"+=",
"raw",
".",
"substring",
"(",
"0",
",",
"def",
".",
"range",
"[",
"0",
"]",
")",
";",
"output",
"+=",
"getRequires",
"(",
"args",
",",
"factory",
")",
";",
"output",
"+=",
"getBody",
"(",
"raw",
",",
"factory",
".",
"body",
",",
"useStrict",
")",
";",
"output",
"+=",
"raw",
".",
"substring",
"(",
"def",
".",
"range",
"[",
"1",
"]",
",",
"raw",
".",
"length",
")",
";",
"}"
] |
Convert AMD-style JavaScript string into node.js compatible module
|
[
"Convert",
"AMD",
"-",
"style",
"JavaScript",
"string",
"into",
"node",
".",
"js",
"compatible",
"module"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/build/amd2common.js#L57-L89
|
train
|
apache/incubator-echarts
|
src/visual/VisualMapping.js
|
function () {
var thisOption = this.option;
return zrUtil.bind(
thisOption.mappingMethod === 'category'
? function (value, isNormalized) {
!isNormalized && (value = this._normalizeData(value));
return doMapCategory.call(this, value);
}
: function (value, isNormalized, out) {
// If output rgb array
// which will be much faster and useful in pixel manipulation
var returnRGBArray = !!out;
!isNormalized && (value = this._normalizeData(value));
out = zrColor.fastLerp(value, thisOption.parsedVisual, out);
return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
},
this
);
}
|
javascript
|
function () {
var thisOption = this.option;
return zrUtil.bind(
thisOption.mappingMethod === 'category'
? function (value, isNormalized) {
!isNormalized && (value = this._normalizeData(value));
return doMapCategory.call(this, value);
}
: function (value, isNormalized, out) {
// If output rgb array
// which will be much faster and useful in pixel manipulation
var returnRGBArray = !!out;
!isNormalized && (value = this._normalizeData(value));
out = zrColor.fastLerp(value, thisOption.parsedVisual, out);
return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
},
this
);
}
|
[
"function",
"(",
")",
"{",
"var",
"thisOption",
"=",
"this",
".",
"option",
";",
"return",
"zrUtil",
".",
"bind",
"(",
"thisOption",
".",
"mappingMethod",
"===",
"'category'",
"?",
"function",
"(",
"value",
",",
"isNormalized",
")",
"{",
"!",
"isNormalized",
"&&",
"(",
"value",
"=",
"this",
".",
"_normalizeData",
"(",
"value",
")",
")",
";",
"return",
"doMapCategory",
".",
"call",
"(",
"this",
",",
"value",
")",
";",
"}",
":",
"function",
"(",
"value",
",",
"isNormalized",
",",
"out",
")",
"{",
"var",
"returnRGBArray",
"=",
"!",
"!",
"out",
";",
"!",
"isNormalized",
"&&",
"(",
"value",
"=",
"this",
".",
"_normalizeData",
"(",
"value",
")",
")",
";",
"out",
"=",
"zrColor",
".",
"fastLerp",
"(",
"value",
",",
"thisOption",
".",
"parsedVisual",
",",
"out",
")",
";",
"return",
"returnRGBArray",
"?",
"out",
":",
"zrColor",
".",
"stringify",
"(",
"out",
",",
"'rgba'",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] |
Create a mapper function
@return {Function}
|
[
"Create",
"a",
"mapper",
"function"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/visual/VisualMapping.js#L146-L165
|
train
|
|
apache/incubator-echarts
|
src/component/helper/BrushController.js
|
function (brushOptionList) {
if (__DEV__) {
zrUtil.assert(this._mounted);
}
brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
});
var tmpIdPrefix = '\0-brush-index-';
var oldCovers = this._covers;
var newCovers = this._covers = [];
var controller = this;
var creatingCover = this._creatingCover;
(new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
.add(addOrUpdate)
.update(addOrUpdate)
.remove(remove)
.execute();
return this;
function getKey(brushOption, index) {
return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
+ '-' + brushOption.brushType;
}
function oldGetKey(cover, index) {
return getKey(cover.__brushOption, index);
}
function addOrUpdate(newIndex, oldIndex) {
var newBrushOption = brushOptionList[newIndex];
// Consider setOption in event listener of brushSelect,
// where updating cover when creating should be forbiden.
if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
newCovers[newIndex] = oldCovers[oldIndex];
}
else {
var cover = newCovers[newIndex] = oldIndex != null
? (
oldCovers[oldIndex].__brushOption = newBrushOption,
oldCovers[oldIndex]
)
: endCreating(controller, createCover(controller, newBrushOption));
updateCoverAfterCreation(controller, cover);
}
}
function remove(oldIndex) {
if (oldCovers[oldIndex] !== creatingCover) {
controller.group.remove(oldCovers[oldIndex]);
}
}
}
|
javascript
|
function (brushOptionList) {
if (__DEV__) {
zrUtil.assert(this._mounted);
}
brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
});
var tmpIdPrefix = '\0-brush-index-';
var oldCovers = this._covers;
var newCovers = this._covers = [];
var controller = this;
var creatingCover = this._creatingCover;
(new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
.add(addOrUpdate)
.update(addOrUpdate)
.remove(remove)
.execute();
return this;
function getKey(brushOption, index) {
return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
+ '-' + brushOption.brushType;
}
function oldGetKey(cover, index) {
return getKey(cover.__brushOption, index);
}
function addOrUpdate(newIndex, oldIndex) {
var newBrushOption = brushOptionList[newIndex];
// Consider setOption in event listener of brushSelect,
// where updating cover when creating should be forbiden.
if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
newCovers[newIndex] = oldCovers[oldIndex];
}
else {
var cover = newCovers[newIndex] = oldIndex != null
? (
oldCovers[oldIndex].__brushOption = newBrushOption,
oldCovers[oldIndex]
)
: endCreating(controller, createCover(controller, newBrushOption));
updateCoverAfterCreation(controller, cover);
}
}
function remove(oldIndex) {
if (oldCovers[oldIndex] !== creatingCover) {
controller.group.remove(oldCovers[oldIndex]);
}
}
}
|
[
"function",
"(",
"brushOptionList",
")",
"{",
"if",
"(",
"__DEV__",
")",
"{",
"zrUtil",
".",
"assert",
"(",
"this",
".",
"_mounted",
")",
";",
"}",
"brushOptionList",
"=",
"zrUtil",
".",
"map",
"(",
"brushOptionList",
",",
"function",
"(",
"brushOption",
")",
"{",
"return",
"zrUtil",
".",
"merge",
"(",
"zrUtil",
".",
"clone",
"(",
"DEFAULT_BRUSH_OPT",
")",
",",
"brushOption",
",",
"true",
")",
";",
"}",
")",
";",
"var",
"tmpIdPrefix",
"=",
"'\\0-brush-index-'",
";",
"\\0",
"var",
"oldCovers",
"=",
"this",
".",
"_covers",
";",
"var",
"newCovers",
"=",
"this",
".",
"_covers",
"=",
"[",
"]",
";",
"var",
"controller",
"=",
"this",
";",
"var",
"creatingCover",
"=",
"this",
".",
"_creatingCover",
";",
"(",
"new",
"DataDiffer",
"(",
"oldCovers",
",",
"brushOptionList",
",",
"oldGetKey",
",",
"getKey",
")",
")",
".",
"add",
"(",
"addOrUpdate",
")",
".",
"update",
"(",
"addOrUpdate",
")",
".",
"remove",
"(",
"remove",
")",
".",
"execute",
"(",
")",
";",
"return",
"this",
";",
"function",
"getKey",
"(",
"brushOption",
",",
"index",
")",
"{",
"return",
"(",
"brushOption",
".",
"id",
"!=",
"null",
"?",
"brushOption",
".",
"id",
":",
"tmpIdPrefix",
"+",
"index",
")",
"+",
"'-'",
"+",
"brushOption",
".",
"brushType",
";",
"}",
"function",
"oldGetKey",
"(",
"cover",
",",
"index",
")",
"{",
"return",
"getKey",
"(",
"cover",
".",
"__brushOption",
",",
"index",
")",
";",
"}",
"function",
"addOrUpdate",
"(",
"newIndex",
",",
"oldIndex",
")",
"{",
"var",
"newBrushOption",
"=",
"brushOptionList",
"[",
"newIndex",
"]",
";",
"if",
"(",
"oldIndex",
"!=",
"null",
"&&",
"oldCovers",
"[",
"oldIndex",
"]",
"===",
"creatingCover",
")",
"{",
"newCovers",
"[",
"newIndex",
"]",
"=",
"oldCovers",
"[",
"oldIndex",
"]",
";",
"}",
"else",
"{",
"var",
"cover",
"=",
"newCovers",
"[",
"newIndex",
"]",
"=",
"oldIndex",
"!=",
"null",
"?",
"(",
"oldCovers",
"[",
"oldIndex",
"]",
".",
"__brushOption",
"=",
"newBrushOption",
",",
"oldCovers",
"[",
"oldIndex",
"]",
")",
":",
"endCreating",
"(",
"controller",
",",
"createCover",
"(",
"controller",
",",
"newBrushOption",
")",
")",
";",
"updateCoverAfterCreation",
"(",
"controller",
",",
"cover",
")",
";",
"}",
"}",
"}"
] |
Update covers.
@param {Array.<Object>} brushOptionList Like:
[
{id: 'xx', brushType: 'line', range: [23, 44], brushStyle, transformable},
{id: 'yy', brushType: 'rect', range: [[23, 44], [23, 54]]},
...
]
`brushType` is required in each cover info. (can not be 'auto')
`id` is not mandatory.
`brushStyle`, `transformable` is not mandatory, use DEFAULT_BRUSH_OPT by default.
If brushOptionList is null/undefined, all covers removed.
|
[
"Update",
"covers",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/helper/BrushController.js#L286-L341
|
train
|
|
apache/incubator-echarts
|
src/component/helper/BrushController.js
|
getPanelByCover
|
function getPanelByCover(controller, cover) {
var panels = controller._panels;
if (!panels) {
return true; // Global panel
}
var panelId = cover.__brushOption.panelId;
// User may give cover without coord sys info,
// which is then treated as global panel.
return panelId != null ? panels[panelId] : true;
}
|
javascript
|
function getPanelByCover(controller, cover) {
var panels = controller._panels;
if (!panels) {
return true; // Global panel
}
var panelId = cover.__brushOption.panelId;
// User may give cover without coord sys info,
// which is then treated as global panel.
return panelId != null ? panels[panelId] : true;
}
|
[
"function",
"getPanelByCover",
"(",
"controller",
",",
"cover",
")",
"{",
"var",
"panels",
"=",
"controller",
".",
"_panels",
";",
"if",
"(",
"!",
"panels",
")",
"{",
"return",
"true",
";",
"}",
"var",
"panelId",
"=",
"cover",
".",
"__brushOption",
".",
"panelId",
";",
"return",
"panelId",
"!=",
"null",
"?",
"panels",
"[",
"panelId",
"]",
":",
"true",
";",
"}"
] |
Return a panel or true
|
[
"Return",
"a",
"panel",
"or",
"true"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/helper/BrushController.js#L456-L465
|
train
|
apache/incubator-echarts
|
src/coord/geo/Geo.js
|
function (coord) {
var regions = this.regions;
for (var i = 0; i < regions.length; i++) {
if (regions[i].contain(coord)) {
return true;
}
}
return false;
}
|
javascript
|
function (coord) {
var regions = this.regions;
for (var i = 0; i < regions.length; i++) {
if (regions[i].contain(coord)) {
return true;
}
}
return false;
}
|
[
"function",
"(",
"coord",
")",
"{",
"var",
"regions",
"=",
"this",
".",
"regions",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"regions",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"regions",
"[",
"i",
"]",
".",
"contain",
"(",
"coord",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
If contain given lng,lat coord
@param {Array.<number>}
@readOnly
|
[
"If",
"contain",
"given",
"lng",
"lat",
"coord"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/geo/Geo.js#L82-L90
|
train
|
|
apache/incubator-echarts
|
src/chart/treemap/TreemapView.js
|
prepareAnimationWhenNoOld
|
function prepareAnimationWhenNoOld(lasts, element, storageName) {
var lastCfg = lasts[thisRawIndex] = {};
var parentNode = thisNode.parentNode;
if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
var parentOldX = 0;
var parentOldY = 0;
// New nodes appear from right-bottom corner in 'zoomToNode' animation.
// For convenience, get old bounding rect from background.
var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
if (!reRoot && parentOldBg && parentOldBg.old) {
parentOldX = parentOldBg.old.width;
parentOldY = parentOldBg.old.height;
}
// When no parent old shape found, its parent is new too,
// so we can just use {x:0, y:0}.
lastCfg.old = storageName === 'nodeGroup'
? [0, parentOldY]
: {x: parentOldX, y: parentOldY, width: 0, height: 0};
}
// Fade in, user can be aware that these nodes are new.
lastCfg.fadein = storageName !== 'nodeGroup';
}
|
javascript
|
function prepareAnimationWhenNoOld(lasts, element, storageName) {
var lastCfg = lasts[thisRawIndex] = {};
var parentNode = thisNode.parentNode;
if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
var parentOldX = 0;
var parentOldY = 0;
// New nodes appear from right-bottom corner in 'zoomToNode' animation.
// For convenience, get old bounding rect from background.
var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
if (!reRoot && parentOldBg && parentOldBg.old) {
parentOldX = parentOldBg.old.width;
parentOldY = parentOldBg.old.height;
}
// When no parent old shape found, its parent is new too,
// so we can just use {x:0, y:0}.
lastCfg.old = storageName === 'nodeGroup'
? [0, parentOldY]
: {x: parentOldX, y: parentOldY, width: 0, height: 0};
}
// Fade in, user can be aware that these nodes are new.
lastCfg.fadein = storageName !== 'nodeGroup';
}
|
[
"function",
"prepareAnimationWhenNoOld",
"(",
"lasts",
",",
"element",
",",
"storageName",
")",
"{",
"var",
"lastCfg",
"=",
"lasts",
"[",
"thisRawIndex",
"]",
"=",
"{",
"}",
";",
"var",
"parentNode",
"=",
"thisNode",
".",
"parentNode",
";",
"if",
"(",
"parentNode",
"&&",
"(",
"!",
"reRoot",
"||",
"reRoot",
".",
"direction",
"===",
"'drillDown'",
")",
")",
"{",
"var",
"parentOldX",
"=",
"0",
";",
"var",
"parentOldY",
"=",
"0",
";",
"var",
"parentOldBg",
"=",
"lastsForAnimation",
".",
"background",
"[",
"parentNode",
".",
"getRawIndex",
"(",
")",
"]",
";",
"if",
"(",
"!",
"reRoot",
"&&",
"parentOldBg",
"&&",
"parentOldBg",
".",
"old",
")",
"{",
"parentOldX",
"=",
"parentOldBg",
".",
"old",
".",
"width",
";",
"parentOldY",
"=",
"parentOldBg",
".",
"old",
".",
"height",
";",
"}",
"lastCfg",
".",
"old",
"=",
"storageName",
"===",
"'nodeGroup'",
"?",
"[",
"0",
",",
"parentOldY",
"]",
":",
"{",
"x",
":",
"parentOldX",
",",
"y",
":",
"parentOldY",
",",
"width",
":",
"0",
",",
"height",
":",
"0",
"}",
";",
"}",
"lastCfg",
".",
"fadein",
"=",
"storageName",
"!==",
"'nodeGroup'",
";",
"}"
] |
If a element is new, we need to find the animation start point carefully, otherwise it will looks strange when 'zoomToNode'.
|
[
"If",
"a",
"element",
"is",
"new",
"we",
"need",
"to",
"find",
"the",
"animation",
"start",
"point",
"carefully",
"otherwise",
"it",
"will",
"looks",
"strange",
"when",
"zoomToNode",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/TreemapView.js#L899-L924
|
train
|
apache/incubator-echarts
|
src/coord/Axis.js
|
function (dim, scale, extent) {
/**
* Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'.
* @type {string}
*/
this.dim = dim;
/**
* Axis scale
* @type {module:echarts/coord/scale/*}
*/
this.scale = scale;
/**
* @type {Array.<number>}
* @private
*/
this._extent = extent || [0, 0];
/**
* @type {boolean}
*/
this.inverse = false;
/**
* Usually true when axis has a ordinal scale
* @type {boolean}
*/
this.onBand = false;
}
|
javascript
|
function (dim, scale, extent) {
/**
* Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'.
* @type {string}
*/
this.dim = dim;
/**
* Axis scale
* @type {module:echarts/coord/scale/*}
*/
this.scale = scale;
/**
* @type {Array.<number>}
* @private
*/
this._extent = extent || [0, 0];
/**
* @type {boolean}
*/
this.inverse = false;
/**
* Usually true when axis has a ordinal scale
* @type {boolean}
*/
this.onBand = false;
}
|
[
"function",
"(",
"dim",
",",
"scale",
",",
"extent",
")",
"{",
"this",
".",
"dim",
"=",
"dim",
";",
"this",
".",
"scale",
"=",
"scale",
";",
"this",
".",
"_extent",
"=",
"extent",
"||",
"[",
"0",
",",
"0",
"]",
";",
"this",
".",
"inverse",
"=",
"false",
";",
"this",
".",
"onBand",
"=",
"false",
";",
"}"
] |
Base class of Axis.
@constructor
|
[
"Base",
"class",
"of",
"Axis",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L34-L64
|
train
|
|
apache/incubator-echarts
|
src/coord/Axis.js
|
function (coord) {
var extent = this._extent;
var min = Math.min(extent[0], extent[1]);
var max = Math.max(extent[0], extent[1]);
return coord >= min && coord <= max;
}
|
javascript
|
function (coord) {
var extent = this._extent;
var min = Math.min(extent[0], extent[1]);
var max = Math.max(extent[0], extent[1]);
return coord >= min && coord <= max;
}
|
[
"function",
"(",
"coord",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"min",
"=",
"Math",
".",
"min",
"(",
"extent",
"[",
"0",
"]",
",",
"extent",
"[",
"1",
"]",
")",
";",
"var",
"max",
"=",
"Math",
".",
"max",
"(",
"extent",
"[",
"0",
"]",
",",
"extent",
"[",
"1",
"]",
")",
";",
"return",
"coord",
">=",
"min",
"&&",
"coord",
"<=",
"max",
";",
"}"
] |
If axis extent contain given coord
@param {number} coord
@return {boolean}
|
[
"If",
"axis",
"extent",
"contain",
"given",
"coord"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L75-L80
|
train
|
|
apache/incubator-echarts
|
src/coord/Axis.js
|
function (data, clamp) {
var extent = this._extent;
var scale = this.scale;
data = scale.normalize(data);
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
return linearMap(data, NORMALIZED_EXTENT, extent, clamp);
}
|
javascript
|
function (data, clamp) {
var extent = this._extent;
var scale = this.scale;
data = scale.normalize(data);
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
return linearMap(data, NORMALIZED_EXTENT, extent, clamp);
}
|
[
"function",
"(",
"data",
",",
"clamp",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"scale",
"=",
"this",
".",
"scale",
";",
"data",
"=",
"scale",
".",
"normalize",
"(",
"data",
")",
";",
"if",
"(",
"this",
".",
"onBand",
"&&",
"scale",
".",
"type",
"===",
"'ordinal'",
")",
"{",
"extent",
"=",
"extent",
".",
"slice",
"(",
")",
";",
"fixExtentWithBands",
"(",
"extent",
",",
"scale",
".",
"count",
"(",
")",
")",
";",
"}",
"return",
"linearMap",
"(",
"data",
",",
"NORMALIZED_EXTENT",
",",
"extent",
",",
"clamp",
")",
";",
"}"
] |
Convert data to coord. Data is the rank if it has an ordinal scale
@param {number} data
@param {boolean} clamp
@return {number}
|
[
"Convert",
"data",
"to",
"coord",
".",
"Data",
"is",
"the",
"rank",
"if",
"it",
"has",
"an",
"ordinal",
"scale"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L128-L139
|
train
|
|
apache/incubator-echarts
|
src/coord/Axis.js
|
function (coord, clamp) {
var extent = this._extent;
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
return this.scale.scale(t);
}
|
javascript
|
function (coord, clamp) {
var extent = this._extent;
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
return this.scale.scale(t);
}
|
[
"function",
"(",
"coord",
",",
"clamp",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"scale",
"=",
"this",
".",
"scale",
";",
"if",
"(",
"this",
".",
"onBand",
"&&",
"scale",
".",
"type",
"===",
"'ordinal'",
")",
"{",
"extent",
"=",
"extent",
".",
"slice",
"(",
")",
";",
"fixExtentWithBands",
"(",
"extent",
",",
"scale",
".",
"count",
"(",
")",
")",
";",
"}",
"var",
"t",
"=",
"linearMap",
"(",
"coord",
",",
"extent",
",",
"NORMALIZED_EXTENT",
",",
"clamp",
")",
";",
"return",
"this",
".",
"scale",
".",
"scale",
"(",
"t",
")",
";",
"}"
] |
Convert coord to data. Data is the rank if it has an ordinal scale
@param {number} coord
@param {boolean} clamp
@return {number}
|
[
"Convert",
"coord",
"to",
"data",
".",
"Data",
"is",
"the",
"rank",
"if",
"it",
"has",
"an",
"ordinal",
"scale"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L147-L159
|
train
|
|
apache/incubator-echarts
|
src/coord/Axis.js
|
function () {
var axisExtent = this._extent;
var dataExtent = this.scale.getExtent();
var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
// Fix #2728, avoid NaN when only one data.
len === 0 && (len = 1);
var size = Math.abs(axisExtent[1] - axisExtent[0]);
return Math.abs(size) / len;
}
|
javascript
|
function () {
var axisExtent = this._extent;
var dataExtent = this.scale.getExtent();
var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
// Fix #2728, avoid NaN when only one data.
len === 0 && (len = 1);
var size = Math.abs(axisExtent[1] - axisExtent[0]);
return Math.abs(size) / len;
}
|
[
"function",
"(",
")",
"{",
"var",
"axisExtent",
"=",
"this",
".",
"_extent",
";",
"var",
"dataExtent",
"=",
"this",
".",
"scale",
".",
"getExtent",
"(",
")",
";",
"var",
"len",
"=",
"dataExtent",
"[",
"1",
"]",
"-",
"dataExtent",
"[",
"0",
"]",
"+",
"(",
"this",
".",
"onBand",
"?",
"1",
":",
"0",
")",
";",
"len",
"===",
"0",
"&&",
"(",
"len",
"=",
"1",
")",
";",
"var",
"size",
"=",
"Math",
".",
"abs",
"(",
"axisExtent",
"[",
"1",
"]",
"-",
"axisExtent",
"[",
"0",
"]",
")",
";",
"return",
"Math",
".",
"abs",
"(",
"size",
")",
"/",
"len",
";",
"}"
] |
Get width of band
@return {number}
|
[
"Get",
"width",
"of",
"band"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L242-L253
|
train
|
|
apache/incubator-echarts
|
src/component/dataZoom/roams.js
|
mergeControllerParams
|
function mergeControllerParams(dataZoomInfos) {
var controlType;
// DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated
// as string, it is probably revert to reserved word by compress tool. See #7411.
var prefix = 'type_';
var typePriority = {
'type_true': 2,
'type_move': 1,
'type_false': 0,
'type_undefined': -1
};
var preventDefaultMouseMove = true;
zrUtil.each(dataZoomInfos, function (dataZoomInfo) {
var dataZoomModel = dataZoomInfo.dataZoomModel;
var oneType = dataZoomModel.get('disabled', true)
? false
: dataZoomModel.get('zoomLock', true)
? 'move'
: true;
if (typePriority[prefix + oneType] > typePriority[prefix + controlType]) {
controlType = oneType;
}
// Prevent default move event by default. If one false, do not prevent. Otherwise
// users may be confused why it does not work when multiple insideZooms exist.
preventDefaultMouseMove &= dataZoomModel.get('preventDefaultMouseMove', true);
});
return {
controlType: controlType,
opt: {
// RoamController will enable all of these functionalities,
// and the final behavior is determined by its event listener
// provided by each inside zoom.
zoomOnMouseWheel: true,
moveOnMouseMove: true,
moveOnMouseWheel: true,
preventDefaultMouseMove: !!preventDefaultMouseMove
}
};
}
|
javascript
|
function mergeControllerParams(dataZoomInfos) {
var controlType;
// DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated
// as string, it is probably revert to reserved word by compress tool. See #7411.
var prefix = 'type_';
var typePriority = {
'type_true': 2,
'type_move': 1,
'type_false': 0,
'type_undefined': -1
};
var preventDefaultMouseMove = true;
zrUtil.each(dataZoomInfos, function (dataZoomInfo) {
var dataZoomModel = dataZoomInfo.dataZoomModel;
var oneType = dataZoomModel.get('disabled', true)
? false
: dataZoomModel.get('zoomLock', true)
? 'move'
: true;
if (typePriority[prefix + oneType] > typePriority[prefix + controlType]) {
controlType = oneType;
}
// Prevent default move event by default. If one false, do not prevent. Otherwise
// users may be confused why it does not work when multiple insideZooms exist.
preventDefaultMouseMove &= dataZoomModel.get('preventDefaultMouseMove', true);
});
return {
controlType: controlType,
opt: {
// RoamController will enable all of these functionalities,
// and the final behavior is determined by its event listener
// provided by each inside zoom.
zoomOnMouseWheel: true,
moveOnMouseMove: true,
moveOnMouseWheel: true,
preventDefaultMouseMove: !!preventDefaultMouseMove
}
};
}
|
[
"function",
"mergeControllerParams",
"(",
"dataZoomInfos",
")",
"{",
"var",
"controlType",
";",
"var",
"prefix",
"=",
"'type_'",
";",
"var",
"typePriority",
"=",
"{",
"'type_true'",
":",
"2",
",",
"'type_move'",
":",
"1",
",",
"'type_false'",
":",
"0",
",",
"'type_undefined'",
":",
"-",
"1",
"}",
";",
"var",
"preventDefaultMouseMove",
"=",
"true",
";",
"zrUtil",
".",
"each",
"(",
"dataZoomInfos",
",",
"function",
"(",
"dataZoomInfo",
")",
"{",
"var",
"dataZoomModel",
"=",
"dataZoomInfo",
".",
"dataZoomModel",
";",
"var",
"oneType",
"=",
"dataZoomModel",
".",
"get",
"(",
"'disabled'",
",",
"true",
")",
"?",
"false",
":",
"dataZoomModel",
".",
"get",
"(",
"'zoomLock'",
",",
"true",
")",
"?",
"'move'",
":",
"true",
";",
"if",
"(",
"typePriority",
"[",
"prefix",
"+",
"oneType",
"]",
">",
"typePriority",
"[",
"prefix",
"+",
"controlType",
"]",
")",
"{",
"controlType",
"=",
"oneType",
";",
"}",
"preventDefaultMouseMove",
"&=",
"dataZoomModel",
".",
"get",
"(",
"'preventDefaultMouseMove'",
",",
"true",
")",
";",
"}",
")",
";",
"return",
"{",
"controlType",
":",
"controlType",
",",
"opt",
":",
"{",
"zoomOnMouseWheel",
":",
"true",
",",
"moveOnMouseMove",
":",
"true",
",",
"moveOnMouseWheel",
":",
"true",
",",
"preventDefaultMouseMove",
":",
"!",
"!",
"preventDefaultMouseMove",
"}",
"}",
";",
"}"
] |
Merge roamController settings when multiple dataZooms share one roamController.
|
[
"Merge",
"roamController",
"settings",
"when",
"multiple",
"dataZooms",
"share",
"one",
"roamController",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/roams.js#L189-L230
|
train
|
apache/incubator-echarts
|
src/coord/polar/AngleAxis.js
|
function () {
var axis = this;
var labelModel = axis.getLabelModel();
var ordinalScale = axis.scale;
var ordinalExtent = ordinalScale.getExtent();
// Providing this method is for optimization:
// avoid generating a long array by `getTicks`
// in large category data case.
var tickCount = ordinalScale.count();
if (ordinalExtent[1] - ordinalExtent[0] < 1) {
return 0;
}
var tickValue = ordinalExtent[0];
var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
var unitH = Math.abs(unitSpan);
// Not precise, just use height as text width
// and each distance from axis line yet.
var rect = textContain.getBoundingRect(
tickValue, labelModel.getFont(), 'center', 'top'
);
var maxH = Math.max(rect.height, 7);
var dh = maxH / unitH;
// 0/0 is NaN, 1/0 is Infinity.
isNaN(dh) && (dh = Infinity);
var interval = Math.max(0, Math.floor(dh));
var cache = inner(axis.model);
var lastAutoInterval = cache.lastAutoInterval;
var lastTickCount = cache.lastTickCount;
// Use cache to keep interval stable while moving zoom window,
// otherwise the calculated interval might jitter when the zoom
// window size is close to the interval-changing size.
if (lastAutoInterval != null
&& lastTickCount != null
&& Math.abs(lastAutoInterval - interval) <= 1
&& Math.abs(lastTickCount - tickCount) <= 1
// Always choose the bigger one, otherwise the critical
// point is not the same when zooming in or zooming out.
&& lastAutoInterval > interval
) {
interval = lastAutoInterval;
}
// Only update cache if cache not used, otherwise the
// changing of interval is too insensitive.
else {
cache.lastTickCount = tickCount;
cache.lastAutoInterval = interval;
}
return interval;
}
|
javascript
|
function () {
var axis = this;
var labelModel = axis.getLabelModel();
var ordinalScale = axis.scale;
var ordinalExtent = ordinalScale.getExtent();
// Providing this method is for optimization:
// avoid generating a long array by `getTicks`
// in large category data case.
var tickCount = ordinalScale.count();
if (ordinalExtent[1] - ordinalExtent[0] < 1) {
return 0;
}
var tickValue = ordinalExtent[0];
var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
var unitH = Math.abs(unitSpan);
// Not precise, just use height as text width
// and each distance from axis line yet.
var rect = textContain.getBoundingRect(
tickValue, labelModel.getFont(), 'center', 'top'
);
var maxH = Math.max(rect.height, 7);
var dh = maxH / unitH;
// 0/0 is NaN, 1/0 is Infinity.
isNaN(dh) && (dh = Infinity);
var interval = Math.max(0, Math.floor(dh));
var cache = inner(axis.model);
var lastAutoInterval = cache.lastAutoInterval;
var lastTickCount = cache.lastTickCount;
// Use cache to keep interval stable while moving zoom window,
// otherwise the calculated interval might jitter when the zoom
// window size is close to the interval-changing size.
if (lastAutoInterval != null
&& lastTickCount != null
&& Math.abs(lastAutoInterval - interval) <= 1
&& Math.abs(lastTickCount - tickCount) <= 1
// Always choose the bigger one, otherwise the critical
// point is not the same when zooming in or zooming out.
&& lastAutoInterval > interval
) {
interval = lastAutoInterval;
}
// Only update cache if cache not used, otherwise the
// changing of interval is too insensitive.
else {
cache.lastTickCount = tickCount;
cache.lastAutoInterval = interval;
}
return interval;
}
|
[
"function",
"(",
")",
"{",
"var",
"axis",
"=",
"this",
";",
"var",
"labelModel",
"=",
"axis",
".",
"getLabelModel",
"(",
")",
";",
"var",
"ordinalScale",
"=",
"axis",
".",
"scale",
";",
"var",
"ordinalExtent",
"=",
"ordinalScale",
".",
"getExtent",
"(",
")",
";",
"var",
"tickCount",
"=",
"ordinalScale",
".",
"count",
"(",
")",
";",
"if",
"(",
"ordinalExtent",
"[",
"1",
"]",
"-",
"ordinalExtent",
"[",
"0",
"]",
"<",
"1",
")",
"{",
"return",
"0",
";",
"}",
"var",
"tickValue",
"=",
"ordinalExtent",
"[",
"0",
"]",
";",
"var",
"unitSpan",
"=",
"axis",
".",
"dataToCoord",
"(",
"tickValue",
"+",
"1",
")",
"-",
"axis",
".",
"dataToCoord",
"(",
"tickValue",
")",
";",
"var",
"unitH",
"=",
"Math",
".",
"abs",
"(",
"unitSpan",
")",
";",
"var",
"rect",
"=",
"textContain",
".",
"getBoundingRect",
"(",
"tickValue",
",",
"labelModel",
".",
"getFont",
"(",
")",
",",
"'center'",
",",
"'top'",
")",
";",
"var",
"maxH",
"=",
"Math",
".",
"max",
"(",
"rect",
".",
"height",
",",
"7",
")",
";",
"var",
"dh",
"=",
"maxH",
"/",
"unitH",
";",
"isNaN",
"(",
"dh",
")",
"&&",
"(",
"dh",
"=",
"Infinity",
")",
";",
"var",
"interval",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"floor",
"(",
"dh",
")",
")",
";",
"var",
"cache",
"=",
"inner",
"(",
"axis",
".",
"model",
")",
";",
"var",
"lastAutoInterval",
"=",
"cache",
".",
"lastAutoInterval",
";",
"var",
"lastTickCount",
"=",
"cache",
".",
"lastTickCount",
";",
"if",
"(",
"lastAutoInterval",
"!=",
"null",
"&&",
"lastTickCount",
"!=",
"null",
"&&",
"Math",
".",
"abs",
"(",
"lastAutoInterval",
"-",
"interval",
")",
"<=",
"1",
"&&",
"Math",
".",
"abs",
"(",
"lastTickCount",
"-",
"tickCount",
")",
"<=",
"1",
"&&",
"lastAutoInterval",
">",
"interval",
")",
"{",
"interval",
"=",
"lastAutoInterval",
";",
"}",
"else",
"{",
"cache",
".",
"lastTickCount",
"=",
"tickCount",
";",
"cache",
".",
"lastAutoInterval",
"=",
"interval",
";",
"}",
"return",
"interval",
";",
"}"
] |
Only be called in category axis.
Angle axis uses text height to decide interval
@override
@return {number} Auto interval for cateogry axis tick and label
|
[
"Only",
"be",
"called",
"in",
"category",
"axis",
".",
"Angle",
"axis",
"uses",
"text",
"height",
"to",
"decide",
"interval"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/AngleAxis.js#L66-L122
|
train
|
|
apache/incubator-echarts
|
src/coord/single/singleCreator.js
|
create
|
function create(ecModel, api) {
var singles = [];
ecModel.eachComponent('singleAxis', function (axisModel, idx) {
var single = new Single(axisModel, ecModel, api);
single.name = 'single_' + idx;
single.resize(axisModel, api);
axisModel.coordinateSystem = single;
singles.push(single);
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'singleAxis') {
var singleAxisModel = ecModel.queryComponents({
mainType: 'singleAxis',
index: seriesModel.get('singleAxisIndex'),
id: seriesModel.get('singleAxisId')
})[0];
seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
}
});
return singles;
}
|
javascript
|
function create(ecModel, api) {
var singles = [];
ecModel.eachComponent('singleAxis', function (axisModel, idx) {
var single = new Single(axisModel, ecModel, api);
single.name = 'single_' + idx;
single.resize(axisModel, api);
axisModel.coordinateSystem = single;
singles.push(single);
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'singleAxis') {
var singleAxisModel = ecModel.queryComponents({
mainType: 'singleAxis',
index: seriesModel.get('singleAxisIndex'),
id: seriesModel.get('singleAxisId')
})[0];
seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
}
});
return singles;
}
|
[
"function",
"create",
"(",
"ecModel",
",",
"api",
")",
"{",
"var",
"singles",
"=",
"[",
"]",
";",
"ecModel",
".",
"eachComponent",
"(",
"'singleAxis'",
",",
"function",
"(",
"axisModel",
",",
"idx",
")",
"{",
"var",
"single",
"=",
"new",
"Single",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
";",
"single",
".",
"name",
"=",
"'single_'",
"+",
"idx",
";",
"single",
".",
"resize",
"(",
"axisModel",
",",
"api",
")",
";",
"axisModel",
".",
"coordinateSystem",
"=",
"single",
";",
"singles",
".",
"push",
"(",
"single",
")",
";",
"}",
")",
";",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"if",
"(",
"seriesModel",
".",
"get",
"(",
"'coordinateSystem'",
")",
"===",
"'singleAxis'",
")",
"{",
"var",
"singleAxisModel",
"=",
"ecModel",
".",
"queryComponents",
"(",
"{",
"mainType",
":",
"'singleAxis'",
",",
"index",
":",
"seriesModel",
".",
"get",
"(",
"'singleAxisIndex'",
")",
",",
"id",
":",
"seriesModel",
".",
"get",
"(",
"'singleAxisId'",
")",
"}",
")",
"[",
"0",
"]",
";",
"seriesModel",
".",
"coordinateSystem",
"=",
"singleAxisModel",
"&&",
"singleAxisModel",
".",
"coordinateSystem",
";",
"}",
"}",
")",
";",
"return",
"singles",
";",
"}"
] |
Create single coordinate system and inject it into seriesModel.
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api
@return {Array.<module:echarts/coord/single/Single>}
|
[
"Create",
"single",
"coordinate",
"system",
"and",
"inject",
"it",
"into",
"seriesModel",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/singleCreator.js#L34-L59
|
train
|
apache/incubator-echarts
|
src/coord/single/Single.js
|
Single
|
function Single(axisModel, ecModel, api) {
/**
* @type {string}
* @readOnly
*/
this.dimension = 'single';
/**
* Add it just for draw tooltip.
*
* @type {Array.<string>}
* @readOnly
*/
this.dimensions = ['single'];
/**
* @private
* @type {module:echarts/coord/single/SingleAxis}.
*/
this._axis = null;
/**
* @private
* @type {module:zrender/core/BoundingRect}
*/
this._rect;
this._init(axisModel, ecModel, api);
/**
* @type {module:echarts/coord/single/AxisModel}
*/
this.model = axisModel;
}
|
javascript
|
function Single(axisModel, ecModel, api) {
/**
* @type {string}
* @readOnly
*/
this.dimension = 'single';
/**
* Add it just for draw tooltip.
*
* @type {Array.<string>}
* @readOnly
*/
this.dimensions = ['single'];
/**
* @private
* @type {module:echarts/coord/single/SingleAxis}.
*/
this._axis = null;
/**
* @private
* @type {module:zrender/core/BoundingRect}
*/
this._rect;
this._init(axisModel, ecModel, api);
/**
* @type {module:echarts/coord/single/AxisModel}
*/
this.model = axisModel;
}
|
[
"function",
"Single",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
"{",
"this",
".",
"dimension",
"=",
"'single'",
";",
"this",
".",
"dimensions",
"=",
"[",
"'single'",
"]",
";",
"this",
".",
"_axis",
"=",
"null",
";",
"this",
".",
"_rect",
";",
"this",
".",
"_init",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
";",
"this",
".",
"model",
"=",
"axisModel",
";",
"}"
] |
Create a single coordinates system.
@param {module:echarts/coord/single/AxisModel} axisModel
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api
|
[
"Create",
"a",
"single",
"coordinates",
"system",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L36-L70
|
train
|
apache/incubator-echarts
|
src/coord/single/Single.js
|
function (axisModel, ecModel, api) {
var dim = this.dimension;
var axis = new SingleAxis(
dim,
axisHelper.createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisModel.get('position')
);
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
axis.orient = axisModel.get('orient');
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = this;
this._axis = axis;
}
|
javascript
|
function (axisModel, ecModel, api) {
var dim = this.dimension;
var axis = new SingleAxis(
dim,
axisHelper.createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisModel.get('position')
);
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
axis.orient = axisModel.get('orient');
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = this;
this._axis = axis;
}
|
[
"function",
"(",
"axisModel",
",",
"ecModel",
",",
"api",
")",
"{",
"var",
"dim",
"=",
"this",
".",
"dimension",
";",
"var",
"axis",
"=",
"new",
"SingleAxis",
"(",
"dim",
",",
"axisHelper",
".",
"createScaleByModel",
"(",
"axisModel",
")",
",",
"[",
"0",
",",
"0",
"]",
",",
"axisModel",
".",
"get",
"(",
"'type'",
")",
",",
"axisModel",
".",
"get",
"(",
"'position'",
")",
")",
";",
"var",
"isCategory",
"=",
"axis",
".",
"type",
"===",
"'category'",
";",
"axis",
".",
"onBand",
"=",
"isCategory",
"&&",
"axisModel",
".",
"get",
"(",
"'boundaryGap'",
")",
";",
"axis",
".",
"inverse",
"=",
"axisModel",
".",
"get",
"(",
"'inverse'",
")",
";",
"axis",
".",
"orient",
"=",
"axisModel",
".",
"get",
"(",
"'orient'",
")",
";",
"axisModel",
".",
"axis",
"=",
"axis",
";",
"axis",
".",
"model",
"=",
"axisModel",
";",
"axis",
".",
"coordinateSystem",
"=",
"this",
";",
"this",
".",
"_axis",
"=",
"axis",
";",
"}"
] |
Initialize single coordinate system.
@param {module:echarts/coord/single/AxisModel} axisModel
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api
@private
|
[
"Initialize",
"single",
"coordinate",
"system",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L88-L109
|
train
|
|
apache/incubator-echarts
|
src/coord/single/Single.js
|
function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data = seriesModel.getData();
each(data.mapDimension(this.dimension, true), function (dim) {
this._axis.scale.unionExtentFromData(data, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
}
|
javascript
|
function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data = seriesModel.getData();
each(data.mapDimension(this.dimension, true), function (dim) {
this._axis.scale.unionExtentFromData(data, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
}
|
[
"function",
"(",
"ecModel",
",",
"api",
")",
"{",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"if",
"(",
"seriesModel",
".",
"coordinateSystem",
"===",
"this",
")",
"{",
"var",
"data",
"=",
"seriesModel",
".",
"getData",
"(",
")",
";",
"each",
"(",
"data",
".",
"mapDimension",
"(",
"this",
".",
"dimension",
",",
"true",
")",
",",
"function",
"(",
"dim",
")",
"{",
"this",
".",
"_axis",
".",
"scale",
".",
"unionExtentFromData",
"(",
"data",
",",
"dim",
")",
";",
"}",
",",
"this",
")",
";",
"axisHelper",
".",
"niceScaleExtent",
"(",
"this",
".",
"_axis",
".",
"scale",
",",
"this",
".",
"_axis",
".",
"model",
")",
";",
"}",
"}",
",",
"this",
")",
";",
"}"
] |
Update axis scale after data processed
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api
|
[
"Update",
"axis",
"scale",
"after",
"data",
"processed"
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L116-L126
|
train
|
|
apache/incubator-echarts
|
src/coord/single/Single.js
|
function (axisModel, api) {
this._rect = getLayoutRect(
{
left: axisModel.get('left'),
top: axisModel.get('top'),
right: axisModel.get('right'),
bottom: axisModel.get('bottom'),
width: axisModel.get('width'),
height: axisModel.get('height')
},
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._adjustAxis();
}
|
javascript
|
function (axisModel, api) {
this._rect = getLayoutRect(
{
left: axisModel.get('left'),
top: axisModel.get('top'),
right: axisModel.get('right'),
bottom: axisModel.get('bottom'),
width: axisModel.get('width'),
height: axisModel.get('height')
},
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._adjustAxis();
}
|
[
"function",
"(",
"axisModel",
",",
"api",
")",
"{",
"this",
".",
"_rect",
"=",
"getLayoutRect",
"(",
"{",
"left",
":",
"axisModel",
".",
"get",
"(",
"'left'",
")",
",",
"top",
":",
"axisModel",
".",
"get",
"(",
"'top'",
")",
",",
"right",
":",
"axisModel",
".",
"get",
"(",
"'right'",
")",
",",
"bottom",
":",
"axisModel",
".",
"get",
"(",
"'bottom'",
")",
",",
"width",
":",
"axisModel",
".",
"get",
"(",
"'width'",
")",
",",
"height",
":",
"axisModel",
".",
"get",
"(",
"'height'",
")",
"}",
",",
"{",
"width",
":",
"api",
".",
"getWidth",
"(",
")",
",",
"height",
":",
"api",
".",
"getHeight",
"(",
")",
"}",
")",
";",
"this",
".",
"_adjustAxis",
"(",
")",
";",
"}"
] |
Resize the single coordinate system.
@param {module:echarts/coord/single/AxisModel} axisModel
@param {module:echarts/ExtensionAPI} api
|
[
"Resize",
"the",
"single",
"coordinate",
"system",
"."
] |
4d0ea095dc3929cb6de40c45748826e7999c7aa8
|
https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L134-L151
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.