import { ChartInternal } from './core' import { isFunction, sanitise } from './util' ChartInternal.prototype.isStanfordGraphType = function() { var $$ = this return $$.config.data_type === 'stanford' } ChartInternal.prototype.initStanfordData = function() { var $$ = this, d3 = $$.d3, config = $$.config, target = $$.data.targets[0], epochs, maxEpochs, minEpochs // Make larger values appear on top target.values.sort(compareEpochs) // Get array of epochs epochs = target.values.map(a => a.epochs) minEpochs = !isNaN(config.stanford_scaleMin) ? config.stanford_scaleMin : d3.min(epochs) maxEpochs = !isNaN(config.stanford_scaleMax) ? config.stanford_scaleMax : d3.max(epochs) if (minEpochs > maxEpochs) { throw Error('Number of minEpochs has to be smaller than maxEpochs') } target.colors = isFunction(config.stanford_colors) ? config.stanford_colors : d3.interpolateHslLong(d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)) target.colorscale = d3 .scaleSequentialLog(target.colors) .domain([minEpochs, maxEpochs]) target.minEpochs = minEpochs target.maxEpochs = maxEpochs } ChartInternal.prototype.getStanfordPointColor = function(d) { var $$ = this, target = $$.data.targets[0] return target.colorscale(d.epochs) } // http://jsfiddle.net/Xotic750/KtzLq/ ChartInternal.prototype.getCentroid = function(points) { var area = getRegionArea(points) var x = 0, y = 0, i, j, f, point1, point2 for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { point1 = points[i] point2 = points[j] f = point1.x * point2.y - point2.x * point1.y x += (point1.x + point2.x) * f y += (point1.y + point2.y) * f } f = area * 6 return { x: x / f, y: y / f } } ChartInternal.prototype.getStanfordTooltipTitle = function(d) { var $$ = this, labelX = $$.axis.getLabelText('x'), labelY = $$.axis.getLabelText('y') return `