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
spite/ccapture.js
src/webm-writer-0.2.0.js
rewriteDuration
function rewriteDuration() { var buffer = new ArrayBufferDataStream(8), oldPos = blobBuffer.pos; // Rewrite the data payload (don't need to update the id or size) buffer.writeDoubleBE(clusterStartTime); ...
javascript
function rewriteDuration() { var buffer = new ArrayBufferDataStream(8), oldPos = blobBuffer.pos; // Rewrite the data payload (don't need to update the id or size) buffer.writeDoubleBE(clusterStartTime); ...
[ "function", "rewriteDuration", "(", ")", "{", "var", "buffer", "=", "new", "ArrayBufferDataStream", "(", "8", ")", ",", "oldPos", "=", "blobBuffer", ".", "pos", ";", "// Rewrite the data payload (don't need to update the id or size)", "buffer", ".", "writeDoubleBE", "...
Rewrite the Duration field of the Segment with the newly-discovered video duration.
[ "Rewrite", "the", "Duration", "field", "of", "the", "Segment", "with", "the", "newly", "-", "discovered", "video", "duration", "." ]
e4bc8fccc1e10d69b79b1c02fd13f3c448a3fb41
https://github.com/spite/ccapture.js/blob/e4bc8fccc1e10d69b79b1c02fd13f3c448a3fb41/src/webm-writer-0.2.0.js#L1023-L1036
train
apache/cordova-plugin-file-transfer
src/windows/FileTransferProxy.js
cordovaPathToNative
function cordovaPathToNative(path) { var cleanPath = String(path); // turn / into \\ cleanPath = cleanPath.replace(/\//g, '\\'); // turn \\ into \ cleanPath = cleanPath.replace(/\\\\/g, '\\'); // strip end \\ characters cleanPath = cleanPath.replace(/\\+$/g, ''); return cleanPath; }
javascript
function cordovaPathToNative(path) { var cleanPath = String(path); // turn / into \\ cleanPath = cleanPath.replace(/\//g, '\\'); // turn \\ into \ cleanPath = cleanPath.replace(/\\\\/g, '\\'); // strip end \\ characters cleanPath = cleanPath.replace(/\\+$/g, ''); return cleanPath; }
[ "function", "cordovaPathToNative", "(", "path", ")", "{", "var", "cleanPath", "=", "String", "(", "path", ")", ";", "// turn / into \\\\", "cleanPath", "=", "cleanPath", ".", "replace", "(", "/", "\\/", "/", "g", ",", "'\\\\'", ")", ";", "// turn \\\\ into ...
Some private helper functions, hidden by the module
[ "Some", "private", "helper", "functions", "hidden", "by", "the", "module" ]
dc8fbd78a234bd88450ebe01835c60371bc2cf8e
https://github.com/apache/cordova-plugin-file-transfer/blob/dc8fbd78a234bd88450ebe01835c60371bc2cf8e/src/windows/FileTransferProxy.js#L40-L50
train
eventbrite/britecharts
src/charts/mini-tooltip.js
getMaxLengthLine
function getMaxLengthLine(...texts) { let textSizes = texts.filter(x => !!x) .map(x => x.node().getBBox().width); return d3Array.max(textSizes); }
javascript
function getMaxLengthLine(...texts) { let textSizes = texts.filter(x => !!x) .map(x => x.node().getBBox().width); return d3Array.max(textSizes); }
[ "function", "getMaxLengthLine", "(", "...", "texts", ")", "{", "let", "textSizes", "=", "texts", ".", "filter", "(", "x", "=>", "!", "!", "x", ")", ".", "map", "(", "x", "=>", "x", ".", "node", "(", ")", ".", "getBBox", "(", ")", ".", "width", ...
Figures out the max length of the tooltip lines @param {D3Selection[]} texts List of svg elements of each line @return {Number} Max size of the lines
[ "Figures", "out", "the", "max", "length", "of", "the", "tooltip", "lines" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/mini-tooltip.js#L176-L181
train
eventbrite/britecharts
src/charts/mini-tooltip.js
updatePositionAndSize
function updatePositionAndSize(mousePosition, parentChartSize) { let [tooltipX, tooltipY] = getTooltipPosition(mousePosition, parentChartSize); svg.transition() .duration(mouseChaseDuration) .ease(ease) .attr('height', chartHeight + margin.top + m...
javascript
function updatePositionAndSize(mousePosition, parentChartSize) { let [tooltipX, tooltipY] = getTooltipPosition(mousePosition, parentChartSize); svg.transition() .duration(mouseChaseDuration) .ease(ease) .attr('height', chartHeight + margin.top + m...
[ "function", "updatePositionAndSize", "(", "mousePosition", ",", "parentChartSize", ")", "{", "let", "[", "tooltipX", ",", "tooltipY", "]", "=", "getTooltipPosition", "(", "mousePosition", ",", "parentChartSize", ")", ";", "svg", ".", "transition", "(", ")", ".",...
Updates size and position of tooltip depending on the side of the chart we are in @param {Object} dataPoint DataPoint of the tooltip @return void
[ "Updates", "size", "and", "position", "of", "tooltip", "depending", "on", "the", "side", "of", "the", "chart", "we", "are", "in" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/mini-tooltip.js#L316-L329
train
eventbrite/britecharts
src/charts/step.js
cleanData
function cleanData(originalData) { return originalData.reduce((acc, d) => { d.value = +d[valueLabel]; d.key = String(d[nameLabel]); return [...acc, d]; }, []); }
javascript
function cleanData(originalData) { return originalData.reduce((acc, d) => { d.value = +d[valueLabel]; d.key = String(d[nameLabel]); return [...acc, d]; }, []); }
[ "function", "cleanData", "(", "originalData", ")", "{", "return", "originalData", ".", "reduce", "(", "(", "acc", ",", "d", ")", "=>", "{", "d", ".", "value", "=", "+", "d", "[", "valueLabel", "]", ";", "d", ".", "key", "=", "String", "(", "d", "...
Cleaning data casting the values and keys to the proper type while keeping the rest of properties on the data @param {StepChartData} originalData Data as provided on the container @private
[ "Cleaning", "data", "casting", "the", "values", "and", "keys", "to", "the", "proper", "type", "while", "keeping", "the", "rest", "of", "properties", "on", "the", "data" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/step.js#L215-L222
train
eventbrite/britecharts
src/charts/step.js
drawSteps
function drawSteps(){ let steps = svg.select('.chart-group').selectAll('.step').data(data); // Enter steps.enter() .append('rect') .classed('step', true) .attr('x', chartWidth) // Initially drawing the steps at the end of Y axis ...
javascript
function drawSteps(){ let steps = svg.select('.chart-group').selectAll('.step').data(data); // Enter steps.enter() .append('rect') .classed('step', true) .attr('x', chartWidth) // Initially drawing the steps at the end of Y axis ...
[ "function", "drawSteps", "(", ")", "{", "let", "steps", "=", "svg", ".", "select", "(", "'.chart-group'", ")", ".", "selectAll", "(", "'.step'", ")", ".", "data", "(", "data", ")", ";", "// Enter", "steps", ".", "enter", "(", ")", ".", "append", "(",...
Draws the step elements within the chart group @private
[ "Draws", "the", "step", "elements", "within", "the", "chart", "group" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/step.js#L273-L310
train
eventbrite/britecharts
src/charts/brush.js
buildAxis
function buildAxis(){ let minor, major; if (xAxisFormat === 'custom' && typeof xAxisCustomFormat === 'string') { minor = { tick: xTicks, format: d3TimeFormat.timeFormat(xAxisCustomFormat) }; } else { ...
javascript
function buildAxis(){ let minor, major; if (xAxisFormat === 'custom' && typeof xAxisCustomFormat === 'string') { minor = { tick: xTicks, format: d3TimeFormat.timeFormat(xAxisCustomFormat) }; } else { ...
[ "function", "buildAxis", "(", ")", "{", "let", "minor", ",", "major", ";", "if", "(", "xAxisFormat", "===", "'custom'", "&&", "typeof", "xAxisCustomFormat", "===", "'string'", ")", "{", "minor", "=", "{", "tick", ":", "xTicks", ",", "format", ":", "d3Tim...
Creates the d3 x axis, setting orientation @private
[ "Creates", "the", "d3", "x", "axis", "setting", "orientation" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L154-L171
train
eventbrite/britecharts
src/charts/brush.js
buildBrush
function buildBrush() { brush = d3Brush.brushX() .extent([[0, 0], [chartWidth, chartHeight]]) .on('brush', handleBrushStart) .on('end', handleBrushEnd); }
javascript
function buildBrush() { brush = d3Brush.brushX() .extent([[0, 0], [chartWidth, chartHeight]]) .on('brush', handleBrushStart) .on('end', handleBrushEnd); }
[ "function", "buildBrush", "(", ")", "{", "brush", "=", "d3Brush", ".", "brushX", "(", ")", ".", "extent", "(", "[", "[", "0", ",", "0", "]", ",", "[", "chartWidth", ",", "chartHeight", "]", "]", ")", ".", "on", "(", "'brush'", ",", "handleBrushStar...
Creates the brush element and attaches a listener @return {void}
[ "Creates", "the", "brush", "element", "and", "attaches", "a", "listener" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L177-L182
train
eventbrite/britecharts
src/charts/brush.js
buildGradient
function buildGradient() { if (!chartGradientEl) { chartGradientEl = svg.select('.metadata-group') .append('linearGradient') .attr('id', gradientId) .attr('gradientUnits', 'userSpaceOnUse') .attr('x1', 0) ...
javascript
function buildGradient() { if (!chartGradientEl) { chartGradientEl = svg.select('.metadata-group') .append('linearGradient') .attr('id', gradientId) .attr('gradientUnits', 'userSpaceOnUse') .attr('x1', 0) ...
[ "function", "buildGradient", "(", ")", "{", "if", "(", "!", "chartGradientEl", ")", "{", "chartGradientEl", "=", "svg", ".", "select", "(", "'.metadata-group'", ")", ".", "append", "(", "'linearGradient'", ")", ".", "attr", "(", "'id'", ",", "gradientId", ...
Creates the gradient on the area @return {void}
[ "Creates", "the", "gradient", "on", "the", "area" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L215-L234
train
eventbrite/britecharts
src/charts/brush.js
drawArea
function drawArea() { if (brushArea) { svg.selectAll('.brush-area').remove(); } // Create and configure the area generator brushArea = d3Shape.area() .x(({date}) => xScale(date)) .y0(chartHeight) .y1(({value...
javascript
function drawArea() { if (brushArea) { svg.selectAll('.brush-area').remove(); } // Create and configure the area generator brushArea = d3Shape.area() .x(({date}) => xScale(date)) .y0(chartHeight) .y1(({value...
[ "function", "drawArea", "(", ")", "{", "if", "(", "brushArea", ")", "{", "svg", ".", "selectAll", "(", "'.brush-area'", ")", ".", "remove", "(", ")", ";", "}", "// Create and configure the area generator", "brushArea", "=", "d3Shape", ".", "area", "(", ")", ...
Draws the area that is going to represent the data @return {void}
[ "Draws", "the", "area", "that", "is", "going", "to", "represent", "the", "data" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L310-L328
train
eventbrite/britecharts
src/charts/brush.js
drawBrush
function drawBrush() { chartBrush = svg.select('.brush-group') .call(brush); // Update the height of the brushing rectangle chartBrush.selectAll('rect') .classed('brush-rect', true) .attr('height', chartHeight); ...
javascript
function drawBrush() { chartBrush = svg.select('.brush-group') .call(brush); // Update the height of the brushing rectangle chartBrush.selectAll('rect') .classed('brush-rect', true) .attr('height', chartHeight); ...
[ "function", "drawBrush", "(", ")", "{", "chartBrush", "=", "svg", ".", "select", "(", "'.brush-group'", ")", ".", "call", "(", "brush", ")", ";", "// Update the height of the brushing rectangle", "chartBrush", ".", "selectAll", "(", "'rect'", ")", ".", "classed"...
Draws the Brush components on its group @return {void}
[ "Draws", "the", "Brush", "components", "on", "its", "group" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L334-L345
train
eventbrite/britecharts
src/charts/brush.js
drawHandles
function drawHandles() { let handleFillColor = colorHelper.colorSchemasHuman.grey[1]; // Styling handle = chartBrush .selectAll('.handle.brush-rect') .style('fill', handleFillColor); }
javascript
function drawHandles() { let handleFillColor = colorHelper.colorSchemasHuman.grey[1]; // Styling handle = chartBrush .selectAll('.handle.brush-rect') .style('fill', handleFillColor); }
[ "function", "drawHandles", "(", ")", "{", "let", "handleFillColor", "=", "colorHelper", ".", "colorSchemasHuman", ".", "grey", "[", "1", "]", ";", "// Styling", "handle", "=", "chartBrush", ".", "selectAll", "(", "'.handle.brush-rect'", ")", ".", "style", "(",...
Draws a handle for the Brush section @return {void}
[ "Draws", "a", "handle", "for", "the", "Brush", "section" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L351-L358
train
eventbrite/britecharts
src/charts/brush.js
handleBrushStart
function handleBrushStart() { const selection = d3Selection.event.selection; if (!selection) { return; } dispatcher.call('customBrushStart', this, selection.map(xScale.invert)); }
javascript
function handleBrushStart() { const selection = d3Selection.event.selection; if (!selection) { return; } dispatcher.call('customBrushStart', this, selection.map(xScale.invert)); }
[ "function", "handleBrushStart", "(", ")", "{", "const", "selection", "=", "d3Selection", ".", "event", ".", "selection", ";", "if", "(", "!", "selection", ")", "{", "return", ";", "}", "dispatcher", ".", "call", "(", "'customBrushStart'", ",", "this", ",",...
When a brush event starts, we can extract info from the extension of the brush. @return {void}
[ "When", "a", "brush", "event", "starts", "we", "can", "extract", "info", "from", "the", "extension", "of", "the", "brush", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L366-L374
train
eventbrite/britecharts
src/charts/brush.js
setBrushByDates
function setBrushByDates(dateA, dateB) { let selection = null; if (dateA !== null) { selection = [ xScale(new Date(dateA)), xScale(new Date(dateB)) ]; } brush.move(chartBrush, selection); }
javascript
function setBrushByDates(dateA, dateB) { let selection = null; if (dateA !== null) { selection = [ xScale(new Date(dateA)), xScale(new Date(dateB)) ]; } brush.move(chartBrush, selection); }
[ "function", "setBrushByDates", "(", "dateA", ",", "dateB", ")", "{", "let", "selection", "=", "null", ";", "if", "(", "dateA", "!==", "null", ")", "{", "selection", "=", "[", "xScale", "(", "new", "Date", "(", "dateA", ")", ")", ",", "xScale", "(", ...
Sets a new brush extent within the passed dates @param {String | Date} dateA Initial Date @param {String | Date} dateB End Date
[ "Sets", "a", "new", "brush", "extent", "within", "the", "passed", "dates" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/brush.js#L414-L425
train
eventbrite/britecharts
src/charts/sparkline.js
createGradients
function createGradients() { let metadataGroup = svg.select('.metadata-group'); if (areaGradientEl || lineGradientEl) { svg.selectAll(`#${areaGradientId}`).remove(); svg.selectAll(`#${lineGradientId}`).remove(); } areaGradientEl = metadat...
javascript
function createGradients() { let metadataGroup = svg.select('.metadata-group'); if (areaGradientEl || lineGradientEl) { svg.selectAll(`#${areaGradientId}`).remove(); svg.selectAll(`#${lineGradientId}`).remove(); } areaGradientEl = metadat...
[ "function", "createGradients", "(", ")", "{", "let", "metadataGroup", "=", "svg", ".", "select", "(", "'.metadata-group'", ")", ";", "if", "(", "areaGradientEl", "||", "lineGradientEl", ")", "{", "svg", ".", "selectAll", "(", "`", "${", "areaGradientId", "}"...
Creates the gradient on the area below the line @return {void}
[ "Creates", "the", "gradient", "on", "the", "area", "below", "the", "line" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/sparkline.js#L215-L256
train
eventbrite/britecharts
src/charts/sparkline.js
drawArea
function drawArea(){ if (area) { svg.selectAll('.sparkline-area').remove(); } area = d3Shape.area() .x(({date}) => xScale(date)) .y0(() => yScale(0) + lineStrokeWidth / 2) .y1(({value}) => yScale(value)) ...
javascript
function drawArea(){ if (area) { svg.selectAll('.sparkline-area').remove(); } area = d3Shape.area() .x(({date}) => xScale(date)) .y0(() => yScale(0) + lineStrokeWidth / 2) .y1(({value}) => yScale(value)) ...
[ "function", "drawArea", "(", ")", "{", "if", "(", "area", ")", "{", "svg", ".", "selectAll", "(", "'.sparkline-area'", ")", ".", "remove", "(", ")", ";", "}", "area", "=", "d3Shape", ".", "area", "(", ")", ".", "x", "(", "(", "{", "date", "}", ...
Draws the area that will be placed below the line @private
[ "Draws", "the", "area", "that", "will", "be", "placed", "below", "the", "line" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/sparkline.js#L290-L308
train
eventbrite/britecharts
src/charts/sparkline.js
drawLine
function drawLine(){ if (topLine) { svg.selectAll('.line').remove(); } topLine = d3Shape.line() .curve(d3Shape.curveBasis) .x(({date}) => xScale(date)) .y(({value}) => yScale(value)); svg.select('.chart-gro...
javascript
function drawLine(){ if (topLine) { svg.selectAll('.line').remove(); } topLine = d3Shape.line() .curve(d3Shape.curveBasis) .x(({date}) => xScale(date)) .y(({value}) => yScale(value)); svg.select('.chart-gro...
[ "function", "drawLine", "(", ")", "{", "if", "(", "topLine", ")", "{", "svg", ".", "selectAll", "(", "'.line'", ")", ".", "remove", "(", ")", ";", "}", "topLine", "=", "d3Shape", ".", "line", "(", ")", ".", "curve", "(", "d3Shape", ".", "curveBasis...
Draws the line element within the chart group @private
[ "Draws", "the", "line", "element", "within", "the", "chart", "group" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/sparkline.js#L314-L331
train
eventbrite/britecharts
src/charts/sparkline.js
drawSparklineTitle
function drawSparklineTitle() { if (titleEl) { svg.selectAll('.sparkline-text').remove(); } titleEl = svg.selectAll('.text-group') .append('text') .attr('x', chartWidth / 2) .attr('y', chartHeight / 6) .at...
javascript
function drawSparklineTitle() { if (titleEl) { svg.selectAll('.sparkline-text').remove(); } titleEl = svg.selectAll('.text-group') .append('text') .attr('x', chartWidth / 2) .attr('y', chartHeight / 6) .at...
[ "function", "drawSparklineTitle", "(", ")", "{", "if", "(", "titleEl", ")", "{", "svg", ".", "selectAll", "(", "'.sparkline-text'", ")", ".", "remove", "(", ")", ";", "}", "titleEl", "=", "svg", ".", "selectAll", "(", "'.text-group'", ")", ".", "append",...
Draws the text element within the text group Is displayed at the top of sparked area @private
[ "Draws", "the", "text", "element", "within", "the", "text", "group", "Is", "displayed", "at", "the", "top", "of", "sparked", "area" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/sparkline.js#L338-L355
train
eventbrite/britecharts
src/charts/sparkline.js
drawEndMarker
function drawEndMarker(){ if (circle) { svg.selectAll('.sparkline-circle').remove(); } circle = svg.selectAll('.chart-group') .append('circle') .attr('class', 'sparkline-circle') .attr('cx', xScale(data[data.length - 1].d...
javascript
function drawEndMarker(){ if (circle) { svg.selectAll('.sparkline-circle').remove(); } circle = svg.selectAll('.chart-group') .append('circle') .attr('class', 'sparkline-circle') .attr('cx', xScale(data[data.length - 1].d...
[ "function", "drawEndMarker", "(", ")", "{", "if", "(", "circle", ")", "{", "svg", ".", "selectAll", "(", "'.sparkline-circle'", ")", ".", "remove", "(", ")", ";", "}", "circle", "=", "svg", ".", "selectAll", "(", "'.chart-group'", ")", ".", "append", "...
Draws a marker at the end of the sparkline
[ "Draws", "a", "marker", "at", "the", "end", "of", "the", "sparkline" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/sparkline.js#L360-L371
train
eventbrite/britecharts
sandbox/sandbox.js
main
function main() { loadDependencies(); setInitialData(); domHelpers.initDomElements(); setDataInInputField(); setConfigInInputField(); setChartSelectorType(); setNewChart(); setHandlers(); }
javascript
function main() { loadDependencies(); setInitialData(); domHelpers.initDomElements(); setDataInInputField(); setConfigInInputField(); setChartSelectorType(); setNewChart(); setHandlers(); }
[ "function", "main", "(", ")", "{", "loadDependencies", "(", ")", ";", "setInitialData", "(", ")", ";", "domHelpers", ".", "initDomElements", "(", ")", ";", "setDataInInputField", "(", ")", ";", "setConfigInInputField", "(", ")", ";", "setChartSelectorType", "(...
Main function to run the sandbox
[ "Main", "function", "to", "run", "the", "sandbox" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L75-L85
train
eventbrite/britecharts
sandbox/sandbox.js
setHandlers
function setHandlers() { d3.select(`.${chartSelectorClass}`).on('change', _handleChartSelectorChange); d3.select(`.${dataSelectorClass}`).on('change', _handleDataSelectorChange); d3.select(`.${dataSubmitButtonClass}`).on('click', _handleDataUpdate); d3.select(`.${dataResetButtonClass}`).on('click', _ha...
javascript
function setHandlers() { d3.select(`.${chartSelectorClass}`).on('change', _handleChartSelectorChange); d3.select(`.${dataSelectorClass}`).on('change', _handleDataSelectorChange); d3.select(`.${dataSubmitButtonClass}`).on('click', _handleDataUpdate); d3.select(`.${dataResetButtonClass}`).on('click', _ha...
[ "function", "setHandlers", "(", ")", "{", "d3", ".", "select", "(", "`", "${", "chartSelectorClass", "}", "`", ")", ".", "on", "(", "'change'", ",", "_handleChartSelectorChange", ")", ";", "d3", ".", "select", "(", "`", "${", "dataSelectorClass", "}", "`...
Sets handlers on all of our input fields on the sandbox dom
[ "Sets", "handlers", "on", "all", "of", "our", "input", "fields", "on", "the", "sandbox", "dom" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L98-L111
train
eventbrite/britecharts
sandbox/sandbox.js
setNewDataTypes
function setNewDataTypes() { let chartType = getCurrentType(); let dataTypes = Object.keys(defaultData[chartType]); let dataSelector = d3.select(`.${dataSelectorClass}`) .selectAll('option') .data(dataTypes); dataSelector.enter().append('option') .merge(dataSelector) ...
javascript
function setNewDataTypes() { let chartType = getCurrentType(); let dataTypes = Object.keys(defaultData[chartType]); let dataSelector = d3.select(`.${dataSelectorClass}`) .selectAll('option') .data(dataTypes); dataSelector.enter().append('option') .merge(dataSelector) ...
[ "function", "setNewDataTypes", "(", ")", "{", "let", "chartType", "=", "getCurrentType", "(", ")", ";", "let", "dataTypes", "=", "Object", ".", "keys", "(", "defaultData", "[", "chartType", "]", ")", ";", "let", "dataSelector", "=", "d3", ".", "select", ...
Reads from the constants file to fill the data type selelctor with the data types of that chart
[ "Reads", "from", "the", "constants", "file", "to", "fill", "the", "data", "type", "selelctor", "with", "the", "data", "types", "of", "that", "chart" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L176-L190
train
eventbrite/britecharts
sandbox/sandbox.js
getCurrentData
function getCurrentData() { let currentData = storage.getDataByKey(savedDataKey); if (!currentData) { let chartType = getCurrentType(); let {initialDataType} = defaultConfig[chartType]; currentData = defaultData[chartType][initialDataType]; storage.setDataByKey(savedDataKey, c...
javascript
function getCurrentData() { let currentData = storage.getDataByKey(savedDataKey); if (!currentData) { let chartType = getCurrentType(); let {initialDataType} = defaultConfig[chartType]; currentData = defaultData[chartType][initialDataType]; storage.setDataByKey(savedDataKey, c...
[ "function", "getCurrentData", "(", ")", "{", "let", "currentData", "=", "storage", ".", "getDataByKey", "(", "savedDataKey", ")", ";", "if", "(", "!", "currentData", ")", "{", "let", "chartType", "=", "getCurrentType", "(", ")", ";", "let", "{", "initialDa...
Gets the current data either from the store or from the data file. If no data is found on the store, one is set from the data file. @return {Object} Data object [data is parsed before it is set]
[ "Gets", "the", "current", "data", "either", "from", "the", "store", "or", "from", "the", "data", "file", ".", "If", "no", "data", "is", "found", "on", "the", "store", "one", "is", "set", "from", "the", "data", "file", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L197-L210
train
eventbrite/britecharts
sandbox/sandbox.js
getCurrentConfig
function getCurrentConfig() { let initString = storage.getDataByKey(savedConfigKey); if (!initString) { let chartType = getCurrentType(); let {chartConfig} = defaultConfig[chartType]; initString = formatParamsIntoChartInitString(chartConfig); storage.setDataByKey(savedConfigKe...
javascript
function getCurrentConfig() { let initString = storage.getDataByKey(savedConfigKey); if (!initString) { let chartType = getCurrentType(); let {chartConfig} = defaultConfig[chartType]; initString = formatParamsIntoChartInitString(chartConfig); storage.setDataByKey(savedConfigKe...
[ "function", "getCurrentConfig", "(", ")", "{", "let", "initString", "=", "storage", ".", "getDataByKey", "(", "savedConfigKey", ")", ";", "if", "(", "!", "initString", ")", "{", "let", "chartType", "=", "getCurrentType", "(", ")", ";", "let", "{", "chartCo...
Gets teh current chart configuration either from the store or from the constants file. If no configuraiton is found on the store, one is set from the constants. @return {String} config string
[ "Gets", "teh", "current", "chart", "configuration", "either", "from", "the", "store", "or", "from", "the", "constants", "file", ".", "If", "no", "configuraiton", "is", "found", "on", "the", "store", "one", "is", "set", "from", "the", "constants", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L217-L230
train
eventbrite/britecharts
sandbox/sandbox.js
getCurrentType
function getCurrentType() { let currentType = storage.getDataByKey(savedChartTypeKey); if (!currentType) { currentType = charts[0]; storage.setDataByKey(savedChartTypeKey, currentType); } return currentType; }
javascript
function getCurrentType() { let currentType = storage.getDataByKey(savedChartTypeKey); if (!currentType) { currentType = charts[0]; storage.setDataByKey(savedChartTypeKey, currentType); } return currentType; }
[ "function", "getCurrentType", "(", ")", "{", "let", "currentType", "=", "storage", ".", "getDataByKey", "(", "savedChartTypeKey", ")", ";", "if", "(", "!", "currentType", ")", "{", "currentType", "=", "charts", "[", "0", "]", ";", "storage", ".", "setDataB...
Gets the current chart type either from the store or from the constants file If no chart type is found in the store, one is set from the constants. @return {String} chart type
[ "Gets", "the", "current", "chart", "type", "either", "from", "the", "store", "or", "from", "the", "constants", "file", "If", "no", "chart", "type", "is", "found", "in", "the", "store", "one", "is", "set", "from", "the", "constants", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L237-L246
train
eventbrite/britecharts
sandbox/sandbox.js
_handleAddTooltip
function _handleAddTooltip(tooltipType) { let initString = getCurrentConfig(); let tooltipInitString = tooltipConfigs[tooltipType].initString; initString = initString.concat(tooltipInitString); configEditor.setValue(prettifyInitString(initString)); setNewChart(); }
javascript
function _handleAddTooltip(tooltipType) { let initString = getCurrentConfig(); let tooltipInitString = tooltipConfigs[tooltipType].initString; initString = initString.concat(tooltipInitString); configEditor.setValue(prettifyInitString(initString)); setNewChart(); }
[ "function", "_handleAddTooltip", "(", "tooltipType", ")", "{", "let", "initString", "=", "getCurrentConfig", "(", ")", ";", "let", "tooltipInitString", "=", "tooltipConfigs", "[", "tooltipType", "]", ".", "initString", ";", "initString", "=", "initString", ".", ...
Adds tooltip code to the editor @param {string} tooltipType Constant from constant file
[ "Adds", "tooltip", "code", "to", "the", "editor" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L252-L258
train
eventbrite/britecharts
sandbox/sandbox.js
_handleDataSelectorChange
function _handleDataSelectorChange () { let chartType = getCurrentType(); let dataType = d3.select(`.${dataSelectorClass}`).property('value'); let currentData = defaultData[chartType][dataType]; storage.setDataByKey(savedDataKey, currentData); updateAllComponents(); }
javascript
function _handleDataSelectorChange () { let chartType = getCurrentType(); let dataType = d3.select(`.${dataSelectorClass}`).property('value'); let currentData = defaultData[chartType][dataType]; storage.setDataByKey(savedDataKey, currentData); updateAllComponents(); }
[ "function", "_handleDataSelectorChange", "(", ")", "{", "let", "chartType", "=", "getCurrentType", "(", ")", ";", "let", "dataType", "=", "d3", ".", "select", "(", "`", "${", "dataSelectorClass", "}", "`", ")", ".", "property", "(", "'value'", ")", ";", ...
Handles data selection change, updates the data on the store and then updates all components
[ "Handles", "data", "selection", "change", "updates", "the", "data", "on", "the", "store", "and", "then", "updates", "all", "components" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L263-L270
train
eventbrite/britecharts
sandbox/sandbox.js
_handleDataUpdate
function _handleDataUpdate() { const rawData = dataEditor.getValue(); let freshData = null; try { freshData = evalDataString(rawData); } catch(e) { errors.push(new Error('Could not parse the data from the input field', rawData)); } storage.setDataByKey(savedDataKey, freshData);...
javascript
function _handleDataUpdate() { const rawData = dataEditor.getValue(); let freshData = null; try { freshData = evalDataString(rawData); } catch(e) { errors.push(new Error('Could not parse the data from the input field', rawData)); } storage.setDataByKey(savedDataKey, freshData);...
[ "function", "_handleDataUpdate", "(", ")", "{", "const", "rawData", "=", "dataEditor", ".", "getValue", "(", ")", ";", "let", "freshData", "=", "null", ";", "try", "{", "freshData", "=", "evalDataString", "(", "rawData", ")", ";", "}", "catch", "(", "e",...
Updates the data for the chart on the store, then sets a new chart so the new data is displayed @return {[type]} [description]
[ "Updates", "the", "data", "for", "the", "chart", "on", "the", "store", "then", "sets", "a", "new", "chart", "so", "the", "new", "data", "is", "displayed" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L288-L303
train
eventbrite/britecharts
sandbox/sandbox.js
_handleDataReset
function _handleDataReset() { storage.removeDataByKey(savedDataKey); let data = getCurrentData(); dataEditor.setValue(prettifyJson(data)); }
javascript
function _handleDataReset() { storage.removeDataByKey(savedDataKey); let data = getCurrentData(); dataEditor.setValue(prettifyJson(data)); }
[ "function", "_handleDataReset", "(", ")", "{", "storage", ".", "removeDataByKey", "(", "savedDataKey", ")", ";", "let", "data", "=", "getCurrentData", "(", ")", ";", "dataEditor", ".", "setValue", "(", "prettifyJson", "(", "data", ")", ")", ";", "}" ]
Resets the data to its default state
[ "Resets", "the", "data", "to", "its", "default", "state" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L308-L314
train
eventbrite/britecharts
sandbox/sandbox.js
_handleConfigReset
function _handleConfigReset() { storage.removeDataByKey(savedConfigKey); let initString = getCurrentConfig(); configEditor.setValue(prettifyInitString(initString)); }
javascript
function _handleConfigReset() { storage.removeDataByKey(savedConfigKey); let initString = getCurrentConfig(); configEditor.setValue(prettifyInitString(initString)); }
[ "function", "_handleConfigReset", "(", ")", "{", "storage", ".", "removeDataByKey", "(", "savedConfigKey", ")", ";", "let", "initString", "=", "getCurrentConfig", "(", ")", ";", "configEditor", ".", "setValue", "(", "prettifyInitString", "(", "initString", ")", ...
Resets the chart config to its default state
[ "Resets", "the", "chart", "config", "to", "its", "default", "state" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L329-L335
train
eventbrite/britecharts
sandbox/sandbox.js
_handleChartSelectorChange
function _handleChartSelectorChange() { storage.clear(); let chartType = d3.select(`.${chartSelectorClass}`).property('value'); storage.setDataByKey(savedChartTypeKey, chartType); updateAllComponents(); }
javascript
function _handleChartSelectorChange() { storage.clear(); let chartType = d3.select(`.${chartSelectorClass}`).property('value'); storage.setDataByKey(savedChartTypeKey, chartType); updateAllComponents(); }
[ "function", "_handleChartSelectorChange", "(", ")", "{", "storage", ".", "clear", "(", ")", ";", "let", "chartType", "=", "d3", ".", "select", "(", "`", "${", "chartSelectorClass", "}", "`", ")", ".", "property", "(", "'value'", ")", ";", "storage", ".",...
Updates the chart type when the chart selector is changed
[ "Updates", "the", "chart", "type", "when", "the", "chart", "selector", "is", "changed" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L341-L348
train
eventbrite/britecharts
sandbox/sandbox.js
_safeLoadDependency
function _safeLoadDependency(name) { try { window[name.split('/').pop()] = require(`../src/charts/${name}`); } catch(e) { errors.push({ error: e, filePath: name }); } }
javascript
function _safeLoadDependency(name) { try { window[name.split('/').pop()] = require(`../src/charts/${name}`); } catch(e) { errors.push({ error: e, filePath: name }); } }
[ "function", "_safeLoadDependency", "(", "name", ")", "{", "try", "{", "window", "[", "name", ".", "split", "(", "'/'", ")", ".", "pop", "(", ")", "]", "=", "require", "(", "`", "${", "name", "}", "`", ")", ";", "}", "catch", "(", "e", ")", "{",...
Safe load dependency. If there is an error, it loads the error to be displayed in the notification bar @param {file name} name name of fiel at src/charts. probably could refactor to take full path
[ "Safe", "load", "dependency", ".", "If", "there", "is", "an", "error", "it", "loads", "the", "error", "to", "be", "displayed", "in", "the", "notification", "bar" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/sandbox/sandbox.js#L354-L363
train
eventbrite/britecharts
src/charts/scatter-plot.js
buildAxis
function buildAxis() { xAxis = d3Axis.axisBottom(xScale) .ticks(xTicks) .tickPadding(tickPadding) .tickFormat(d3Format.format(xAxisFormat)); yAxis = d3Axis.axisLeft(yScale) .ticks(yTicks) .tickPadding(tickPadding) ...
javascript
function buildAxis() { xAxis = d3Axis.axisBottom(xScale) .ticks(xTicks) .tickPadding(tickPadding) .tickFormat(d3Format.format(xAxisFormat)); yAxis = d3Axis.axisLeft(yScale) .ticks(yTicks) .tickPadding(tickPadding) ...
[ "function", "buildAxis", "(", ")", "{", "xAxis", "=", "d3Axis", ".", "axisBottom", "(", "xScale", ")", ".", "ticks", "(", "xTicks", ")", ".", "tickPadding", "(", "tickPadding", ")", ".", "tickFormat", "(", "d3Format", ".", "format", "(", "xAxisFormat", "...
Creates the x-axis and y-axis with proper orientations @return {void} @private
[ "Creates", "the", "x", "-", "axis", "and", "y", "-", "axis", "with", "proper", "orientations" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L241-L251
train
eventbrite/britecharts
src/charts/scatter-plot.js
buildVoronoi
function buildVoronoi() { voronoi = d3Voronoi.voronoi() .x((d) => xScale(d.x)) .y((d) => yScale(d.y)) .extent([ [0, 0], [chartWidth, chartHeight] ])(dataPoints); }
javascript
function buildVoronoi() { voronoi = d3Voronoi.voronoi() .x((d) => xScale(d.x)) .y((d) => yScale(d.y)) .extent([ [0, 0], [chartWidth, chartHeight] ])(dataPoints); }
[ "function", "buildVoronoi", "(", ")", "{", "voronoi", "=", "d3Voronoi", ".", "voronoi", "(", ")", ".", "x", "(", "(", "d", ")", "=>", "xScale", "(", "d", ".", "x", ")", ")", ".", "y", "(", "(", "d", ")", "=>", "yScale", "(", "d", ".", "y", ...
Draws the voronoi component in the chart. @return {void} @private
[ "Draws", "the", "voronoi", "component", "in", "the", "chart", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L286-L294
train
eventbrite/britecharts
src/charts/scatter-plot.js
buildScales
function buildScales() { const [minX, minY] = [d3Array.min(dataPoints, ({ x }) => x), d3Array.min(dataPoints, ({ y }) => y)]; const [maxX, maxY] = [d3Array.max(dataPoints, ({ x }) => x), d3Array.max(dataPoints, ({ y }) => y)]; const yScaleBottomValue = Math.abs(minY) < 0 ? Math.abs(m...
javascript
function buildScales() { const [minX, minY] = [d3Array.min(dataPoints, ({ x }) => x), d3Array.min(dataPoints, ({ y }) => y)]; const [maxX, maxY] = [d3Array.max(dataPoints, ({ x }) => x), d3Array.max(dataPoints, ({ y }) => y)]; const yScaleBottomValue = Math.abs(minY) < 0 ? Math.abs(m...
[ "function", "buildScales", "(", ")", "{", "const", "[", "minX", ",", "minY", "]", "=", "[", "d3Array", ".", "min", "(", "dataPoints", ",", "(", "{", "x", "}", ")", "=>", "x", ")", ",", "d3Array", ".", "min", "(", "dataPoints", ",", "(", "{", "y...
Creates the x and y scales of the chart @return {void} @private
[ "Creates", "the", "x", "and", "y", "scales", "of", "the", "chart" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L301-L342
train
eventbrite/britecharts
src/charts/scatter-plot.js
cleanData
function cleanData(originalData) { return originalData.reduce((acc, d) => { d.name = String(d[nameKey]); d.x = d[xKey]; d.y = d[yKey]; return [...acc, d]; }, []); }
javascript
function cleanData(originalData) { return originalData.reduce((acc, d) => { d.name = String(d[nameKey]); d.x = d[xKey]; d.y = d[yKey]; return [...acc, d]; }, []); }
[ "function", "cleanData", "(", "originalData", ")", "{", "return", "originalData", ".", "reduce", "(", "(", "acc", ",", "d", ")", "=>", "{", "d", ".", "name", "=", "String", "(", "d", "[", "nameKey", "]", ")", ";", "d", ".", "x", "=", "d", "[", ...
Cleaning data casting the values and names to the proper type while keeping the rest of properties on the data @param {ScatterPlotData} originalData Raw data as passed to the container @return {ScatterPlotData} Clean data @private
[ "Cleaning", "data", "casting", "the", "values", "and", "names", "to", "the", "proper", "type", "while", "keeping", "the", "rest", "of", "properties", "on", "the", "data" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L372-L380
train
eventbrite/britecharts
src/charts/scatter-plot.js
drawAxisLabels
function drawAxisLabels() { // If y-axis label is given, draw it if (yAxisLabel) { if (yAxisLabelEl) { svg.selectAll('.y-axis-label-text').remove(); } yAxisLabelEl = svg.select('.axis-labels-group') .append(...
javascript
function drawAxisLabels() { // If y-axis label is given, draw it if (yAxisLabel) { if (yAxisLabelEl) { svg.selectAll('.y-axis-label-text').remove(); } yAxisLabelEl = svg.select('.axis-labels-group') .append(...
[ "function", "drawAxisLabels", "(", ")", "{", "// If y-axis label is given, draw it", "if", "(", "yAxisLabel", ")", "{", "if", "(", "yAxisLabelEl", ")", "{", "svg", ".", "selectAll", "(", "'.y-axis-label-text'", ")", ".", "remove", "(", ")", ";", "}", "yAxisLab...
Draws axis labels next to x and y axis to represent data value labels on the chart @return {void} @private
[ "Draws", "axis", "labels", "next", "to", "x", "and", "y", "axis", "to", "represent", "data", "value", "labels", "on", "the", "chart" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L405-L440
train
eventbrite/britecharts
src/charts/scatter-plot.js
drawTrendline
function drawTrendline(linearData) { if (trendLinePath) { trendLinePath.remove(); } const params = [ {x: linearData.x1, y: linearData.y1}, {x: linearData.x2, y: linearData.y2} ]; let line = d3Shape.line() ...
javascript
function drawTrendline(linearData) { if (trendLinePath) { trendLinePath.remove(); } const params = [ {x: linearData.x1, y: linearData.y1}, {x: linearData.x2, y: linearData.y2} ]; let line = d3Shape.line() ...
[ "function", "drawTrendline", "(", "linearData", ")", "{", "if", "(", "trendLinePath", ")", "{", "trendLinePath", ".", "remove", "(", ")", ";", "}", "const", "params", "=", "[", "{", "x", ":", "linearData", ".", "x1", ",", "y", ":", "linearData", ".", ...
Draws a trend line given the data that contains and y params from calculated y-intercept and slope using linear regression formula. @param {Object} linearData @returns {void} @private
[ "Draws", "a", "trend", "line", "given", "the", "data", "that", "contains", "and", "y", "params", "from", "calculated", "y", "-", "intercept", "and", "slope", "using", "linear", "regression", "formula", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L468-L501
train
eventbrite/britecharts
src/charts/scatter-plot.js
drawVerticalGridLines
function drawVerticalGridLines() { maskGridLines = svg.select('.grid-lines-group') .selectAll('line.vertical-grid-line') .data(xScale.ticks(xTicks)) .enter() .append('line') .attr('class', 'vertical-grid-line') ...
javascript
function drawVerticalGridLines() { maskGridLines = svg.select('.grid-lines-group') .selectAll('line.vertical-grid-line') .data(xScale.ticks(xTicks)) .enter() .append('line') .attr('class', 'vertical-grid-line') ...
[ "function", "drawVerticalGridLines", "(", ")", "{", "maskGridLines", "=", "svg", ".", "select", "(", "'.grid-lines-group'", ")", ".", "selectAll", "(", "'line.vertical-grid-line'", ")", ".", "data", "(", "xScale", ".", "ticks", "(", "xTicks", ")", ")", ".", ...
Draws vertical gridlines of the chart These gridlines are parallel to y-axis @return {void} @private
[ "Draws", "vertical", "gridlines", "of", "the", "chart", "These", "gridlines", "are", "parallel", "to", "y", "-", "axis" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L509-L520
train
eventbrite/britecharts
src/charts/scatter-plot.js
drawDataPoints
function drawDataPoints() { let circles = svg.select('.chart-group') .attr('clip-path', `url(#${maskingRectangleId})`) .selectAll('circle') .data(dataPoints) .enter(); if (isAnimated) { circles ....
javascript
function drawDataPoints() { let circles = svg.select('.chart-group') .attr('clip-path', `url(#${maskingRectangleId})`) .selectAll('circle') .data(dataPoints) .enter(); if (isAnimated) { circles ....
[ "function", "drawDataPoints", "(", ")", "{", "let", "circles", "=", "svg", ".", "select", "(", "'.chart-group'", ")", ".", "attr", "(", "'clip-path'", ",", "`", "${", "maskingRectangleId", "}", "`", ")", ".", "selectAll", "(", "'circle'", ")", ".", "data...
Draws the points for each data element on the chart group @return {void} @private
[ "Draws", "the", "points", "for", "each", "data", "element", "on", "the", "chart", "group" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L527-L566
train
eventbrite/britecharts
src/charts/scatter-plot.js
drawDataPointsValueHighlights
function drawDataPointsValueHighlights(data) { showCrossHairComponentsWithLabels(true); // Draw line perpendicular to y-axis highlightCrossHairContainer.selectAll('line.highlight-y-line') .attr('stroke', nameColorMap[data.name]) .attr('class', 'highlight-...
javascript
function drawDataPointsValueHighlights(data) { showCrossHairComponentsWithLabels(true); // Draw line perpendicular to y-axis highlightCrossHairContainer.selectAll('line.highlight-y-line') .attr('stroke', nameColorMap[data.name]) .attr('class', 'highlight-...
[ "function", "drawDataPointsValueHighlights", "(", "data", ")", "{", "showCrossHairComponentsWithLabels", "(", "true", ")", ";", "// Draw line perpendicular to y-axis", "highlightCrossHairContainer", ".", "selectAll", "(", "'line.highlight-y-line'", ")", ".", "attr", "(", "'...
Draws the crosshair lines and label components given the coordinates and name of the data point @param {Object} dataPoint @return {void} @private
[ "Draws", "the", "crosshair", "lines", "and", "label", "components", "given", "the", "coordinates", "and", "name", "of", "the", "data", "point" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L575-L614
train
eventbrite/britecharts
src/charts/scatter-plot.js
drawHorizontalGridLines
function drawHorizontalGridLines() { maskGridLines = svg.select('.grid-lines-group') .selectAll('line.horizontal-grid-line') .data(yScale.ticks(yTicks)) .enter() .append('line') .attr('class', 'horizontal-grid-line') ...
javascript
function drawHorizontalGridLines() { maskGridLines = svg.select('.grid-lines-group') .selectAll('line.horizontal-grid-line') .data(yScale.ticks(yTicks)) .enter() .append('line') .attr('class', 'horizontal-grid-line') ...
[ "function", "drawHorizontalGridLines", "(", ")", "{", "maskGridLines", "=", "svg", ".", "select", "(", "'.grid-lines-group'", ")", ".", "selectAll", "(", "'line.horizontal-grid-line'", ")", ".", "data", "(", "yScale", ".", "ticks", "(", "yTicks", ")", ")", "."...
Draw horizontal gridles of the chart These gridlines are parallel to x-axis @return {void} @private
[ "Draw", "horizontal", "gridles", "of", "the", "chart", "These", "gridlines", "are", "parallel", "to", "x", "-", "axis" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L661-L672
train
eventbrite/britecharts
src/charts/scatter-plot.js
calcLinearRegression
function calcLinearRegression() { let n = dataPoints.length, x = 0, y = 0, xy = 0, x2 = 0, y2 = 0; dataPoints.forEach(d => { x += d.x; y += d.y; xy += d.x * d.y; x2 += d.x...
javascript
function calcLinearRegression() { let n = dataPoints.length, x = 0, y = 0, xy = 0, x2 = 0, y2 = 0; dataPoints.forEach(d => { x += d.x; y += d.y; xy += d.x * d.y; x2 += d.x...
[ "function", "calcLinearRegression", "(", ")", "{", "let", "n", "=", "dataPoints", ".", "length", ",", "x", "=", "0", ",", "y", "=", "0", ",", "xy", "=", "0", ",", "x2", "=", "0", ",", "y2", "=", "0", ";", "dataPoints", ".", "forEach", "(", "d",...
Returns an object that contains necessary coordinates for drawing the trendline. The calculation of slope and y-intercept uses basic accumulative linear regression formula. @return {Object} @private
[ "Returns", "an", "object", "that", "contains", "necessary", "coordinates", "for", "drawing", "the", "trendline", ".", "The", "calculation", "of", "slope", "and", "y", "-", "intercept", "uses", "basic", "accumulative", "linear", "regression", "formula", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L682-L710
train
eventbrite/britecharts
src/charts/scatter-plot.js
getPointProps
function getPointProps(svg) { let mousePos = d3Selection.mouse(svg); mousePos[0] -= margin.left; mousePos[1] -= margin.top; return { closestPoint: voronoi.find(mousePos[0], mousePos[1]), mousePos }; }
javascript
function getPointProps(svg) { let mousePos = d3Selection.mouse(svg); mousePos[0] -= margin.left; mousePos[1] -= margin.top; return { closestPoint: voronoi.find(mousePos[0], mousePos[1]), mousePos }; }
[ "function", "getPointProps", "(", "svg", ")", "{", "let", "mousePos", "=", "d3Selection", ".", "mouse", "(", "svg", ")", ";", "mousePos", "[", "0", "]", "-=", "margin", ".", "left", ";", "mousePos", "[", "1", "]", "-=", "margin", ".", "top", ";", "...
Calculates and returns @param {*} svg @return {Object} @private
[ "Calculates", "and", "returns" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L718-L728
train
eventbrite/britecharts
src/charts/scatter-plot.js
handleMouseMove
function handleMouseMove(e) { let { mousePos, closestPoint } = getPointProps(e); let pointData = getPointData(closestPoint); if (hasCrossHairs) { drawDataPointsValueHighlights(pointData); } highlightDataPoint(pointData); dispatch...
javascript
function handleMouseMove(e) { let { mousePos, closestPoint } = getPointProps(e); let pointData = getPointData(closestPoint); if (hasCrossHairs) { drawDataPointsValueHighlights(pointData); } highlightDataPoint(pointData); dispatch...
[ "function", "handleMouseMove", "(", "e", ")", "{", "let", "{", "mousePos", ",", "closestPoint", "}", "=", "getPointProps", "(", "e", ")", ";", "let", "pointData", "=", "getPointData", "(", "closestPoint", ")", ";", "if", "(", "hasCrossHairs", ")", "{", "...
Handler called on mousemove event @return {void} @private
[ "Handler", "called", "on", "mousemove", "event" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L735-L746
train
eventbrite/britecharts
src/charts/scatter-plot.js
handleMouseOver
function handleMouseOver (e, d) { dispatcher.call('customMouseOver', e, d, d3Selection.mouse(e)); }
javascript
function handleMouseOver (e, d) { dispatcher.call('customMouseOver', e, d, d3Selection.mouse(e)); }
[ "function", "handleMouseOver", "(", "e", ",", "d", ")", "{", "dispatcher", ".", "call", "(", "'customMouseOver'", ",", "e", ",", "d", ",", "d3Selection", ".", "mouse", "(", "e", ")", ")", ";", "}" ]
Handler called on mouseover event @return {void} @private
[ "Handler", "called", "on", "mouseover", "event" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L753-L755
train
eventbrite/britecharts
src/charts/scatter-plot.js
handleMouseOut
function handleMouseOut(e, d) { removePointHighlight(); if (hasCrossHairs) { showCrossHairComponentsWithLabels(false); } dispatcher.call('customMouseOut', e, d, d3Selection.mouse(e)); }
javascript
function handleMouseOut(e, d) { removePointHighlight(); if (hasCrossHairs) { showCrossHairComponentsWithLabels(false); } dispatcher.call('customMouseOut', e, d, d3Selection.mouse(e)); }
[ "function", "handleMouseOut", "(", "e", ",", "d", ")", "{", "removePointHighlight", "(", ")", ";", "if", "(", "hasCrossHairs", ")", "{", "showCrossHairComponentsWithLabels", "(", "false", ")", ";", "}", "dispatcher", ".", "call", "(", "'customMouseOut'", ",", ...
Handler called on mouseout event @return {void} @private
[ "Handler", "called", "on", "mouseout", "event" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L762-L769
train
eventbrite/britecharts
src/charts/scatter-plot.js
handleClick
function handleClick(e) { let { closestPoint } = getPointProps(e); let d = getPointData(closestPoint); handleClickAnimation(d); dispatcher.call('customClick', e, d, d3Selection.mouse(e), [chartWidth, chartHeight]); }
javascript
function handleClick(e) { let { closestPoint } = getPointProps(e); let d = getPointData(closestPoint); handleClickAnimation(d); dispatcher.call('customClick', e, d, d3Selection.mouse(e), [chartWidth, chartHeight]); }
[ "function", "handleClick", "(", "e", ")", "{", "let", "{", "closestPoint", "}", "=", "getPointProps", "(", "e", ")", ";", "let", "d", "=", "getPointData", "(", "closestPoint", ")", ";", "handleClickAnimation", "(", "d", ")", ";", "dispatcher", ".", "call...
Custom onClick event handler @return {void} @private
[ "Custom", "onClick", "event", "handler" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L776-L783
train
eventbrite/britecharts
src/charts/scatter-plot.js
handleClickAnimation
function handleClickAnimation(dataPoint) { bounceCircleHighlight( highlightCircle, ease, areaScale(dataPoint.y), areaScale(dataPoint.y * 2) ); }
javascript
function handleClickAnimation(dataPoint) { bounceCircleHighlight( highlightCircle, ease, areaScale(dataPoint.y), areaScale(dataPoint.y * 2) ); }
[ "function", "handleClickAnimation", "(", "dataPoint", ")", "{", "bounceCircleHighlight", "(", "highlightCircle", ",", "ease", ",", "areaScale", "(", "dataPoint", ".", "y", ")", ",", "areaScale", "(", "dataPoint", ".", "y", "*", "2", ")", ")", ";", "}" ]
Applies animation on data point click @param {Object} dataPoint @return {void} @private
[ "Applies", "animation", "on", "data", "point", "click" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L791-L798
train
eventbrite/britecharts
src/charts/scatter-plot.js
highlightDataPoint
function highlightDataPoint(data) { removePointHighlight(); if (!highlightFilter) { highlightFilter = createFilterContainer(svg.select('.metadata-group')); highlightFilterId = createGlowWithMatrix(highlightFilter); } highlightCircle ...
javascript
function highlightDataPoint(data) { removePointHighlight(); if (!highlightFilter) { highlightFilter = createFilterContainer(svg.select('.metadata-group')); highlightFilterId = createGlowWithMatrix(highlightFilter); } highlightCircle ...
[ "function", "highlightDataPoint", "(", "data", ")", "{", "removePointHighlight", "(", ")", ";", "if", "(", "!", "highlightFilter", ")", "{", "highlightFilter", "=", "createFilterContainer", "(", "svg", ".", "select", "(", "'.metadata-group'", ")", ")", ";", "h...
Applies glow to hovered data point @return {void} @private
[ "Applies", "glow", "to", "hovered", "data", "point" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L805-L827
train
eventbrite/britecharts
src/charts/scatter-plot.js
initHighlightComponents
function initHighlightComponents() { highlightCircle = svg.select('.metadata-group') .selectAll('circle.highlight-circle') .data([1]) .enter() .append('circle') .attr('class', 'highlight-circle') .attr(...
javascript
function initHighlightComponents() { highlightCircle = svg.select('.metadata-group') .selectAll('circle.highlight-circle') .data([1]) .enter() .append('circle') .attr('class', 'highlight-circle') .attr(...
[ "function", "initHighlightComponents", "(", ")", "{", "highlightCircle", "=", "svg", ".", "select", "(", "'.metadata-group'", ")", ".", "selectAll", "(", "'circle.highlight-circle'", ")", ".", "data", "(", "[", "1", "]", ")", ".", "enter", "(", ")", ".", "...
Places the highlighter point to the DOM to be used once one of the data points is highlighted @return {void} @private
[ "Places", "the", "highlighter", "point", "to", "the", "DOM", "to", "be", "used", "once", "one", "of", "the", "data", "points", "is", "highlighted" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L836-L880
train
eventbrite/britecharts
src/charts/scatter-plot.js
showCrossHairComponentsWithLabels
function showCrossHairComponentsWithLabels(status = false) { const opacityIndex = status ? 1 : 0; highlightCrossHairContainer.attr('opacity', opacityIndex); highlightCrossHairLabelsContainer.attr('opacity', opacityIndex); }
javascript
function showCrossHairComponentsWithLabels(status = false) { const opacityIndex = status ? 1 : 0; highlightCrossHairContainer.attr('opacity', opacityIndex); highlightCrossHairLabelsContainer.attr('opacity', opacityIndex); }
[ "function", "showCrossHairComponentsWithLabels", "(", "status", "=", "false", ")", "{", "const", "opacityIndex", "=", "status", "?", "1", ":", "0", ";", "highlightCrossHairContainer", ".", "attr", "(", "'opacity'", ",", "opacityIndex", ")", ";", "highlightCrossHai...
Sets the visibility of cross hair lines if 1, it sets lines to visible, if 0, it hides lines @param {boolean} @return {void} @private
[ "Sets", "the", "visibility", "of", "cross", "hair", "lines", "if", "1", "it", "sets", "lines", "to", "visible", "if", "0", "it", "hides", "lines" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/scatter-plot.js#L899-L904
train
eventbrite/britecharts
src/charts/helpers/export.js
exportChart
function exportChart(d3svg, filename, title) { if (isIE) { console.error(IE_ERROR_MSG); return false; } let img = createImage(convertSvgToHtml.call(this, d3svg, title)); img.onload = handleImageLoad.bind( img, createCanvas(this.w...
javascript
function exportChart(d3svg, filename, title) { if (isIE) { console.error(IE_ERROR_MSG); return false; } let img = createImage(convertSvgToHtml.call(this, d3svg, title)); img.onload = handleImageLoad.bind( img, createCanvas(this.w...
[ "function", "exportChart", "(", "d3svg", ",", "filename", ",", "title", ")", "{", "if", "(", "isIE", ")", "{", "console", ".", "error", "(", "IE_ERROR_MSG", ")", ";", "return", "false", ";", "}", "let", "img", "=", "createImage", "(", "convertSvgToHtml",...
Main function to be used as a method by chart instances to export charts to png @param {array} svgs (or an svg element) pass in both chart & legend as array or just chart as svg or in array @param {string} filename [download to be called <filename>.png] @param {string} title Title for the image
[ "Main", "function", "to", "be", "used", "as", "a", "method", "by", "chart", "instances", "to", "export", "charts", "to", "png" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/helpers/export.js#L45-L59
train
eventbrite/britecharts
src/charts/helpers/export.js
convertSvgToHtml
function convertSvgToHtml (d3svg, title) { if (!d3svg) { return; } d3svg.attr('version', 1.1) .attr('xmlns', 'http://www.w3.org/2000/svg'); let serializer = serializeWithStyles.initializeSerializer(); let html = serializer(d3svg.node()); html = f...
javascript
function convertSvgToHtml (d3svg, title) { if (!d3svg) { return; } d3svg.attr('version', 1.1) .attr('xmlns', 'http://www.w3.org/2000/svg'); let serializer = serializeWithStyles.initializeSerializer(); let html = serializer(d3svg.node()); html = f...
[ "function", "convertSvgToHtml", "(", "d3svg", ",", "title", ")", "{", "if", "(", "!", "d3svg", ")", "{", "return", ";", "}", "d3svg", ".", "attr", "(", "'version'", ",", "1.1", ")", ".", "attr", "(", "'xmlns'", ",", "'http://www.w3.org/2000/svg'", ")", ...
Takes the D3 SVG element, adds proper SVG tags, adds inline styles from stylesheets, adds white background and returns string @param {SVGElement} d3svg TYPE d3 svg element @return {String} String of passed d3
[ "Takes", "the", "D3", "SVG", "element", "adds", "proper", "SVG", "tags", "adds", "inline", "styles", "from", "stylesheets", "adds", "white", "background", "and", "returns", "string" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/helpers/export.js#L75-L90
train
eventbrite/britecharts
src/charts/helpers/export.js
handleImageLoad
function handleImageLoad(canvas, filename, e) { e.preventDefault(); downloadCanvas(drawImageOnCanvas(this, canvas), filename); }
javascript
function handleImageLoad(canvas, filename, e) { e.preventDefault(); downloadCanvas(drawImageOnCanvas(this, canvas), filename); }
[ "function", "handleImageLoad", "(", "canvas", ",", "filename", ",", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "downloadCanvas", "(", "drawImageOnCanvas", "(", "this", ",", "canvas", ")", ",", "filename", ")", ";", "}" ]
Handles on load event fired by img.onload, this=img @param {object} canvas TYPE: el <canvas> @param {string} filename @param {object} e
[ "Handles", "on", "load", "event", "fired", "by", "img", ".", "onload", "this", "=", "img" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/helpers/export.js#L169-L173
train
eventbrite/britecharts
src/charts/helpers/export.js
prependTitle
function prependTitle(html, title, svgWidth) { if (!title || !svgWidth) { return html; } let {grey} = colorSchemas; html = html.replace(/<g/,`<text x="${this.margin().left}" y="${config.titleTopOffset}" font-family="${config.titleFontFamily}" font-size="${config.titleFontSi...
javascript
function prependTitle(html, title, svgWidth) { if (!title || !svgWidth) { return html; } let {grey} = colorSchemas; html = html.replace(/<g/,`<text x="${this.margin().left}" y="${config.titleTopOffset}" font-family="${config.titleFontFamily}" font-size="${config.titleFontSi...
[ "function", "prependTitle", "(", "html", ",", "title", ",", "svgWidth", ")", "{", "if", "(", "!", "title", "||", "!", "svgWidth", ")", "{", "return", "html", ";", "}", "let", "{", "grey", "}", "=", "colorSchemas", ";", "html", "=", "html", ".", "re...
if passed, append title to the raw html to appear on graph @param {string} html raw html string @param {string} title title of the graph @param {number} svgWidth width of graph container @return {string} raw html with title prepended
[ "if", "passed", "append", "title", "to", "the", "raw", "html", "to", "appear", "on", "graph" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/helpers/export.js#L182-L191
train
eventbrite/britecharts
src/charts/donut.js
buildContainerGroups
function buildContainerGroups() { let container = svg .append('g') .classed('container-group', true); container .append('g') .classed('chart-group', true); container .append('g') .classed('lege...
javascript
function buildContainerGroups() { let container = svg .append('g') .classed('container-group', true); container .append('g') .classed('chart-group', true); container .append('g') .classed('lege...
[ "function", "buildContainerGroups", "(", ")", "{", "let", "container", "=", "svg", ".", "append", "(", "'g'", ")", ".", "classed", "(", "'container-group'", ",", "true", ")", ";", "container", ".", "append", "(", "'g'", ")", ".", "classed", "(", "'chart-...
Builds containers for the chart, the legend and a wrapper for all of them @private
[ "Builds", "containers", "for", "the", "chart", "the", "legend", "and", "a", "wrapper", "for", "all", "of", "them" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L183-L194
train
eventbrite/britecharts
src/charts/donut.js
buildLayout
function buildLayout() { layout = d3Shape.pie() .padAngle(paddingAngle) .value(getQuantity) .sort(orderingFunction); }
javascript
function buildLayout() { layout = d3Shape.pie() .padAngle(paddingAngle) .value(getQuantity) .sort(orderingFunction); }
[ "function", "buildLayout", "(", ")", "{", "layout", "=", "d3Shape", ".", "pie", "(", ")", ".", "padAngle", "(", "paddingAngle", ")", ".", "value", "(", "getQuantity", ")", ".", "sort", "(", "orderingFunction", ")", ";", "}" ]
Builds the pie layout that will produce data ready to draw @private
[ "Builds", "the", "pie", "layout", "that", "will", "produce", "data", "ready", "to", "draw" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L200-L205
train
eventbrite/britecharts
src/charts/donut.js
cleanData
function cleanData(data) { let dataWithPercentages; let cleanData = data.reduce((acc, d) => { // Skip data without quantity if (d[quantityLabel] === undefined || d[quantityLabel] === null) { return acc; } d.quan...
javascript
function cleanData(data) { let dataWithPercentages; let cleanData = data.reduce((acc, d) => { // Skip data without quantity if (d[quantityLabel] === undefined || d[quantityLabel] === null) { return acc; } d.quan...
[ "function", "cleanData", "(", "data", ")", "{", "let", "dataWithPercentages", ";", "let", "cleanData", "=", "data", ".", "reduce", "(", "(", "acc", ",", "d", ")", "=>", "{", "// Skip data without quantity", "if", "(", "d", "[", "quantityLabel", "]", "===",...
Cleaning data casting the quantities, names and percentages to the proper type while keeping the rest of properties on the data. It also calculates the percentages if not present. @param {DonutChartData} data Data as passed to the container @return {DonutChartData} Clean data with percentages @private
[ "Cleaning", "data", "casting", "the", "quantities", "names", "and", "percentages", "to", "the", "proper", "type", "while", "keeping", "the", "rest", "of", "properties", "on", "the", "data", ".", "It", "also", "calculates", "the", "percentages", "if", "not", ...
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L250-L279
train
eventbrite/britecharts
src/charts/donut.js
drawEmptySlice
function drawEmptySlice() { if (slices) { svg.selectAll('g.arc').remove(); } slices = svg.select('.chart-group') .selectAll('g.arc') .data(layout(emptyDonutData)); let newSlices = slices.enter() .append('g'...
javascript
function drawEmptySlice() { if (slices) { svg.selectAll('g.arc').remove(); } slices = svg.select('.chart-group') .selectAll('g.arc') .data(layout(emptyDonutData)); let newSlices = slices.enter() .append('g'...
[ "function", "drawEmptySlice", "(", ")", "{", "if", "(", "slices", ")", "{", "svg", ".", "selectAll", "(", "'g.arc'", ")", ".", "remove", "(", ")", ";", "}", "slices", "=", "svg", ".", "select", "(", "'.chart-group'", ")", ".", "selectAll", "(", "'g.a...
Draw an empty slice @private
[ "Draw", "an", "empty", "slice" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L293-L318
train
eventbrite/britecharts
src/charts/donut.js
drawLegend
function drawLegend(obj) { if (obj.data) { svg.select('.donut-text') .text(() => centeredTextFunction(obj.data)) .attr('dy', '.2em') .attr('text-anchor', 'middle'); svg.select('.donut-text').call(wrapText, legendWi...
javascript
function drawLegend(obj) { if (obj.data) { svg.select('.donut-text') .text(() => centeredTextFunction(obj.data)) .attr('dy', '.2em') .attr('text-anchor', 'middle'); svg.select('.donut-text').call(wrapText, legendWi...
[ "function", "drawLegend", "(", "obj", ")", "{", "if", "(", "obj", ".", "data", ")", "{", "svg", ".", "select", "(", "'.donut-text'", ")", ".", "text", "(", "(", ")", "=>", "centeredTextFunction", "(", "obj", ".", "data", ")", ")", ".", "attr", "(",...
Draws the values on the donut slice inside the text element @param {Object} obj Data object @private
[ "Draws", "the", "values", "on", "the", "donut", "slice", "inside", "the", "text", "element" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L326-L336
train
eventbrite/britecharts
src/charts/donut.js
drawSlices
function drawSlices() { // Not ideal, we need to figure out how to call exit for nested elements if (slices) { svg.selectAll('g.arc').remove(); } slices = svg.select('.chart-group') .selectAll('g.arc') .data(layout(data)); ...
javascript
function drawSlices() { // Not ideal, we need to figure out how to call exit for nested elements if (slices) { svg.selectAll('g.arc').remove(); } slices = svg.select('.chart-group') .selectAll('g.arc') .data(layout(data)); ...
[ "function", "drawSlices", "(", ")", "{", "// Not ideal, we need to figure out how to call exit for nested elements", "if", "(", "slices", ")", "{", "svg", ".", "selectAll", "(", "'g.arc'", ")", ".", "remove", "(", ")", ";", "}", "slices", "=", "svg", ".", "selec...
Draws the slices of the donut @private
[ "Draws", "the", "slices", "of", "the", "donut" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L342-L397
train
eventbrite/britecharts
src/charts/donut.js
handleMouseOver
function handleMouseOver(el, d, chartWidth, chartHeight) { drawLegend(d); dispatcher.call('customMouseOver', el, d, d3Selection.mouse(el), [chartWidth, chartHeight]); if (hasHoverAnimation) { // if the hovered slice is not the same as the last slice hovered ...
javascript
function handleMouseOver(el, d, chartWidth, chartHeight) { drawLegend(d); dispatcher.call('customMouseOver', el, d, d3Selection.mouse(el), [chartWidth, chartHeight]); if (hasHoverAnimation) { // if the hovered slice is not the same as the last slice hovered ...
[ "function", "handleMouseOver", "(", "el", ",", "d", ",", "chartWidth", ",", "chartHeight", ")", "{", "drawLegend", "(", "d", ")", ";", "dispatcher", ".", "call", "(", "'customMouseOver'", ",", "el", ",", "d", ",", "d3Selection", ".", "mouse", "(", "el", ...
Handles a path mouse over @return {void} @private
[ "Handles", "a", "path", "mouse", "over" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L416-L432
train
eventbrite/britecharts
src/charts/donut.js
handleMouseMove
function handleMouseMove(el, d, chartWidth, chartHeight) { dispatcher.call('customMouseMove', el, d, d3Selection.mouse(el), [chartWidth, chartHeight]); }
javascript
function handleMouseMove(el, d, chartWidth, chartHeight) { dispatcher.call('customMouseMove', el, d, d3Selection.mouse(el), [chartWidth, chartHeight]); }
[ "function", "handleMouseMove", "(", "el", ",", "d", ",", "chartWidth", ",", "chartHeight", ")", "{", "dispatcher", ".", "call", "(", "'customMouseMove'", ",", "el", ",", "d", ",", "d3Selection", ".", "mouse", "(", "el", ")", ",", "[", "chartWidth", ",", ...
Handles a path mouse move @return {void} @private
[ "Handles", "a", "path", "mouse", "move" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L439-L441
train
eventbrite/britecharts
src/charts/donut.js
handleMouseOut
function handleMouseOut(el, d, chartWidth, chartHeight) { cleanLegend(); // When there is a fixed highlighted slice, // we will always highlight it and render legend if (highlightedSlice && hasFixedHighlightedSlice && !hasLastHoverSliceHighlighted) { draw...
javascript
function handleMouseOut(el, d, chartWidth, chartHeight) { cleanLegend(); // When there is a fixed highlighted slice, // we will always highlight it and render legend if (highlightedSlice && hasFixedHighlightedSlice && !hasLastHoverSliceHighlighted) { draw...
[ "function", "handleMouseOut", "(", "el", ",", "d", ",", "chartWidth", ",", "chartHeight", ")", "{", "cleanLegend", "(", ")", ";", "// When there is a fixed highlighted slice,", "// we will always highlight it and render legend", "if", "(", "highlightedSlice", "&&", "hasFi...
Handles a path mouse out @return {void} @private
[ "Handles", "a", "path", "mouse", "out" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L448-L471
train
eventbrite/britecharts
src/charts/donut.js
initHighlightSlice
function initHighlightSlice() { highlightedSlice = svg.selectAll('.chart-group .arc path') .select(filterHighlightedSlice).node(); if (highlightedSlice) { drawLegend(highlightedSlice.__data__); tweenGrowth(highlightedSlice, externalRadius, pieDraw...
javascript
function initHighlightSlice() { highlightedSlice = svg.selectAll('.chart-group .arc path') .select(filterHighlightedSlice).node(); if (highlightedSlice) { drawLegend(highlightedSlice.__data__); tweenGrowth(highlightedSlice, externalRadius, pieDraw...
[ "function", "initHighlightSlice", "(", ")", "{", "highlightedSlice", "=", "svg", ".", "selectAll", "(", "'.chart-group .arc path'", ")", ".", "select", "(", "filterHighlightedSlice", ")", ".", "node", "(", ")", ";", "if", "(", "highlightedSlice", ")", "{", "dr...
Find the slice by id and growth it if needed @private
[ "Find", "the", "slice", "by", "id", "and", "growth", "it", "if", "needed" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L486-L494
train
eventbrite/britecharts
src/charts/donut.js
tweenGrowth
function tweenGrowth(slice, outerRadius, delay = 0) { d3Selection.select(slice) .transition() .delay(delay) .attrTween('d', function(d) { let i = d3Interpolate.interpolate(d.outerRadius, outerRadius); return (t) => { ...
javascript
function tweenGrowth(slice, outerRadius, delay = 0) { d3Selection.select(slice) .transition() .delay(delay) .attrTween('d', function(d) { let i = d3Interpolate.interpolate(d.outerRadius, outerRadius); return (t) => { ...
[ "function", "tweenGrowth", "(", "slice", ",", "outerRadius", ",", "delay", "=", "0", ")", "{", "d3Selection", ".", "select", "(", "slice", ")", ".", "transition", "(", ")", ".", "delay", "(", "delay", ")", ".", "attrTween", "(", "'d'", ",", "function",...
Animate slice with tweens depending on the attributes given @param {DOMElement} slice Slice to growth @param {Number} outerRadius Final outer radius value @param {Number} delay Delay of animation @private
[ "Animate", "slice", "with", "tweens", "depending", "on", "the", "attributes", "given" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L531-L544
train
eventbrite/britecharts
src/charts/donut.js
wrapText
function wrapText(text, legendWidth) { let fontSize = externalRadius / 5; textHelper.wrapText.call(null, 0, fontSize, legendWidth, text.node()); }
javascript
function wrapText(text, legendWidth) { let fontSize = externalRadius / 5; textHelper.wrapText.call(null, 0, fontSize, legendWidth, text.node()); }
[ "function", "wrapText", "(", "text", ",", "legendWidth", ")", "{", "let", "fontSize", "=", "externalRadius", "/", "5", ";", "textHelper", ".", "wrapText", ".", "call", "(", "null", ",", "0", ",", "fontSize", ",", "legendWidth", ",", "text", ".", "node", ...
Utility function that wraps a text into the given width @param {D3Selection} text Text to write @param {Number} legendWidth Width of the container @private
[ "Utility", "function", "that", "wraps", "a", "text", "into", "the", "given", "width" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/donut.js#L570-L574
train
eventbrite/britecharts
src/charts/tooltip.js
getValueText
function getValueText(data) { let value = data[valueLabel]; let valueText; if (data.missingValue) { valueText = '-'; } else { valueText = getFormattedValue(value).toString(); } return valueText; }
javascript
function getValueText(data) { let value = data[valueLabel]; let valueText; if (data.missingValue) { valueText = '-'; } else { valueText = getFormattedValue(value).toString(); } return valueText; }
[ "function", "getValueText", "(", "data", ")", "{", "let", "value", "=", "data", "[", "valueLabel", "]", ";", "let", "valueText", ";", "if", "(", "data", ".", "missingValue", ")", "{", "valueText", "=", "'-'", ";", "}", "else", "{", "valueText", "=", ...
Extracts the value from the data object @param {Object} data Data value containing the info @return {String} Value to show
[ "Extracts", "the", "value", "from", "the", "data", "object" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/tooltip.js#L296-L307
train
eventbrite/britecharts
src/charts/tooltip.js
updateTitle
function updateTitle(dataPoint) { let tTitle = title; let formattedDate = formatDate(new Date(dataPoint[dateLabel])); if (tTitle.length) { if (shouldShowDateInTitle) { tTitle = `${tTitle} - ${formattedDate}`; } } else {...
javascript
function updateTitle(dataPoint) { let tTitle = title; let formattedDate = formatDate(new Date(dataPoint[dateLabel])); if (tTitle.length) { if (shouldShowDateInTitle) { tTitle = `${tTitle} - ${formattedDate}`; } } else {...
[ "function", "updateTitle", "(", "dataPoint", ")", "{", "let", "tTitle", "=", "title", ";", "let", "formattedDate", "=", "formatDate", "(", "new", "Date", "(", "dataPoint", "[", "dateLabel", "]", ")", ")", ";", "if", "(", "tTitle", ".", "length", ")", "...
Updates value of tooltipTitle with the data meaning and the date @param {Object} dataPoint Point of data to use as source @return void @private
[ "Updates", "value", "of", "tooltipTitle", "with", "the", "data", "meaning", "and", "the", "date" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/tooltip.js#L409-L422
train
eventbrite/britecharts
src/charts/tooltip.js
formatDate
function formatDate(date) { let settings = dateFormat || defaultAxisSettings; let format = null; let localeOptions = {month:'short', day:'numeric'}; if (settings === axisTimeCombinations.DAY_MONTH || settings === axisTimeCombinations.MONTH_YEAR) { format ...
javascript
function formatDate(date) { let settings = dateFormat || defaultAxisSettings; let format = null; let localeOptions = {month:'short', day:'numeric'}; if (settings === axisTimeCombinations.DAY_MONTH || settings === axisTimeCombinations.MONTH_YEAR) { format ...
[ "function", "formatDate", "(", "date", ")", "{", "let", "settings", "=", "dateFormat", "||", "defaultAxisSettings", ";", "let", "format", "=", "null", ";", "let", "localeOptions", "=", "{", "month", ":", "'short'", ",", "day", ":", "'numeric'", "}", ";", ...
Figures out which date format to use when showing the date of the current data entry @param {Date} date Date object to format @return {Function} The proper date formatting function @private
[ "Figures", "out", "which", "date", "format", "to", "use", "when", "showing", "the", "date", "of", "the", "current", "data", "entry" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/tooltip.js#L430-L452
train
eventbrite/britecharts
src/charts/tooltip.js
_sortByTopicsOrder
function _sortByTopicsOrder(topics, order=topicsOrder) { return order.map((orderName) => topics.filter(({name}) => name === orderName)[0]); }
javascript
function _sortByTopicsOrder(topics, order=topicsOrder) { return order.map((orderName) => topics.filter(({name}) => name === orderName)[0]); }
[ "function", "_sortByTopicsOrder", "(", "topics", ",", "order", "=", "topicsOrder", ")", "{", "return", "order", ".", "map", "(", "(", "orderName", ")", "=>", "topics", ".", "filter", "(", "(", "{", "name", "}", ")", "=>", "name", "===", "orderName", ")...
Helper method to sort the passed topics array by the names passed int he order arary @param {Object[]} topics Topics data, retrieved from datapoint passed by line chart @param {Object[]} order Array of names in the order to sort topics by @return {Object[]} sorted topics object @private
[ "Helper", "method", "to", "sort", "the", "passed", "topics", "array", "by", "the", "names", "passed", "int", "he", "order", "arary" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/tooltip.js#L461-L463
train
eventbrite/britecharts
src/charts/tooltip.js
_sortByAlpha
function _sortByAlpha(topics) { return topics .map(d => d) .sort((a, b) => { if (a.name > b.name) return 1; if (a.name === b.name) return 0; return -1; }); let otherIndex = topics.map(({...
javascript
function _sortByAlpha(topics) { return topics .map(d => d) .sort((a, b) => { if (a.name > b.name) return 1; if (a.name === b.name) return 0; return -1; }); let otherIndex = topics.map(({...
[ "function", "_sortByAlpha", "(", "topics", ")", "{", "return", "topics", ".", "map", "(", "d", "=>", "d", ")", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "{", "if", "(", "a", ".", "name", ">", "b", ".", "name", ")", "return", "1", ";", ...
Sorts topic by alphabetical order for arrays of objects with a name proeprty @param {Array} topics List of topic objects @return {Array} List of topic name strings @private
[ "Sorts", "topic", "by", "alphabetical", "order", "for", "arrays", "of", "objects", "with", "a", "name", "proeprty" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/tooltip.js#L471-L488
train
eventbrite/britecharts
src/charts/tooltip.js
updateContent
function updateContent(dataPoint){ var topics = dataPoint[topicLabel]; // sort order by topicsOrder array if passed if (topicsOrder.length) { topics = _sortByTopicsOrder(topics); } else if (topics.length && topics[0].name) { topics = _sort...
javascript
function updateContent(dataPoint){ var topics = dataPoint[topicLabel]; // sort order by topicsOrder array if passed if (topicsOrder.length) { topics = _sortByTopicsOrder(topics); } else if (topics.length && topics[0].name) { topics = _sort...
[ "function", "updateContent", "(", "dataPoint", ")", "{", "var", "topics", "=", "dataPoint", "[", "topicLabel", "]", ";", "// sort order by topicsOrder array if passed", "if", "(", "topicsOrder", ".", "length", ")", "{", "topics", "=", "_sortByTopicsOrder", "(", "t...
Draws the data entries inside the tooltip @param {Object} dataPoint Data entry from to take the info @return void @private
[ "Draws", "the", "data", "entries", "inside", "the", "tooltip" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/tooltip.js#L557-L571
train
eventbrite/britecharts
src/charts/tooltip.js
updateTooltip
function updateTooltip(dataPoint, xPosition, yPosition) { updateContent(dataPoint); updatePositionAndSize(dataPoint, xPosition, yPosition); }
javascript
function updateTooltip(dataPoint, xPosition, yPosition) { updateContent(dataPoint); updatePositionAndSize(dataPoint, xPosition, yPosition); }
[ "function", "updateTooltip", "(", "dataPoint", ",", "xPosition", ",", "yPosition", ")", "{", "updateContent", "(", "dataPoint", ")", ";", "updatePositionAndSize", "(", "dataPoint", ",", "xPosition", ",", "yPosition", ")", ";", "}" ]
Updates tooltip title, content, size and position sorts by alphatical name order if not forced order given @param {lineChartPointByDate} dataPoint Current datapoint to show info about @param {Number} xPosition Position of the mouse on the X axis @return void @private
[ "Updates", "tooltip", "title", "content", "size", "and", "position", "sorts", "by", "alphatical", "name", "order", "if", "not", "forced", "order", "given" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/tooltip.js#L582-L585
train
eventbrite/britecharts
src/charts/helpers/text.js
function(text, fontSize = defaultTextSize, fontFace = defaultFontFace) { let a = document.createElement('canvas'), b = a.getContext('2d'); b.font = fontSize + 'px ' + fontFace; return b.measureText(text).width; }
javascript
function(text, fontSize = defaultTextSize, fontFace = defaultFontFace) { let a = document.createElement('canvas'), b = a.getContext('2d'); b.font = fontSize + 'px ' + fontFace; return b.measureText(text).width; }
[ "function", "(", "text", ",", "fontSize", "=", "defaultTextSize", ",", "fontFace", "=", "defaultFontFace", ")", "{", "let", "a", "=", "document", ".", "createElement", "(", "'canvas'", ")", ",", "b", "=", "a", ".", "getContext", "(", "'2d'", ")", ";", ...
Figures out an approximate of the text width by using a canvas element This avoids having to actually render the text to measure it from the DOM itself @param {String} text Text to measure @param {Number} [fontSize=12] Font size (or default) @param {String} [fontFace='Arial'] Font family to use...
[ "Figures", "out", "an", "approximate", "of", "the", "text", "width", "by", "using", "a", "canvas", "element", "This", "avoids", "having", "to", "actually", "render", "the", "text", "to", "measure", "it", "from", "the", "DOM", "itself" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/helpers/text.js#L144-L151
train
eventbrite/britecharts
src/charts/heatmap.js
buildScales
function buildScales() { colorScale = d3Scale.scaleLinear() .range([colorSchema[0], colorSchema[colorSchema.length - 1]]) .domain(d3Array.extent(data, getValue)) .interpolate(d3Interpolate.interpolateHcl); }
javascript
function buildScales() { colorScale = d3Scale.scaleLinear() .range([colorSchema[0], colorSchema[colorSchema.length - 1]]) .domain(d3Array.extent(data, getValue)) .interpolate(d3Interpolate.interpolateHcl); }
[ "function", "buildScales", "(", ")", "{", "colorScale", "=", "d3Scale", ".", "scaleLinear", "(", ")", ".", "range", "(", "[", "colorSchema", "[", "0", "]", ",", "colorSchema", "[", "colorSchema", ".", "length", "-", "1", "]", "]", ")", ".", "domain", ...
Creates the scales for the heatmap chart @return void
[ "Creates", "the", "scales", "for", "the", "heatmap", "chart" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/heatmap.js#L183-L188
train
eventbrite/britecharts
src/charts/heatmap.js
drawBoxes
function drawBoxes() { boxes = svg.select('.chart-group').selectAll('.box').data(data); boxes.enter() .append('rect') .classed('box', true) .attr('width', boxSize) .attr('height', boxSize) .attr('x', ({hour}) => hour ...
javascript
function drawBoxes() { boxes = svg.select('.chart-group').selectAll('.box').data(data); boxes.enter() .append('rect') .classed('box', true) .attr('width', boxSize) .attr('height', boxSize) .attr('x', ({hour}) => hour ...
[ "function", "drawBoxes", "(", ")", "{", "boxes", "=", "svg", ".", "select", "(", "'.chart-group'", ")", ".", "selectAll", "(", "'.box'", ")", ".", "data", "(", "data", ")", ";", "boxes", ".", "enter", "(", ")", ".", "append", "(", "'rect'", ")", "....
Draws the boxes of the heatmap
[ "Draws", "the", "boxes", "of", "the", "heatmap" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/heatmap.js#L193-L213
train
eventbrite/britecharts
src/charts/heatmap.js
drawDayLabels
function drawDayLabels() { let dayLabelsGroup = svg.select('.day-labels-group'); dayLabels = svg.select('.day-labels-group').selectAll('.day-label') .data(daysHuman); dayLabels.enter() .append('text') .text((label) => label) ...
javascript
function drawDayLabels() { let dayLabelsGroup = svg.select('.day-labels-group'); dayLabels = svg.select('.day-labels-group').selectAll('.day-label') .data(daysHuman); dayLabels.enter() .append('text') .text((label) => label) ...
[ "function", "drawDayLabels", "(", ")", "{", "let", "dayLabelsGroup", "=", "svg", ".", "select", "(", "'.day-labels-group'", ")", ";", "dayLabels", "=", "svg", ".", "select", "(", "'.day-labels-group'", ")", ".", "selectAll", "(", "'.day-label'", ")", ".", "d...
Draws the day labels
[ "Draws", "the", "day", "labels" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/heatmap.js#L218-L234
train
eventbrite/britecharts
src/charts/heatmap.js
drawHourLabels
function drawHourLabels() { let hourLabelsGroup = svg.select('.hour-labels-group'); hourLabels = svg.select('.hour-labels-group').selectAll('.hour-label') .data(hoursHuman); hourLabels.enter() .append('text') .text((label) => label) ...
javascript
function drawHourLabels() { let hourLabelsGroup = svg.select('.hour-labels-group'); hourLabels = svg.select('.hour-labels-group').selectAll('.hour-label') .data(hoursHuman); hourLabels.enter() .append('text') .text((label) => label) ...
[ "function", "drawHourLabels", "(", ")", "{", "let", "hourLabelsGroup", "=", "svg", ".", "select", "(", "'.hour-labels-group'", ")", ";", "hourLabels", "=", "svg", ".", "select", "(", "'.hour-labels-group'", ")", ".", "selectAll", "(", "'.hour-label'", ")", "."...
Draws the hour labels
[ "Draws", "the", "hour", "labels" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/heatmap.js#L239-L255
train
eventbrite/britecharts
src/charts/stacked-area.js
addGlowFilter
function addGlowFilter(el) { if (!highlightFilter) { highlightFilter = createFilterContainer(svg.select('.metadata-group')); highlightFilterId = createGlowWithMatrix(highlightFilter); } let glowEl = d3Selection.select(el); glowEl ...
javascript
function addGlowFilter(el) { if (!highlightFilter) { highlightFilter = createFilterContainer(svg.select('.metadata-group')); highlightFilterId = createGlowWithMatrix(highlightFilter); } let glowEl = d3Selection.select(el); glowEl ...
[ "function", "addGlowFilter", "(", "el", ")", "{", "if", "(", "!", "highlightFilter", ")", "{", "highlightFilter", "=", "createFilterContainer", "(", "svg", ".", "select", "(", "'.metadata-group'", ")", ")", ";", "highlightFilterId", "=", "createGlowWithMatrix", ...
Adds a filter to the element @param {DOMElement} el @private
[ "Adds", "a", "filter", "to", "the", "element" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L241-L259
train
eventbrite/britecharts
src/charts/stacked-area.js
buildLayers
function buildLayers() { dataByDateFormatted = dataByDate .map(d => assign({}, d, d.values)) .map(d => { Object.keys(d).forEach(k => { const entry = d[k]; if (entry && entry.name) { ...
javascript
function buildLayers() { dataByDateFormatted = dataByDate .map(d => assign({}, d, d.values)) .map(d => { Object.keys(d).forEach(k => { const entry = d[k]; if (entry && entry.name) { ...
[ "function", "buildLayers", "(", ")", "{", "dataByDateFormatted", "=", "dataByDate", ".", "map", "(", "d", "=>", "assign", "(", "{", "}", ",", "d", ",", "d", ".", "values", ")", ")", ".", "map", "(", "d", "=>", "{", "Object", ".", "keys", "(", "d"...
Builds the stacked layers layout @return {D3Layout} Layout for drawing the chart @private
[ "Builds", "the", "stacked", "layers", "layout" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L380-L432
train
eventbrite/britecharts
src/charts/stacked-area.js
formatOrder
function formatOrder(totals) { let order = Object.keys(totals) .sort((a, b) => { if (totals[a] > totals[b]) return -1; if (totals[a] === totals[b]) return 0; return 1; }); let otherIndex = order.indexOf...
javascript
function formatOrder(totals) { let order = Object.keys(totals) .sort((a, b) => { if (totals[a] > totals[b]) return -1; if (totals[a] === totals[b]) return 0; return 1; }); let otherIndex = order.indexOf...
[ "function", "formatOrder", "(", "totals", ")", "{", "let", "order", "=", "Object", ".", "keys", "(", "totals", ")", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "{", "if", "(", "totals", "[", "a", "]", ">", "totals", "[", "b", "]", ")", "...
Takes an object with all topics as keys and their aggregate totals as values, sorts them into a list by descending total value and moves "Other" to the end @param {Object} totals Keys of all the topics and their corresponding totals @return {Array} List of topic names in aggregate order
[ "Takes", "an", "object", "with", "all", "topics", "as", "keys", "and", "their", "aggregate", "totals", "as", "values", "sorts", "them", "into", "a", "list", "by", "descending", "total", "value", "and", "moves", "Other", "to", "the", "end" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L441-L459
train
eventbrite/britecharts
src/charts/stacked-area.js
createFakeData
function createFakeData() { const numDays = diffDays(emptyDataConfig.minDate, emptyDataConfig.maxDate) const emptyArray = Array.apply(null, Array(numDays)); isUsingFakeData = true; return [ ...emptyArray.map((el, i) => ({ [dateLabel]:...
javascript
function createFakeData() { const numDays = diffDays(emptyDataConfig.minDate, emptyDataConfig.maxDate) const emptyArray = Array.apply(null, Array(numDays)); isUsingFakeData = true; return [ ...emptyArray.map((el, i) => ({ [dateLabel]:...
[ "function", "createFakeData", "(", ")", "{", "const", "numDays", "=", "diffDays", "(", "emptyDataConfig", ".", "minDate", ",", "emptyDataConfig", ".", "maxDate", ")", "const", "emptyArray", "=", "Array", ".", "apply", "(", "null", ",", "Array", "(", "numDays...
Creates fake data for when data is an empty array @return {array} Fake data built from emptyDataConfig settings
[ "Creates", "fake", "data", "for", "when", "data", "is", "an", "empty", "array" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L504-L523
train
eventbrite/britecharts
src/charts/stacked-area.js
cleanData
function cleanData(originalData) { originalData = originalData.length === 0 ? createFakeData() : originalData; return originalData.reduce((acc, d) => { d.date = new Date(d[dateLabel]), d.value = +d[valueLabel] return [...acc, d]; }, [...
javascript
function cleanData(originalData) { originalData = originalData.length === 0 ? createFakeData() : originalData; return originalData.reduce((acc, d) => { d.date = new Date(d[dateLabel]), d.value = +d[valueLabel] return [...acc, d]; }, [...
[ "function", "cleanData", "(", "originalData", ")", "{", "originalData", "=", "originalData", ".", "length", "===", "0", "?", "createFakeData", "(", ")", ":", "originalData", ";", "return", "originalData", ".", "reduce", "(", "(", "acc", ",", "d", ")", "=>"...
Cleaning data casting the values and dates to the proper type while keeping the rest of properties on the data. It creates fake data is the data is empty. @param {areaChartData} originalData Raw data from the container @return {areaChartData} Parsed data with values and dates @private
[ "Cleaning", "data", "casting", "the", "values", "and", "dates", "to", "the", "proper", "type", "while", "keeping", "the", "rest", "of", "properties", "on", "the", "data", ".", "It", "creates", "fake", "data", "is", "the", "data", "is", "empty", "." ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L532-L541
train
eventbrite/britecharts
src/charts/stacked-area.js
drawEmptyDataLine
function drawEmptyDataLine() { let emptyDataLine = d3Shape.line() .x( (d) => xScale(d.date) ) .y( () => yScale(0) - 1 ); let chartGroup = svg.select('.chart-group'); chartGroup .append('path') .attr('class', 'empty-data-...
javascript
function drawEmptyDataLine() { let emptyDataLine = d3Shape.line() .x( (d) => xScale(d.date) ) .y( () => yScale(0) - 1 ); let chartGroup = svg.select('.chart-group'); chartGroup .append('path') .attr('class', 'empty-data-...
[ "function", "drawEmptyDataLine", "(", ")", "{", "let", "emptyDataLine", "=", "d3Shape", ".", "line", "(", ")", ".", "x", "(", "(", "d", ")", "=>", "xScale", "(", "d", ".", "date", ")", ")", ".", "y", "(", "(", ")", "=>", "yScale", "(", "0", ")"...
Draws an empty line when the data is all zero @private
[ "Draws", "an", "empty", "line", "when", "the", "data", "is", "all", "zero" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L705-L735
train
eventbrite/britecharts
src/charts/stacked-area.js
drawVerticalMarker
function drawVerticalMarker() { // Not ideal, we need to figure out how to call exit for nested elements if (verticalMarkerContainer) { svg.selectAll('.vertical-marker-container').remove(); } verticalMarkerContainer = svg.select('.metadata-group') ...
javascript
function drawVerticalMarker() { // Not ideal, we need to figure out how to call exit for nested elements if (verticalMarkerContainer) { svg.selectAll('.vertical-marker-container').remove(); } verticalMarkerContainer = svg.select('.metadata-group') ...
[ "function", "drawVerticalMarker", "(", ")", "{", "// Not ideal, we need to figure out how to call exit for nested elements", "if", "(", "verticalMarkerContainer", ")", "{", "svg", ".", "selectAll", "(", "'.vertical-marker-container'", ")", ".", "remove", "(", ")", ";", "}...
Creates the vertical marker @return void
[ "Creates", "the", "vertical", "marker" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L855-L880
train
eventbrite/britecharts
src/charts/stacked-area.js
getDataByDate
function getDataByDate(data) { return d3Collection.nest() .key(getDate) .entries( data.sort((a, b) => a.date - b.date) ) .map(d => { return assign({}, d, { date: new Date(d.key) ...
javascript
function getDataByDate(data) { return d3Collection.nest() .key(getDate) .entries( data.sort((a, b) => a.date - b.date) ) .map(d => { return assign({}, d, { date: new Date(d.key) ...
[ "function", "getDataByDate", "(", "data", ")", "{", "return", "d3Collection", ".", "nest", "(", ")", ".", "key", "(", "getDate", ")", ".", "entries", "(", "data", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "a", ".", "date", "-", "b", ".", ...
Orders the data by date for consumption on the chart tooltip @param {areaChartData} data Chart data @return {Object[]} Chart data ordered by date @private
[ "Orders", "the", "data", "by", "date", "for", "consumption", "on", "the", "chart", "tooltip" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L897-L912
train
eventbrite/britecharts
src/charts/stacked-area.js
getMaxValueByDate
function getMaxValueByDate() { let keys = uniq(data.map(o => o.name)); let maxValueByDate = d3Array.max(dataByDateFormatted, function(d){ let vals = keys.map((key) => d[key]); return d3Array.sum(vals); }); return maxValueByDate; }
javascript
function getMaxValueByDate() { let keys = uniq(data.map(o => o.name)); let maxValueByDate = d3Array.max(dataByDateFormatted, function(d){ let vals = keys.map((key) => d[key]); return d3Array.sum(vals); }); return maxValueByDate; }
[ "function", "getMaxValueByDate", "(", ")", "{", "let", "keys", "=", "uniq", "(", "data", ".", "map", "(", "o", "=>", "o", ".", "name", ")", ")", ";", "let", "maxValueByDate", "=", "d3Array", ".", "max", "(", "dataByDateFormatted", ",", "function", "(",...
Computes the maximum sum of values for any date @return {Number} Max value
[ "Computes", "the", "maximum", "sum", "of", "values", "for", "any", "date" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L919-L928
train
eventbrite/britecharts
src/charts/stacked-area.js
setEpsilon
function setEpsilon() { let dates = dataByDate.map(({date}) => date); epsilon = (xScale(dates[1]) - xScale(dates[0])) / 2; }
javascript
function setEpsilon() { let dates = dataByDate.map(({date}) => date); epsilon = (xScale(dates[1]) - xScale(dates[0])) / 2; }
[ "function", "setEpsilon", "(", ")", "{", "let", "dates", "=", "dataByDate", ".", "map", "(", "(", "{", "date", "}", ")", "=>", "date", ")", ";", "epsilon", "=", "(", "xScale", "(", "dates", "[", "1", "]", ")", "-", "xScale", "(", "dates", "[", ...
Epsilon is the value given to the number representing half of the distance in pixels between two date data points @return {Number} half distance between any two points
[ "Epsilon", "is", "the", "value", "given", "to", "the", "number", "representing", "half", "of", "the", "distance", "in", "pixels", "between", "two", "date", "data", "points" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L948-L952
train
eventbrite/britecharts
src/charts/stacked-area.js
handleMouseOver
function handleMouseOver(e, d) { overlay.style('display', 'block'); verticalMarkerLine.classed('bc-is-active', true); dispatcher.call('customMouseOver', e, d, d3Selection.mouse(e)); }
javascript
function handleMouseOver(e, d) { overlay.style('display', 'block'); verticalMarkerLine.classed('bc-is-active', true); dispatcher.call('customMouseOver', e, d, d3Selection.mouse(e)); }
[ "function", "handleMouseOver", "(", "e", ",", "d", ")", "{", "overlay", ".", "style", "(", "'display'", ",", "'block'", ")", ";", "verticalMarkerLine", ".", "classed", "(", "'bc-is-active'", ",", "true", ")", ";", "dispatcher", ".", "call", "(", "'customMo...
Mouseover handler, shows overlay and adds active class to verticalMarkerLine @private
[ "Mouseover", "handler", "shows", "overlay", "and", "adds", "active", "class", "to", "verticalMarkerLine" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L994-L999
train
eventbrite/britecharts
src/charts/stacked-area.js
handleTouchMove
function handleTouchMove(e, d) { dispatcher.call('customTouchMove', e, d, d3Selection.touch(e)); }
javascript
function handleTouchMove(e, d) { dispatcher.call('customTouchMove', e, d, d3Selection.touch(e)); }
[ "function", "handleTouchMove", "(", "e", ",", "d", ")", "{", "dispatcher", ".", "call", "(", "'customTouchMove'", ",", "e", ",", "d", ",", "d3Selection", ".", "touch", "(", "e", ")", ")", ";", "}" ]
Touchmove highlighted points It will only pass the information with the event @private
[ "Touchmove", "highlighted", "points", "It", "will", "only", "pass", "the", "information", "with", "the", "event" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L1006-L1008
train
eventbrite/britecharts
src/charts/stacked-area.js
handleHighlightClick
function handleHighlightClick(e, d) { dispatcher.call('customDataEntryClick', e, d, d3Selection.mouse(e)); }
javascript
function handleHighlightClick(e, d) { dispatcher.call('customDataEntryClick', e, d, d3Selection.mouse(e)); }
[ "function", "handleHighlightClick", "(", "e", ",", "d", ")", "{", "dispatcher", ".", "call", "(", "'customDataEntryClick'", ",", "e", ",", "d", ",", "d3Selection", ".", "mouse", "(", "e", ")", ")", ";", "}" ]
Mouseclick handler over one of the highlight points It will only pass the information with the event @private
[ "Mouseclick", "handler", "over", "one", "of", "the", "highlight", "points", "It", "will", "only", "pass", "the", "information", "with", "the", "event" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/stacked-area.js#L1015-L1017
train
eventbrite/britecharts
src/charts/legend.js
adjustLines
function adjustLines() { let lineWidth = svg.select('.legend-line').node().getBoundingClientRect().width + markerSize; let lineWidthSpace = chartWidth - lineWidth; if (lineWidthSpace <= 0) { splitInLines(); } centerInlineLegendOnSVG(); ...
javascript
function adjustLines() { let lineWidth = svg.select('.legend-line').node().getBoundingClientRect().width + markerSize; let lineWidthSpace = chartWidth - lineWidth; if (lineWidthSpace <= 0) { splitInLines(); } centerInlineLegendOnSVG(); ...
[ "function", "adjustLines", "(", ")", "{", "let", "lineWidth", "=", "svg", ".", "select", "(", "'.legend-line'", ")", ".", "node", "(", ")", ".", "getBoundingClientRect", "(", ")", ".", "width", "+", "markerSize", ";", "let", "lineWidthSpace", "=", "chartWi...
Depending on the size of the horizontal legend, we are going to add a new line with the last entry of the legend @return {void} @private
[ "Depending", "on", "the", "size", "of", "the", "horizontal", "legend", "we", "are", "going", "to", "add", "a", "new", "line", "with", "the", "last", "entry", "of", "the", "legend" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/legend.js#L146-L155
train
eventbrite/britecharts
src/charts/legend.js
buildContainerGroups
function buildContainerGroups() { let container = svg .append('g') .classed('legend-container-group', true) .attr('transform', `translate(${margin.left},${margin.top})`); container .append('g') .classed('legend-group', ...
javascript
function buildContainerGroups() { let container = svg .append('g') .classed('legend-container-group', true) .attr('transform', `translate(${margin.left},${margin.top})`); container .append('g') .classed('legend-group', ...
[ "function", "buildContainerGroups", "(", ")", "{", "let", "container", "=", "svg", ".", "append", "(", "'g'", ")", ".", "classed", "(", "'legend-container-group'", ",", "true", ")", ".", "attr", "(", "'transform'", ",", "`", "${", "margin", ".", "left", ...
Builds containers for the legend Also applies the Margin convention @private
[ "Builds", "containers", "for", "the", "legend", "Also", "applies", "the", "Margin", "convention" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/legend.js#L162-L171
train
eventbrite/britecharts
src/charts/legend.js
centerInlineLegendOnSVG
function centerInlineLegendOnSVG() { let legendGroupSize = svg.select('g.legend-container-group').node().getBoundingClientRect().width + getLineElementMargin(); let emptySpace = width - legendGroupSize; let newXPosition = (emptySpace/2); if (emptySpace > 0) { ...
javascript
function centerInlineLegendOnSVG() { let legendGroupSize = svg.select('g.legend-container-group').node().getBoundingClientRect().width + getLineElementMargin(); let emptySpace = width - legendGroupSize; let newXPosition = (emptySpace/2); if (emptySpace > 0) { ...
[ "function", "centerInlineLegendOnSVG", "(", ")", "{", "let", "legendGroupSize", "=", "svg", ".", "select", "(", "'g.legend-container-group'", ")", ".", "node", "(", ")", ".", "getBoundingClientRect", "(", ")", ".", "width", "+", "getLineElementMargin", "(", ")",...
Centers the legend on the chart given that is a single line of labels @return {void} @private
[ "Centers", "the", "legend", "on", "the", "chart", "given", "that", "is", "a", "single", "line", "of", "labels" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/legend.js#L207-L216
train
eventbrite/britecharts
src/charts/legend.js
centerVerticalLegendOnSVG
function centerVerticalLegendOnSVG() { let legendGroupSize = svg.select('g.legend-container-group').node().getBoundingClientRect().width; let emptySpace = width - legendGroupSize; let newXPosition = (emptySpace / 2) - (legendGroupSize / 2); if (emptySpace > 0) { ...
javascript
function centerVerticalLegendOnSVG() { let legendGroupSize = svg.select('g.legend-container-group').node().getBoundingClientRect().width; let emptySpace = width - legendGroupSize; let newXPosition = (emptySpace / 2) - (legendGroupSize / 2); if (emptySpace > 0) { ...
[ "function", "centerVerticalLegendOnSVG", "(", ")", "{", "let", "legendGroupSize", "=", "svg", ".", "select", "(", "'g.legend-container-group'", ")", ".", "node", "(", ")", ".", "getBoundingClientRect", "(", ")", ".", "width", ";", "let", "emptySpace", "=", "wi...
Centers the legend on the chart given that is a stack of labels @return {void} @private
[ "Centers", "the", "legend", "on", "the", "chart", "given", "that", "is", "a", "stack", "of", "labels" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/legend.js#L223-L232
train
eventbrite/britecharts
src/charts/legend.js
cleanData
function cleanData(data) { hasQuantities = data.filter(hasQuantity).length === data.length; return data .reduce((acc, d) => { if (d.quantity !== undefined && d.quantity !== null) { d.quantity = +d.quantity; } ...
javascript
function cleanData(data) { hasQuantities = data.filter(hasQuantity).length === data.length; return data .reduce((acc, d) => { if (d.quantity !== undefined && d.quantity !== null) { d.quantity = +d.quantity; } ...
[ "function", "cleanData", "(", "data", ")", "{", "hasQuantities", "=", "data", ".", "filter", "(", "hasQuantity", ")", ".", "length", "===", "data", ".", "length", ";", "return", "data", ".", "reduce", "(", "(", "acc", ",", "d", ")", "=>", "{", "if", ...
Makes sure the types of the data are right and checks if it has quantities @param {LegendChartData} data @private
[ "Makes", "sure", "the", "types", "of", "the", "data", "are", "right", "and", "checks", "if", "it", "has", "quantities" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/legend.js#L239-L252
train
eventbrite/britecharts
src/charts/legend.js
drawHorizontalLegend
function drawHorizontalLegend() { let xOffset = markerSize; svg.select('.legend-group') .selectAll('g') .remove(); // We want a single line svg.select('.legend-group') .append('g') .classed('legend-line', tru...
javascript
function drawHorizontalLegend() { let xOffset = markerSize; svg.select('.legend-group') .selectAll('g') .remove(); // We want a single line svg.select('.legend-group') .append('g') .classed('legend-line', tru...
[ "function", "drawHorizontalLegend", "(", ")", "{", "let", "xOffset", "=", "markerSize", ";", "svg", ".", "select", "(", "'.legend-group'", ")", ".", "selectAll", "(", "'g'", ")", ".", "remove", "(", ")", ";", "// We want a single line", "svg", ".", "select",...
Draws the entries of the legend within a single line @private
[ "Draws", "the", "entries", "of", "the", "legend", "within", "a", "single", "line" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/legend.js#L268-L327
train
eventbrite/britecharts
src/charts/legend.js
drawVerticalLegend
function drawVerticalLegend() { svg.select('.legend-group') .selectAll('g') .remove(); entries = svg.select('.legend-group') .selectAll('g.legend-line') .data(data); // Enter entries.enter() ....
javascript
function drawVerticalLegend() { svg.select('.legend-group') .selectAll('g') .remove(); entries = svg.select('.legend-group') .selectAll('g.legend-line') .data(data); // Enter entries.enter() ....
[ "function", "drawVerticalLegend", "(", ")", "{", "svg", ".", "select", "(", "'.legend-group'", ")", ".", "selectAll", "(", "'g'", ")", ".", "remove", "(", ")", ";", "entries", "=", "svg", ".", "select", "(", "'.legend-group'", ")", ".", "selectAll", "(",...
Draws the entries of the legend @private
[ "Draws", "the", "entries", "of", "the", "legend" ]
0767051287e9e7211e610b1b13244da71e8e355e
https://github.com/eventbrite/britecharts/blob/0767051287e9e7211e610b1b13244da71e8e355e/src/charts/legend.js#L333-L388
train