File flotr.js
has 2424 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* $Id$ */
/**
* @projectDescription Flotr is a javascript plotting library based on the Prototype Javascript Framework.
* @author Bas Wenneker
* @license MIT License <http://www.opensource.org/licenses/mit-license.php>
Function drawLabels
has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring. Open
drawLabels: function(){
// Construct fixed width label boxes, which can be styled easily.
var noLabels = 0, axis,
xBoxWidth, i, html, tick,
options = this.options,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function insertLegend
has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring. Open
insertLegend: function(){
if(!this.options.legend.show)
return;
var series = this.series,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function hit
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
hit: function(mouse){
var series = this.series,
options = this.options,
prevHit = this.prevHit,
plotOffset = this.plotOffset,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Graph
has 59 functions (exceeds 20 allowed). Consider refactoring. Open
Flotr.Graph = Class.create({
/**
* Flotr Graph constructor.
* @param {Element} el - element to insert the graph into
* @param {Object} data - an array or object of dataseries
Function setOptions
has 204 lines of code (exceeds 25 allowed). Consider refactoring. Open
setOptions: function(opts){
var options = {
colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.
title: null,
subtitle: null,
Function extendXRangeIfNeededByBar
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
extendXRangeIfNeededByBar: function(axis){
if(axis.options.max == null){
var newmin = axis.min,
newmax = axis.max,
i, s, b, c,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function plotBars
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
plotBars: function(series, barWidth, offset, fill){
var data = series.data;
if(data.length < 1) return;
var xa = series.xaxis,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function plotLine
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
plotLine: function(series, offset){
var ctx = this.ctx,
xa = series.xaxis,
ya = series.yaxis,
tHoz = this.tHoz.bind(this),
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function plotLineArea
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
plotLineArea: function(series, offset){
var data = series.data;
if(data.length < 2) return;
var top, lastX = 0,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function findDataRanges
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
findDataRanges: function(){
var s = this.series,
a = this.axes;
a.x.datamin = a.x.datamax =
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function drawLabels
has 139 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawLabels: function(){
// Construct fixed width label boxes, which can be styled easily.
var noLabels = 0, axis,
xBoxWidth, i, html, tick,
options = this.options,
Function extendYRangeIfNeededByBar
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
extendYRangeIfNeededByBar: function(axis){
if(axis.options.max == null){
var newmax = axis.max,
i, s, b, c,
stackedSums = {},
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function setOptions
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
setOptions: function(opts){
var options = {
colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.
title: null,
subtitle: null,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function constructDataGrid
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
constructDataGrid: function(){
// If the data grid has already been built, nothing to do here
if (this.datagrid) return this.datagrid;
var i, j,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function drawSeriesPie
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawSeriesPie: function(series) {
if (this.options.pie.drawn) return;
var ctx = this.ctx,
options = this.options,
Function insertLegend
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
insertLegend: function(){
if(!this.options.legend.show)
return;
var series = this.series,
Function hit
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
hit: function(mouse){
var series = this.series,
options = this.options,
prevHit = this.prevHit,
plotOffset = this.plotOffset,
Function plotBarsShadows
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
plotBarsShadows: function(series, barWidth, offset){
var data = series.data;
if(data.length < 1) return;
var xa = series.xaxis,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function drawTitles
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
drawTitles: function(){
var html,
options = this.options,
margin = options.grid.labelMargin,
ctx = this.ctx,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function drawTitles
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawTitles: function(){
var html,
options = this.options,
margin = options.grid.labelMargin,
ctx = this.ctx,
Consider simplifying this complex logical expression. Open
if (!options.HtmlText && this.textEnabled) {
var style = {
size: options.fontSize,
adjustAlign: true
};
Function plotLineArea
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
plotLineArea: function(series, offset){
var data = series.data;
if(data.length < 2) return;
var top, lastX = 0,
Function calculateTicks
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
calculateTicks: function(axis){
var o = axis.options, i, v;
axis.ticks = [];
if(o.ticks){
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function drawGrid
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
drawGrid: function(){
var v, o = this.options,
ctx = this.ctx;
if(o.grid.verticalLines || o.grid.horizontalLines){
this.el.fire('flotr:beforegrid', [this.axes.x, this.axes.y, o, this]);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function plotLine
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
plotLine: function(series, offset){
var ctx = this.ctx,
xa = series.xaxis,
ya = series.yaxis,
tHoz = this.tHoz.bind(this),
Function plotBars
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
plotBars: function(series, barWidth, offset, fill){
var data = series.data;
if(data.length < 1) return;
var xa = series.xaxis,
Function plotCandles
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
plotCandles: function(series, offset){
var data = series.data;
if(data.length < 1) return;
var xa = series.xaxis,
Function constructDataGrid
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructDataGrid: function(){
// If the data grid has already been built, nothing to do here
if (this.datagrid) return this.datagrid;
var i, j,
Function calculateRange
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
calculateRange: function(axis){
var o = axis.options,
min = o.min != null ? o.min : axis.datamin,
max = o.max != null ? o.max : axis.datamax,
margin;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function plotCandles
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
plotCandles: function(series, offset){
var data = series.data;
if(data.length < 1) return;
var xa = series.xaxis,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function calculateSpacing
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateSpacing: function(){
var a = this.axes,
options = this.options,
series = this.series,
margin = options.grid.labelMargin,
Function generator
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
generator: function(axis) {
var ticks = [],
tickSize = axis.tickSize[0], unit = axis.tickSize[1],
d = new Date(axis.min),
step = tickSize * timeUnitSize[unit];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function findDataRanges
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
findDataRanges: function(){
var s = this.series,
a = this.axes;
a.x.datamin = a.x.datamax =
Function drawGrid
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawGrid: function(){
var v, o = this.options,
ctx = this.ctx;
if(o.grid.verticalLines || o.grid.horizontalLines){
this.el.fire('flotr:beforegrid', [this.axes.x, this.axes.y, o, this]);
Function generator
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
generator: function(axis) {
var ticks = [],
tickSize = axis.tickSize[0], unit = axis.tickSize[1],
d = new Date(axis.min),
step = tickSize * timeUnitSize[unit];
Function drawHit
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawHit: function(n){
var octx = this.octx,
s = n.series,
tHoz = this.tHoz.bind(this),
tVert = this.tVert.bind(this);
Function format
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
format: function(d, format) {
if (!d) return;
var leftPad = function(n) {
n = n.toString();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extendXRangeIfNeededByBar
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
extendXRangeIfNeededByBar: function(axis){
if(axis.options.max == null){
var newmin = axis.min,
newmax = axis.max,
i, s, b, c,
Function plotBarsShadows
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
plotBarsShadows: function(series, barWidth, offset){
var data = series.data;
if(data.length < 1) return;
var xa = series.xaxis,
Function calculateSpacing
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
calculateSpacing: function(){
var a = this.axes,
options = this.options,
series = this.series,
margin = options.grid.labelMargin,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function drawCrosshair
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawCrosshair: function(pos) {
var octx = this.octx,
options = this.options,
plotOffset = this.plotOffset,
x = plotOffset.left+pos.relX+0.5,
Consider simplifying this complex logical expression. Open
if(event.pageX == null && event.clientX != null){
var de = document.documentElement, b = document.body;
ax = event.clientX + (de && de.scrollLeft || b.scrollLeft || 0);
ay = event.clientY + (de && de.scrollTop || b.scrollTop || 0);
}else{
Function constructCanvas
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructCanvas: function(){
var el = this.el,
size, c, oc;
// The old canvases are retrieved to avoid memory leaks ...
Function calculateTicks
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateTicks: function(axis){
var o = axis.options, i, v;
axis.ticks = [];
if(o.ticks){
Function format
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
format: function(d, format) {
if (!d) return;
var leftPad = function(n) {
n = n.toString();
Function extendYRangeIfNeededByBar
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
extendYRangeIfNeededByBar: function(axis){
if(axis.options.max == null){
var newmax = axis.max,
i, s, b, c,
stackedSums = {},
Function calculateRange
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateRange: function(axis){
var o = axis.options,
min = o.min != null ? o.min : axis.datamin,
max = o.max != null ? o.max : axis.datamax,
margin;
Function drawSeriesLines
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawSeriesLines: function(series){
series = series || this.series;
var ctx = this.ctx;
ctx.save();
ctx.translate(this.plotOffset.left, this.plotOffset.top);
Function drawSelection
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
drawSelection: function() {
var prevSelection = this.prevSelection,
selection = this.selection,
octx = this.octx,
options = this.options,
Consider simplifying this complex logical expression. Open
if(((!s.bars.show) && xdiff < xsens && ydiff < ysens) ||
(s.bars.show && xdiff < s.bars.barWidth/2 && my > ya.min && my < y)){
var distance = Math.sqrt(xdiff*xdiff + ydiff*ydiff);
if(distance < n.dist){
n.dist = distance;
Function formatter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
formatter: function (v, axis) {
var d = new Date(v);
// first check global format
if (axis.options.timeformat != null)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function convertToBytes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
convertToBytes: function(value, precision, base){
var sizes = ['Y','Z','E','P','T','G','M','k',''],
fractionSizes = ['y','z','a','f','p','n','µ','m',''],
total = sizes.length;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function parseColor
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
parseColor: function(str){
if (str instanceof Flotr.Color) return str;
var result, Color = Flotr.Color;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function downloadCSV
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
downloadCSV: function(){
var i, csv = '"x"',
series = this.series,
dg = this.loadDataGrid();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function plotSlice
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
plotSlice: function(x, y, radius, startAngle, endAngle, fill, vScale) {
Avoid deeply nested control flow statements. Open
for(j = 1; j < data[h].length; j++){
y = data[h][j];
if(y < yaxis.datamin) yaxis.datamin = y;
else if(y > yaxis.datamax) yaxis.datamax = y;
}
Avoid deeply nested control flow statements. Open
if (!b.horizontal && (b.barWidth + axis.datamax > newmax))
newmax = axis.max + (b.centered ? b.barWidth/2 : b.barWidth);
Function drawHit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
drawHit: function(n){
var octx = this.octx,
s = n.series,
tHoz = this.tHoz.bind(this),
tVert = this.tVert.bind(this);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function plotCandlesShadows
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
plotCandlesShadows: function(series, offset){
var data = series.data;
if(data.length < 1 || series.candles.barcharts) return;
var xa = series.xaxis,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if (!tick.label || tick.label.length == 0 ||
(this.plotOffset.top + this.tVert(tick.v, axis) < 0) ||
(this.plotOffset.top + this.tVert(tick.v, axis) > this.canvasHeight)) continue;
Function drawSeriesPie
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
drawSeriesPie: function(series) {
if (this.options.pie.drawn) return;
var ctx = this.ctx,
options = this.options,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
for (j = 0; j < s.data.length; j++) {
if (s.bars.show && s.bars.stacked) {
var x = s.data[j][0]+'';
stackedSums[x] = (stackedSums[x] || 0) + s.data[j][1];
lastSerie = s;
Function setSelectionPos
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
setSelectionPos: function(pos, event) {
var options = this.options,
offset = $(this.overlay).cumulativeOffset();
if(options.selection.mode.indexOf('x') == -1){
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if(!tick.label || tick.label.length == 0 ||
(this.plotOffset.left + this.tHoz(tick.v, axis) < 0) ||
(this.plotOffset.left + this.tHoz(tick.v, axis) > this.canvasWidth)) continue;
Avoid deeply nested control flow statements. Open
if(p.charAt(0) == 'n') pos += 'top:' + (m + plotOffset.top) + 'px;';
else if(p.charAt(0) == 's') pos += 'bottom:' + (m + plotOffset.bottom) + 'px;';
Avoid deeply nested control flow statements. Open
if (tick) label = tick[1];
Avoid deeply nested control flow statements. Open
if(x < xaxis.datamin) xaxis.datamin = x;
else if(x > xaxis.datamax) xaxis.datamax = x;
Avoid deeply nested control flow statements. Open
for (var j in stackedSums) {
newmax = Math.max(stackedSums[j], newmax);
}
Avoid deeply nested control flow statements. Open
if(options.legend.backgroundOpacity != 0.0){
/**
* Put in the transparent background separately to avoid blended labels and
* label boxes.
*/
Avoid deeply nested control flow statements. Open
if(b.stacked && b.horizontal){
for (j = 0; j < s.data.length; j++) {
if (b.show && b.stacked) {
var x = s.data[j][0]+'';
stackedSums[x] = (stackedSums[x] || 0) + s.data[j][1];
Avoid deeply nested control flow statements. Open
if(!tick.label || tick.label.length == 0 ||
(this.plotOffset.left + this.tHoz(tick.v, axis) < 0) ||
(this.plotOffset.left + this.tHoz(tick.v, axis) > this.canvasWidth)) continue;
Avoid deeply nested control flow statements. Open
if (!tick.label || tick.label.length == 0 ||
(this.plotOffset.top + this.tVert(tick.v, axis) < 0) ||
(this.plotOffset.top + this.tVert(tick.v, axis) > this.canvasHeight)) continue;
Avoid deeply nested control flow statements. Open
if(p.charAt(1) == 'e') pos += 'right:' + (m + plotOffset.right) + 'px;';
else if(p.charAt(1) == 'w') pos += 'left:' + (m + plotOffset.left) + 'px;';
Consider simplifying this complex logical expression. Open
if (!options.HtmlText && this.textEnabled) {
var style = {
size: options.fontSize*1.1,
color: options.grid.color
};
Consider simplifying this complex logical expression. Open
if(n.series && (n.mouse && n.mouse.track && !prevHit || (prevHit /*&& (n.x != prevHit.x || n.y != prevHit.y)*/))){
var mt = this.mouseTrack || this.el.select(".flotr-mouse-value")[0],
pos = '',
s = n.series,
p = n.mouse.position,
Consider simplifying this complex logical expression. Open
if ((doc = node.ownerDocument) && (win = doc.defaultView) &&
win.getSelection && doc.createRange &&
(selection = window.getSelection()) &&
selection.removeAllRanges) {
range = doc.createRange();
Function drawSeriesLines
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
drawSeriesLines: function(series){
series = series || this.series;
var ctx = this.ctx;
ctx.save();
ctx.translate(this.plotOffset.left, this.plotOffset.top);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getSeries
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
getSeries: function(data){
return data.collect(function(serie){
var i;
serie = (serie.data) ? Object.clone(serie) : {'data': serie};
for (i = serie.data.length-1; i > -1; --i) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function merge
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
merge: function(src, dest){
var result = dest || {};
for(var i in src){
result[i] = (src[i] != null && typeof(src[i]) == 'object' && !(src[i].constructor == Array || src[i].constructor == RegExp) && !Object.isElement(src[i])) ? Flotr.merge(src[i], dest[i]) : result[i] = src[i];
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return new Color(parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16));
Avoid too many return
statements within this function. Open
return new Color(parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16));
Avoid too many return
statements within this function. Open
return new Color(255, 255, 255, 0);
Avoid too many return
statements within this function. Open
return ((result = Color.lookupColors[name])) ? new Color(result[0], result[1], result[2]) : false;
Avoid too many return
statements within this function. Open
return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55, parseFloat(result[4]));
Function getTickSize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getTickSize: function(noTicks, min, max, decimals){
var delta = (max - min) / noTicks;
var magn = Flotr.getMagnitude(delta);
// Norm is between 1.0 and 10.0.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getEventPosition
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getEventPosition: function (event){
var offset = this.overlay.cumulativeOffset(),
rx = (event.pageX - offset.left - this.plotOffset.left),
ry = (event.pageY - offset.top - this.plotOffset.top),
ax = 0, ay = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function drawSeries
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
drawSeries: function(series){
series = series || this.series;
var drawn = false;
for(var type in Flotr._registeredTypes){
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function draw
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
draw: function() {
this.drawGrid();
this.drawLabels();
this.drawTitles();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
Flotr.Graph = Class.create({
/**
* Flotr Graph constructor.
* @param {Element} el - element to insert the graph into
* @param {Object} data - an array or object of dataseries
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 33815.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
var Flotr = {
version: '%version%',
author: 'Bas Wenneker',
website: 'http://www.solutoire.com',
/**
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 1630.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
Flotr.Date = {
format: function(d, format) {
if (!d) return;
var leftPad = function(n) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 1610.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
Flotr.Color = Class.create({
initialize: function(r, g, b, a){
this.rgba = ['r','g','b','a'];
var x = 4;
while(-1<--x){
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 677.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
Flotr.Color.lookupColors = {
aqua:[0,255,255],
azure:[240,255,255],
beige:[245,245,220],
black:[0,0,0],
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 405.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76