12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576 |
- (function (Highcharts, UNDEFINED) {
- var arrayMin = Highcharts.arrayMin,
- arrayMax = Highcharts.arrayMax,
- each = Highcharts.each,
- extend = Highcharts.extend,
- merge = Highcharts.merge,
- map = Highcharts.map,
- pick = Highcharts.pick,
- pInt = Highcharts.pInt,
- defaultPlotOptions = Highcharts.getOptions().plotOptions,
- seriesTypes = Highcharts.seriesTypes,
- extendClass = Highcharts.extendClass,
- splat = Highcharts.splat,
- wrap = Highcharts.wrap,
- Axis = Highcharts.Axis,
- Tick = Highcharts.Tick,
- Point = Highcharts.Point,
- Pointer = Highcharts.Pointer,
- CenteredSeriesMixin = Highcharts.CenteredSeriesMixin,
- TrackerMixin = Highcharts.TrackerMixin,
- Series = Highcharts.Series,
- math = Math,
- mathRound = math.round,
- mathFloor = math.floor,
- mathMax = math.max,
- Color = Highcharts.Color,
- noop = function () {};
- function Pane(options, chart, firstAxis) {
- this.init.call(this, options, chart, firstAxis);
- }
- extend(Pane.prototype, {
-
-
- init: function (options, chart, firstAxis) {
- var pane = this,
- backgroundOption,
- defaultOptions = pane.defaultOptions;
-
- pane.chart = chart;
-
-
- if (chart.angular) {
- defaultOptions.background = {};
- }
- pane.options = options = merge(defaultOptions, options);
-
- backgroundOption = options.background;
-
-
-
- if (backgroundOption) {
- each([].concat(splat(backgroundOption)).reverse(), function (config) {
- var backgroundColor = config.backgroundColor;
- config = merge(pane.defaultBackgroundOptions, config);
- if (backgroundColor) {
- config.backgroundColor = backgroundColor;
- }
- config.color = config.backgroundColor;
- firstAxis.options.plotBands.unshift(config);
- });
- }
- },
-
-
- defaultOptions: {
-
- center: ['50%', '50%'],
- size: '85%',
- startAngle: 0
-
- },
-
-
- defaultBackgroundOptions: {
- shape: 'circle',
- borderWidth: 1,
- borderColor: 'silver',
- backgroundColor: {
- linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
- stops: [
- [0, '#FFF'],
- [1, '#DDD']
- ]
- },
- from: -Number.MAX_VALUE,
- innerRadius: 0,
- to: Number.MAX_VALUE,
- outerRadius: '105%'
- }
-
- });
- var axisProto = Axis.prototype,
- tickProto = Tick.prototype;
-
- var hiddenAxisMixin = {
- getOffset: noop,
- redraw: function () {
- this.isDirty = false;
- },
- render: function () {
- this.isDirty = false;
- },
- setScale: noop,
- setCategories: noop,
- setTitle: noop
- };
- var radialAxisMixin = {
- isRadial: true,
-
-
- defaultRadialGaugeOptions: {
- labels: {
- align: 'center',
- x: 0,
- y: null
- },
- minorGridLineWidth: 0,
- minorTickInterval: 'auto',
- minorTickLength: 10,
- minorTickPosition: 'inside',
- minorTickWidth: 1,
- tickLength: 10,
- tickPosition: 'inside',
- tickWidth: 2,
- title: {
- rotation: 0
- },
- zIndex: 2
- },
-
-
- defaultRadialXOptions: {
- gridLineWidth: 1,
- labels: {
- align: null,
- distance: 15,
- x: 0,
- y: null
- },
- maxPadding: 0,
- minPadding: 0,
- showLastLabel: false,
- tickLength: 0
- },
-
-
- defaultRadialYOptions: {
- gridLineInterpolation: 'circle',
- labels: {
- align: 'right',
- x: -3,
- y: -2
- },
- showLastLabel: false,
- title: {
- x: 4,
- text: null,
- rotation: 90
- }
- },
-
-
- setOptions: function (userOptions) {
-
- var options = this.options = merge(
- this.defaultOptions,
- this.defaultRadialOptions,
- userOptions
- );
-
- if (!options.plotBands) {
- options.plotBands = [];
- }
-
- },
-
-
- getOffset: function () {
-
- axisProto.getOffset.call(this);
-
-
- this.chart.axisOffset[this.side] = 0;
-
-
- this.center = this.pane.center = CenteredSeriesMixin.getCenter.call(this.pane);
- },
-
- getLinePath: function (lineWidth, radius) {
- var center = this.center;
- radius = pick(radius, center[2] / 2 - this.offset);
-
- return this.chart.renderer.symbols.arc(
- this.left + center[0],
- this.top + center[1],
- radius,
- radius,
- {
- start: this.startAngleRad,
- end: this.endAngleRad,
- open: true,
- innerR: 0
- }
- );
- },
-
- setAxisTranslation: function () {
-
-
- axisProto.setAxisTranslation.call(this);
-
-
- if (this.center) {
- if (this.isCircular) {
-
- this.transA = (this.endAngleRad - this.startAngleRad) /
- ((this.max - this.min) || 1);
-
-
- } else {
- this.transA = (this.center[2] / 2) / ((this.max - this.min) || 1);
- }
-
- if (this.isXAxis) {
- this.minPixelPadding = this.transA * this.minPointOffset;
- } else {
-
-
- this.minPixelPadding = 0;
- }
- }
- },
-
-
- beforeSetTickPositions: function () {
- if (this.autoConnect) {
- this.max += (this.categories && 1) || this.pointRange || this.closestPointRange || 0;
- }
- },
-
-
- setAxisSize: function () {
-
- axisProto.setAxisSize.call(this);
- if (this.isRadial) {
-
- this.center = this.pane.center = Highcharts.CenteredSeriesMixin.getCenter.call(this.pane);
-
- if (this.isCircular) {
- this.sector = this.endAngleRad - this.startAngleRad;
- }
-
-
- this.len = this.width = this.height = this.center[2] * pick(this.sector, 1) / 2;
- }
- },
-
-
- getPosition: function (value, length) {
- return this.postTranslate(
- this.isCircular ? this.translate(value) : 0,
- pick(this.isCircular ? length : this.translate(value), this.center[2] / 2) - this.offset
- );
- },
-
-
- postTranslate: function (angle, radius) {
-
- var chart = this.chart,
- center = this.center;
-
- angle = this.startAngleRad + angle;
- return {
- x: chart.plotLeft + center[0] + Math.cos(angle) * radius,
- y: chart.plotTop + center[1] + Math.sin(angle) * radius
- };
-
- },
-
-
- getPlotBandPath: function (from, to, options) {
- var center = this.center,
- startAngleRad = this.startAngleRad,
- fullRadius = center[2] / 2,
- radii = [
- pick(options.outerRadius, '100%'),
- options.innerRadius,
- pick(options.thickness, 10)
- ],
- percentRegex = /%$/,
- start,
- end,
- open,
- isCircular = this.isCircular,
- ret;
-
-
- if (this.options.gridLineInterpolation === 'polygon') {
- ret = this.getPlotLinePath(from).concat(this.getPlotLinePath(to, true));
-
-
- } else {
-
-
- if (!isCircular) {
- radii[0] = this.translate(from);
- radii[1] = this.translate(to);
- }
-
-
- radii = map(radii, function (radius) {
- if (percentRegex.test(radius)) {
- radius = (pInt(radius, 10) * fullRadius) / 100;
- }
- return radius;
- });
-
-
- if (options.shape === 'circle' || !isCircular) {
- start = -Math.PI / 2;
- end = Math.PI * 1.5;
- open = true;
- } else {
- start = startAngleRad + this.translate(from);
- end = startAngleRad + this.translate(to);
- }
-
-
- ret = this.chart.renderer.symbols.arc(
- this.left + center[0],
- this.top + center[1],
- radii[0],
- radii[0],
- {
- start: start,
- end: end,
- innerR: pick(radii[1], radii[0] - radii[2]),
- open: open
- }
- );
- }
-
- return ret;
- },
-
-
- getPlotLinePath: function (value, reverse) {
- var axis = this,
- center = axis.center,
- chart = axis.chart,
- end = axis.getPosition(value),
- xAxis,
- xy,
- tickPositions,
- ret;
-
-
- if (axis.isCircular) {
- ret = ['M', center[0] + chart.plotLeft, center[1] + chart.plotTop, 'L', end.x, end.y];
-
-
- } else if (axis.options.gridLineInterpolation === 'circle') {
- value = axis.translate(value);
- if (value) {
- ret = axis.getLinePath(0, value);
- }
-
- } else {
-
- each(chart.xAxis, function (a) {
- if (a.pane === axis.pane) {
- xAxis = a;
- }
- });
- ret = [];
- value = axis.translate(value);
- tickPositions = xAxis.tickPositions;
- if (xAxis.autoConnect) {
- tickPositions = tickPositions.concat([tickPositions[0]]);
- }
-
- if (reverse) {
- tickPositions = [].concat(tickPositions).reverse();
- }
-
- each(tickPositions, function (pos, i) {
- xy = xAxis.getPosition(pos, value);
- ret.push(i ? 'L' : 'M', xy.x, xy.y);
- });
-
- }
- return ret;
- },
-
-
- getTitlePosition: function () {
- var center = this.center,
- chart = this.chart,
- titleOptions = this.options.title;
-
- return {
- x: chart.plotLeft + center[0] + (titleOptions.x || 0),
- y: chart.plotTop + center[1] - ({ high: 0.5, middle: 0.25, low: 0 }[titleOptions.align] *
- center[2]) + (titleOptions.y || 0)
- };
- }
-
- };
- wrap(axisProto, 'init', function (proceed, chart, userOptions) {
- var axis = this,
- angular = chart.angular,
- polar = chart.polar,
- isX = userOptions.isX,
- isHidden = angular && isX,
- isCircular,
- startAngleRad,
- endAngleRad,
- options,
- chartOptions = chart.options,
- paneIndex = userOptions.pane || 0,
- pane,
- paneOptions;
-
-
- if (angular) {
- extend(this, isHidden ? hiddenAxisMixin : radialAxisMixin);
- isCircular = !isX;
- if (isCircular) {
- this.defaultRadialOptions = this.defaultRadialGaugeOptions;
- }
-
- } else if (polar) {
-
- extend(this, radialAxisMixin);
- isCircular = isX;
- this.defaultRadialOptions = isX ? this.defaultRadialXOptions : merge(this.defaultYAxisOptions, this.defaultRadialYOptions);
-
- }
-
-
- proceed.call(this, chart, userOptions);
-
- if (!isHidden && (angular || polar)) {
- options = this.options;
-
-
- if (!chart.panes) {
- chart.panes = [];
- }
- this.pane = pane = chart.panes[paneIndex] = chart.panes[paneIndex] || new Pane(
- splat(chartOptions.pane)[paneIndex],
- chart,
- axis
- );
- paneOptions = pane.options;
-
-
-
- chart.inverted = false;
- chartOptions.chart.zoomType = null;
-
-
-
-
- this.startAngleRad = startAngleRad = (paneOptions.startAngle - 90) * Math.PI / 180;
- this.endAngleRad = endAngleRad = (pick(paneOptions.endAngle, paneOptions.startAngle + 360) - 90) * Math.PI / 180;
- this.offset = options.offset || 0;
-
- this.isCircular = isCircular;
-
-
- if (isCircular && userOptions.max === UNDEFINED && endAngleRad - startAngleRad === 2 * Math.PI) {
- this.autoConnect = true;
- }
- }
-
- });
-
- wrap(tickProto, 'getPosition', function (proceed, horiz, pos, tickmarkOffset, old) {
- var axis = this.axis;
-
- return axis.getPosition ?
- axis.getPosition(pos) :
- proceed.call(this, horiz, pos, tickmarkOffset, old);
- });
-
- wrap(tickProto, 'getLabelPosition', function (proceed, x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
- var axis = this.axis,
- optionsY = labelOptions.y,
- ret,
- align = labelOptions.align,
- angle = ((axis.translate(this.pos) + axis.startAngleRad + Math.PI / 2) / Math.PI * 180) % 360;
- if (axis.isRadial) {
- ret = axis.getPosition(this.pos, (axis.center[2] / 2) + pick(labelOptions.distance, -25));
-
-
- if (labelOptions.rotation === 'auto') {
- label.attr({
- rotation: angle
- });
-
-
- } else if (optionsY === null) {
- optionsY = axis.chart.renderer.fontMetrics(label.styles.fontSize).b - label.getBBox().height / 2;
- }
-
-
- if (align === null) {
- if (axis.isCircular) {
- if (angle > 20 && angle < 160) {
- align = 'left';
- } else if (angle > 200 && angle < 340) {
- align = 'right';
- } else {
- align = 'center';
- }
- } else {
- align = 'center';
- }
- label.attr({
- align: align
- });
- }
-
- ret.x += labelOptions.x;
- ret.y += optionsY;
-
- } else {
- ret = proceed.call(this, x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
- }
- return ret;
- });
- wrap(tickProto, 'getMarkPath', function (proceed, x, y, tickLength, tickWidth, horiz, renderer) {
- var axis = this.axis,
- endPoint,
- ret;
-
- if (axis.isRadial) {
- endPoint = axis.getPosition(this.pos, axis.center[2] / 2 + tickLength);
- ret = [
- 'M',
- x,
- y,
- 'L',
- endPoint.x,
- endPoint.y
- ];
- } else {
- ret = proceed.call(this, x, y, tickLength, tickWidth, horiz, renderer);
- }
- return ret;
- });
- defaultPlotOptions.arearange = merge(defaultPlotOptions.area, {
- lineWidth: 1,
- marker: null,
- threshold: null,
- tooltip: {
- pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
- },
- trackByArea: true,
- dataLabels: {
- align: null,
- verticalAlign: null,
- xLow: 0,
- xHigh: 0,
- yLow: 0,
- yHigh: 0
- },
- states: {
- hover: {
- halo: false
- }
- }
- });
- seriesTypes.arearange = extendClass(seriesTypes.area, {
- type: 'arearange',
- pointArrayMap: ['low', 'high'],
- toYData: function (point) {
- return [point.low, point.high];
- },
- pointValKey: 'low',
-
-
- getSegments: function () {
- var series = this;
- each(series.points, function (point) {
- if (!series.options.connectNulls && (point.low === null || point.high === null)) {
- point.y = null;
- } else if (point.low === null && point.high !== null) {
- point.y = point.high;
- }
- });
- Series.prototype.getSegments.call(this);
- },
-
-
- translate: function () {
- var series = this,
- yAxis = series.yAxis;
- seriesTypes.area.prototype.translate.apply(series);
-
- each(series.points, function (point) {
- var low = point.low,
- high = point.high,
- plotY = point.plotY;
- if (high === null && low === null) {
- point.y = null;
- } else if (low === null) {
- point.plotLow = point.plotY = null;
- point.plotHigh = yAxis.translate(high, 0, 1, 0, 1);
- } else if (high === null) {
- point.plotLow = plotY;
- point.plotHigh = null;
- } else {
- point.plotLow = plotY;
- point.plotHigh = yAxis.translate(high, 0, 1, 0, 1);
- }
- });
- },
-
-
- getSegmentPath: function (segment) {
-
- var lowSegment,
- highSegment = [],
- i = segment.length,
- baseGetSegmentPath = Series.prototype.getSegmentPath,
- point,
- linePath,
- lowerPath,
- options = this.options,
- step = options.step,
- higherPath;
-
-
- lowSegment = HighchartsAdapter.grep(segment, function (point) {
- return point.plotLow !== null;
- });
-
-
- while (i--) {
- point = segment[i];
- if (point.plotHigh !== null) {
- highSegment.push({
- plotX: point.plotX,
- plotY: point.plotHigh
- });
- }
- }
-
-
- lowerPath = baseGetSegmentPath.call(this, lowSegment);
- if (step) {
- if (step === true) {
- step = 'left';
- }
- options.step = { left: 'right', center: 'center', right: 'left' }[step];
- }
- higherPath = baseGetSegmentPath.call(this, highSegment);
- options.step = step;
-
-
- linePath = [].concat(lowerPath, higherPath);
-
-
- higherPath[0] = 'L';
- this.areaPath = this.areaPath.concat(lowerPath, higherPath);
-
- return linePath;
- },
-
-
- drawDataLabels: function () {
-
- var data = this.data,
- length = data.length,
- i,
- originalDataLabels = [],
- seriesProto = Series.prototype,
- dataLabelOptions = this.options.dataLabels,
- align = dataLabelOptions.align,
- point,
- inverted = this.chart.inverted;
-
- if (dataLabelOptions.enabled || this._hasPointLabels) {
-
-
- i = length;
- while (i--) {
- point = data[i];
-
-
- point.y = point.high;
- point._plotY = point.plotY;
- point.plotY = point.plotHigh;
-
-
-
- originalDataLabels[i] = point.dataLabel;
- point.dataLabel = point.dataLabelUpper;
-
-
- point.below = false;
- if (inverted) {
- if (!align) {
- dataLabelOptions.align = 'left';
- }
- dataLabelOptions.x = dataLabelOptions.xHigh;
- } else {
- dataLabelOptions.y = dataLabelOptions.yHigh;
- }
- }
-
- if (seriesProto.drawDataLabels) {
- seriesProto.drawDataLabels.apply(this, arguments);
- }
-
-
- i = length;
- while (i--) {
- point = data[i];
-
-
- point.dataLabelUpper = point.dataLabel;
- point.dataLabel = originalDataLabels[i];
-
-
- point.y = point.low;
- point.plotY = point._plotY;
-
-
- point.below = true;
- if (inverted) {
- if (!align) {
- dataLabelOptions.align = 'right';
- }
- dataLabelOptions.x = dataLabelOptions.xLow;
- } else {
- dataLabelOptions.y = dataLabelOptions.yLow;
- }
- }
- if (seriesProto.drawDataLabels) {
- seriesProto.drawDataLabels.apply(this, arguments);
- }
- }
- dataLabelOptions.align = align;
-
- },
-
- alignDataLabel: function () {
- seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
- },
-
- getSymbol: noop,
-
- drawPoints: noop
- });
- defaultPlotOptions.areasplinerange = merge(defaultPlotOptions.arearange);
- seriesTypes.areasplinerange = extendClass(seriesTypes.arearange, {
- type: 'areasplinerange',
- getPointSpline: seriesTypes.spline.prototype.getPointSpline
- });
- (function () {
-
- var colProto = seriesTypes.column.prototype;
-
- defaultPlotOptions.columnrange = merge(defaultPlotOptions.column, defaultPlotOptions.arearange, {
- lineWidth: 1,
- pointRange: null
- });
-
- seriesTypes.columnrange = extendClass(seriesTypes.arearange, {
- type: 'columnrange',
-
- translate: function () {
- var series = this,
- yAxis = series.yAxis,
- plotHigh;
- colProto.translate.apply(series);
-
- each(series.points, function (point) {
- var shapeArgs = point.shapeArgs,
- minPointLength = series.options.minPointLength,
- heightDifference,
- height,
- y;
- point.tooltipPos = null;
- point.plotHigh = plotHigh = yAxis.translate(point.high, 0, 1, 0, 1);
- point.plotLow = point.plotY;
-
- y = plotHigh;
- height = point.plotY - plotHigh;
- if (height < minPointLength) {
- heightDifference = (minPointLength - height);
- height += heightDifference;
- y -= heightDifference / 2;
- }
- shapeArgs.height = height;
- shapeArgs.y = y;
- });
- },
- trackerGroups: ['group', 'dataLabelsGroup'],
- drawGraph: noop,
- pointAttrToOptions: colProto.pointAttrToOptions,
- drawPoints: colProto.drawPoints,
- drawTracker: colProto.drawTracker,
- animate: colProto.animate,
- getColumnMetrics: colProto.getColumnMetrics
- });
- }());
- defaultPlotOptions.gauge = merge(defaultPlotOptions.line, {
- dataLabels: {
- enabled: true,
- defer: false,
- y: 15,
- borderWidth: 1,
- borderColor: 'silver',
- borderRadius: 3,
- crop: false,
- style: {
- fontWeight: 'bold'
- },
- verticalAlign: 'top',
- zIndex: 2
- },
- dial: {
-
-
-
-
-
-
-
-
- },
- pivot: {
-
-
-
-
- },
- tooltip: {
- headerFormat: ''
- },
- showInLegend: false
- });
- var GaugePoint = extendClass(Point, {
-
- setState: function (state) {
- this.state = state;
- }
- });
- var GaugeSeries = {
- type: 'gauge',
- pointClass: GaugePoint,
-
-
-
- angular: true,
- drawGraph: noop,
- fixedBox: true,
- forceDL: true,
- trackerGroups: ['group', 'dataLabelsGroup'],
-
-
- translate: function () {
-
- var series = this,
- yAxis = series.yAxis,
- options = series.options,
- center = yAxis.center;
-
- series.generatePoints();
-
- each(series.points, function (point) {
-
- var dialOptions = merge(options.dial, point.dial),
- radius = (pInt(pick(dialOptions.radius, 80)) * center[2]) / 200,
- baseLength = (pInt(pick(dialOptions.baseLength, 70)) * radius) / 100,
- rearLength = (pInt(pick(dialOptions.rearLength, 10)) * radius) / 100,
- baseWidth = dialOptions.baseWidth || 3,
- topWidth = dialOptions.topWidth || 1,
- overshoot = options.overshoot,
- rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true);
-
- if (overshoot && typeof overshoot === 'number') {
- overshoot = overshoot / 180 * Math.PI;
- rotation = Math.max(yAxis.startAngleRad - overshoot, Math.min(yAxis.endAngleRad + overshoot, rotation));
-
- } else if (options.wrap === false) {
- rotation = Math.max(yAxis.startAngleRad, Math.min(yAxis.endAngleRad, rotation));
- }
- rotation = rotation * 180 / Math.PI;
-
- point.shapeType = 'path';
- point.shapeArgs = {
- d: dialOptions.path || [
- 'M',
- -rearLength, -baseWidth / 2,
- 'L',
- baseLength, -baseWidth / 2,
- radius, -topWidth / 2,
- radius, topWidth / 2,
- baseLength, baseWidth / 2,
- -rearLength, baseWidth / 2,
- 'z'
- ],
- translateX: center[0],
- translateY: center[1],
- rotation: rotation
- };
-
-
- point.plotX = center[0];
- point.plotY = center[1];
- });
- },
-
-
- drawPoints: function () {
-
- var series = this,
- center = series.yAxis.center,
- pivot = series.pivot,
- options = series.options,
- pivotOptions = options.pivot,
- renderer = series.chart.renderer;
-
- each(series.points, function (point) {
-
- var graphic = point.graphic,
- shapeArgs = point.shapeArgs,
- d = shapeArgs.d,
- dialOptions = merge(options.dial, point.dial);
-
- if (graphic) {
- graphic.animate(shapeArgs);
- shapeArgs.d = d;
- } else {
- point.graphic = renderer[point.shapeType](shapeArgs)
- .attr({
- stroke: dialOptions.borderColor || 'none',
- 'stroke-width': dialOptions.borderWidth || 0,
- fill: dialOptions.backgroundColor || 'black',
- rotation: shapeArgs.rotation
- })
- .add(series.group);
- }
- });
-
-
- if (pivot) {
- pivot.animate({
- translateX: center[0],
- translateY: center[1]
- });
- } else {
- series.pivot = renderer.circle(0, 0, pick(pivotOptions.radius, 5))
- .attr({
- 'stroke-width': pivotOptions.borderWidth || 0,
- stroke: pivotOptions.borderColor || 'silver',
- fill: pivotOptions.backgroundColor || 'black'
- })
- .translate(center[0], center[1])
- .add(series.group);
- }
- },
-
-
- animate: function (init) {
- var series = this;
- if (!init) {
- each(series.points, function (point) {
- var graphic = point.graphic;
- if (graphic) {
-
- graphic.attr({
- rotation: series.yAxis.startAngleRad * 180 / Math.PI
- });
-
- graphic.animate({
- rotation: point.shapeArgs.rotation
- }, series.options.animation);
- }
- });
-
- series.animate = null;
- }
- },
-
- render: function () {
- this.group = this.plotGroup(
- 'group',
- 'series',
- this.visible ? 'visible' : 'hidden',
- this.options.zIndex,
- this.chart.seriesGroup
- );
- Series.prototype.render.call(this);
- this.group.clip(this.chart.clipRect);
- },
-
-
- setData: function (data, redraw) {
- Series.prototype.setData.call(this, data, false);
- this.processData();
- this.generatePoints();
- if (pick(redraw, true)) {
- this.chart.redraw();
- }
- },
-
- drawTracker: TrackerMixin && TrackerMixin.drawTrackerPoint
- };
- seriesTypes.gauge = extendClass(seriesTypes.line, GaugeSeries);
- defaultPlotOptions.boxplot = merge(defaultPlotOptions.column, {
- fillColor: '#FFFFFF',
- lineWidth: 1,
-
- medianWidth: 2,
- states: {
- hover: {
- brightness: -0.3
- }
- },
-
-
-
- threshold: null,
- tooltip: {
- pointFormat: '<span style="color:{series.color}">\u25CF</span> <b> {series.name}</b><br/>' +
- 'Maximum: {point.high}<br/>' +
- 'Upper quartile: {point.q3}<br/>' +
- 'Median: {point.median}<br/>' +
- 'Lower quartile: {point.q1}<br/>' +
- 'Minimum: {point.low}<br/>'
-
- },
-
- whiskerLength: '50%',
- whiskerWidth: 2
- });
- seriesTypes.boxplot = extendClass(seriesTypes.column, {
- type: 'boxplot',
- pointArrayMap: ['low', 'q1', 'median', 'q3', 'high'],
- toYData: function (point) {
- return [point.low, point.q1, point.median, point.q3, point.high];
- },
- pointValKey: 'high',
-
-
- pointAttrToOptions: {
- fill: 'fillColor',
- stroke: 'color',
- 'stroke-width': 'lineWidth'
- },
-
-
- drawDataLabels: noop,
-
- translate: function () {
- var series = this,
- yAxis = series.yAxis,
- pointArrayMap = series.pointArrayMap;
- seriesTypes.column.prototype.translate.apply(series);
-
- each(series.points, function (point) {
- each(pointArrayMap, function (key) {
- if (point[key] !== null) {
- point[key + 'Plot'] = yAxis.translate(point[key], 0, 1, 0, 1);
- }
- });
- });
- },
-
- drawPoints: function () {
- var series = this,
- points = series.points,
- options = series.options,
- chart = series.chart,
- renderer = chart.renderer,
- pointAttr,
- q1Plot,
- q3Plot,
- highPlot,
- lowPlot,
- medianPlot,
- crispCorr,
- crispX,
- graphic,
- stemPath,
- stemAttr,
- boxPath,
- whiskersPath,
- whiskersAttr,
- medianPath,
- medianAttr,
- width,
- left,
- right,
- halfWidth,
- shapeArgs,
- color,
- doQuartiles = series.doQuartiles !== false,
- whiskerLength = parseInt(series.options.whiskerLength, 10) / 100;
- each(points, function (point) {
- graphic = point.graphic;
- shapeArgs = point.shapeArgs;
- stemAttr = {};
- whiskersAttr = {};
- medianAttr = {};
- color = point.color || series.color;
-
- if (point.plotY !== UNDEFINED) {
- pointAttr = point.pointAttr[point.selected ? 'selected' : ''];
-
- width = shapeArgs.width;
- left = mathFloor(shapeArgs.x);
- right = left + width;
- halfWidth = mathRound(width / 2);
-
- q1Plot = mathFloor(doQuartiles ? point.q1Plot : point.lowPlot);
- q3Plot = mathFloor(doQuartiles ? point.q3Plot : point.lowPlot);
- highPlot = mathFloor(point.highPlot);
- lowPlot = mathFloor(point.lowPlot);
-
-
- stemAttr.stroke = point.stemColor || options.stemColor || color;
- stemAttr['stroke-width'] = pick(point.stemWidth, options.stemWidth, options.lineWidth);
- stemAttr.dashstyle = point.stemDashStyle || options.stemDashStyle;
-
-
- whiskersAttr.stroke = point.whiskerColor || options.whiskerColor || color;
- whiskersAttr['stroke-width'] = pick(point.whiskerWidth, options.whiskerWidth, options.lineWidth);
-
-
- medianAttr.stroke = point.medianColor || options.medianColor || color;
- medianAttr['stroke-width'] = pick(point.medianWidth, options.medianWidth, options.lineWidth);
- medianAttr['stroke-linecap'] = 'round';
-
-
-
- crispCorr = (stemAttr['stroke-width'] % 2) / 2;
- crispX = left + halfWidth + crispCorr;
- stemPath = [
-
- 'M',
- crispX, q3Plot,
- 'L',
- crispX, highPlot,
-
-
- 'M',
- crispX, q1Plot,
- 'L',
- crispX, lowPlot
- ];
-
-
- if (doQuartiles) {
- crispCorr = (pointAttr['stroke-width'] % 2) / 2;
- crispX = mathFloor(crispX) + crispCorr;
- q1Plot = mathFloor(q1Plot) + crispCorr;
- q3Plot = mathFloor(q3Plot) + crispCorr;
- left += crispCorr;
- right += crispCorr;
- boxPath = [
- 'M',
- left, q3Plot,
- 'L',
- left, q1Plot,
- 'L',
- right, q1Plot,
- 'L',
- right, q3Plot,
- 'L',
- left, q3Plot,
- 'z'
- ];
- }
-
-
- if (whiskerLength) {
- crispCorr = (whiskersAttr['stroke-width'] % 2) / 2;
- highPlot = highPlot + crispCorr;
- lowPlot = lowPlot + crispCorr;
- whiskersPath = [
-
- 'M',
- crispX - halfWidth * whiskerLength,
- highPlot,
- 'L',
- crispX + halfWidth * whiskerLength,
- highPlot,
-
-
- 'M',
- crispX - halfWidth * whiskerLength,
- lowPlot,
- 'L',
- crispX + halfWidth * whiskerLength,
- lowPlot
- ];
- }
-
-
- crispCorr = (medianAttr['stroke-width'] % 2) / 2;
- medianPlot = mathRound(point.medianPlot) + crispCorr;
- medianPath = [
- 'M',
- left,
- medianPlot,
- 'L',
- right,
- medianPlot
- ];
-
-
- if (graphic) {
-
- point.stem.animate({ d: stemPath });
- if (whiskerLength) {
- point.whiskers.animate({ d: whiskersPath });
- }
- if (doQuartiles) {
- point.box.animate({ d: boxPath });
- }
- point.medianShape.animate({ d: medianPath });
-
- } else {
- point.graphic = graphic = renderer.g()
- .add(series.group);
-
- point.stem = renderer.path(stemPath)
- .attr(stemAttr)
- .add(graphic);
-
- if (whiskerLength) {
- point.whiskers = renderer.path(whiskersPath)
- .attr(whiskersAttr)
- .add(graphic);
- }
- if (doQuartiles) {
- point.box = renderer.path(boxPath)
- .attr(pointAttr)
- .add(graphic);
- }
- point.medianShape = renderer.path(medianPath)
- .attr(medianAttr)
- .add(graphic);
- }
- }
- });
- }
- });
- defaultPlotOptions.errorbar = merge(defaultPlotOptions.boxplot, {
- color: '#000000',
- grouping: false,
- linkedTo: ':previous',
- tooltip: {
- pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
- },
- whiskerWidth: null
- });
- seriesTypes.errorbar = extendClass(seriesTypes.boxplot, {
- type: 'errorbar',
- pointArrayMap: ['low', 'high'],
- toYData: function (point) {
- return [point.low, point.high];
- },
- pointValKey: 'high',
- doQuartiles: false,
- drawDataLabels: seriesTypes.arearange ? seriesTypes.arearange.prototype.drawDataLabels : noop,
-
- getColumnMetrics: function () {
- return (this.linkedParent && this.linkedParent.columnMetrics) ||
- seriesTypes.column.prototype.getColumnMetrics.call(this);
- }
- });
- defaultPlotOptions.waterfall = merge(defaultPlotOptions.column, {
- lineWidth: 1,
- lineColor: '#333',
- dashStyle: 'dot',
- borderColor: '#333',
- states: {
- hover: {
- lineWidthPlus: 0
- }
- }
- });
- seriesTypes.waterfall = extendClass(seriesTypes.column, {
- type: 'waterfall',
- upColorProp: 'fill',
- pointArrayMap: ['low', 'y'],
- pointValKey: 'y',
-
- init: function (chart, options) {
-
- options.stacking = true;
- seriesTypes.column.prototype.init.call(this, chart, options);
- },
-
- translate: function () {
- var series = this,
- options = series.options,
- yAxis = series.yAxis,
- len,
- i,
- points,
- point,
- shapeArgs,
- stack,
- y,
- previousY,
- previousIntermediate,
- stackPoint,
- threshold = options.threshold,
- tooltipY;
-
- seriesTypes.column.prototype.translate.apply(this);
- previousY = previousIntermediate = threshold;
- points = series.points;
- for (i = 0, len = points.length; i < len; i++) {
-
- point = points[i];
- shapeArgs = point.shapeArgs;
-
- stack = series.getStack(i);
- stackPoint = stack.points[series.index + ',' + i];
-
- if (isNaN(point.y)) {
- point.y = series.yData[i];
- }
-
- y = mathMax(previousY, previousY + point.y) + stackPoint[0];
- shapeArgs.y = yAxis.translate(y, 0, 1);
-
- if (point.isSum) {
- shapeArgs.y = yAxis.translate(stackPoint[1], 0, 1);
- shapeArgs.height = yAxis.translate(stackPoint[0], 0, 1) - shapeArgs.y;
- } else if (point.isIntermediateSum) {
- shapeArgs.y = yAxis.translate(stackPoint[1], 0, 1);
- shapeArgs.height = yAxis.translate(previousIntermediate, 0, 1) - shapeArgs.y;
- previousIntermediate = stackPoint[1];
-
- } else {
- previousY += stack.total;
- }
-
- if (shapeArgs.height < 0) {
- shapeArgs.y += shapeArgs.height;
- shapeArgs.height *= -1;
- }
- point.plotY = shapeArgs.y = mathRound(shapeArgs.y) - (series.borderWidth % 2) / 2;
- shapeArgs.height = mathMax(mathRound(shapeArgs.height), 0.001);
- point.yBottom = shapeArgs.y + shapeArgs.height;
-
- tooltipY = point.plotY + (point.negative ? shapeArgs.height : 0);
- if (series.chart.inverted) {
- point.tooltipPos[0] = yAxis.len - tooltipY;
- } else {
- point.tooltipPos[1] = tooltipY;
- }
- }
- },
-
- processData: function (force) {
- var series = this,
- options = series.options,
- yData = series.yData,
- points = series.points,
- point,
- dataLength = yData.length,
- threshold = options.threshold || 0,
- subSum,
- sum,
- dataMin,
- dataMax,
- y,
- i;
- sum = subSum = dataMin = dataMax = threshold;
- for (i = 0; i < dataLength; i++) {
- y = yData[i];
- point = points && points[i] ? points[i] : {};
- if (y === "sum" || point.isSum) {
- yData[i] = sum;
- } else if (y === "intermediateSum" || point.isIntermediateSum) {
- yData[i] = subSum;
- } else {
- sum += y;
- subSum += y;
- }
- dataMin = Math.min(sum, dataMin);
- dataMax = Math.max(sum, dataMax);
- }
- Series.prototype.processData.call(this, force);
-
- series.dataMin = dataMin;
- series.dataMax = dataMax;
- },
-
- toYData: function (pt) {
- if (pt.isSum) {
- return "sum";
- } else if (pt.isIntermediateSum) {
- return "intermediateSum";
- }
- return pt.y;
- },
-
- getAttribs: function () {
- seriesTypes.column.prototype.getAttribs.apply(this, arguments);
- var series = this,
- options = series.options,
- stateOptions = options.states,
- upColor = options.upColor || series.color,
- hoverColor = Highcharts.Color(upColor).brighten(0.1).get(),
- seriesDownPointAttr = merge(series.pointAttr),
- upColorProp = series.upColorProp;
- seriesDownPointAttr[''][upColorProp] = upColor;
- seriesDownPointAttr.hover[upColorProp] = stateOptions.hover.upColor || hoverColor;
- seriesDownPointAttr.select[upColorProp] = stateOptions.select.upColor || upColor;
- each(series.points, function (point) {
- if (point.y > 0 && !point.color) {
- point.pointAttr = seriesDownPointAttr;
- point.color = upColor;
- }
- });
- },
-
- getGraphPath: function () {
- var data = this.data,
- length = data.length,
- lineWidth = this.options.lineWidth + this.borderWidth,
- normalizer = mathRound(lineWidth) % 2 / 2,
- path = [],
- M = 'M',
- L = 'L',
- prevArgs,
- pointArgs,
- i,
- d;
- for (i = 1; i < length; i++) {
- pointArgs = data[i].shapeArgs;
- prevArgs = data[i - 1].shapeArgs;
- d = [
- M,
- prevArgs.x + prevArgs.width, prevArgs.y + normalizer,
- L,
- pointArgs.x, prevArgs.y + normalizer
- ];
- if (data[i - 1].y < 0) {
- d[2] += prevArgs.height;
- d[5] += prevArgs.height;
- }
- path = path.concat(d);
- }
- return path;
- },
-
- getExtremes: noop,
-
- getStack: function (i) {
- var axis = this.yAxis,
- stacks = axis.stacks,
- key = this.stackKey;
- if (this.processedYData[i] < this.options.threshold) {
- key = '-' + key;
- }
- return stacks[key][i];
- },
- drawGraph: Series.prototype.drawGraph
- });
- defaultPlotOptions.bubble = merge(defaultPlotOptions.scatter, {
- dataLabels: {
- formatter: function () {
- return this.point.z;
- },
- inside: true,
- style: {
- color: 'white',
- textShadow: '0px 0px 3px black'
- },
- verticalAlign: 'middle'
- },
-
- marker: {
-
- lineColor: null,
- lineWidth: 1
- },
- minSize: 8,
- maxSize: '20%',
-
-
- states: {
- hover: {
- halo: {
- size: 5
- }
- }
- },
- tooltip: {
- pointFormat: '({point.x}, {point.y}), Size: {point.z}'
- },
- turboThreshold: 0,
- zThreshold: 0
- });
- var BubblePoint = extendClass(Point, {
- haloPath: function () {
- return Point.prototype.haloPath.call(this, this.shapeArgs.r + this.series.options.states.hover.halo.size);
- }
- });
- seriesTypes.bubble = extendClass(seriesTypes.scatter, {
- type: 'bubble',
- pointClass: BubblePoint,
- pointArrayMap: ['y', 'z'],
- parallelArrays: ['x', 'y', 'z'],
- trackerGroups: ['group', 'dataLabelsGroup'],
- bubblePadding: true,
-
-
- pointAttrToOptions: {
- stroke: 'lineColor',
- 'stroke-width': 'lineWidth',
- fill: 'fillColor'
- },
-
-
- applyOpacity: function (fill) {
- var markerOptions = this.options.marker,
- fillOpacity = pick(markerOptions.fillOpacity, 0.5);
-
-
- fill = fill || markerOptions.fillColor || this.color;
-
- if (fillOpacity !== 1) {
- fill = Color(fill).setOpacity(fillOpacity).get('rgba');
- }
- return fill;
- },
-
-
- convertAttribs: function () {
- var obj = Series.prototype.convertAttribs.apply(this, arguments);
-
- obj.fill = this.applyOpacity(obj.fill);
-
- return obj;
- },
-
- getRadii: function (zMin, zMax, minSize, maxSize) {
- var len,
- i,
- pos,
- zData = this.zData,
- radii = [],
- sizeByArea = this.options.sizeBy !== 'width',
- zRange;
-
-
- for (i = 0, len = zData.length; i < len; i++) {
- zRange = zMax - zMin;
- pos = zRange > 0 ?
- (zData[i] - zMin) / (zMax - zMin) :
- 0.5;
- if (sizeByArea && pos >= 0) {
- pos = Math.sqrt(pos);
- }
- radii.push(math.ceil(minSize + pos * (maxSize - minSize)) / 2);
- }
- this.radii = radii;
- },
-
-
- animate: function (init) {
- var animation = this.options.animation;
-
- if (!init) {
- each(this.points, function (point) {
- var graphic = point.graphic,
- shapeArgs = point.shapeArgs;
- if (graphic && shapeArgs) {
-
- graphic.attr('r', 1);
-
- graphic.animate({
- r: shapeArgs.r
- }, animation);
- }
- });
-
- this.animate = null;
- }
- },
-
-
- translate: function () {
-
- var i,
- data = this.data,
- point,
- radius,
- radii = this.radii;
-
-
- seriesTypes.scatter.prototype.translate.call(this);
-
-
- i = data.length;
-
- while (i--) {
- point = data[i];
- radius = radii ? radii[i] : 0;
-
- point.negative = point.z < (this.options.zThreshold || 0);
-
- if (radius >= this.minPxSize / 2) {
-
- point.shapeType = 'circle';
- point.shapeArgs = {
- x: point.plotX,
- y: point.plotY,
- r: radius
- };
-
-
- point.dlBox = {
- x: point.plotX - radius,
- y: point.plotY - radius,
- width: 2 * radius,
- height: 2 * radius
- };
- } else {
- point.shapeArgs = point.plotY = point.dlBox = UNDEFINED;
- }
- }
- },
-
-
- drawLegendSymbol: function (legend, item) {
- var radius = pInt(legend.itemStyle.fontSize) / 2;
-
- item.legendSymbol = this.chart.renderer.circle(
- radius,
- legend.baseline - radius,
- radius
- ).attr({
- zIndex: 3
- }).add(item.legendGroup);
- item.legendSymbol.isMarker = true;
-
- },
-
- drawPoints: seriesTypes.column.prototype.drawPoints,
- alignDataLabel: seriesTypes.column.prototype.alignDataLabel
- });
- Axis.prototype.beforePadding = function () {
- var axis = this,
- axisLength = this.len,
- chart = this.chart,
- pxMin = 0,
- pxMax = axisLength,
- isXAxis = this.isXAxis,
- dataKey = isXAxis ? 'xData' : 'yData',
- min = this.min,
- extremes = {},
- smallestSize = math.min(chart.plotWidth, chart.plotHeight),
- zMin = Number.MAX_VALUE,
- zMax = -Number.MAX_VALUE,
- range = this.max - min,
- transA = axisLength / range,
- activeSeries = [];
-
- if (this.tickPositions) {
- each(this.series, function (series) {
- var seriesOptions = series.options,
- zData;
- if (series.bubblePadding && (series.visible || !chart.options.chart.ignoreHiddenSeries)) {
-
- axis.allowZoomOutside = true;
-
- activeSeries.push(series);
- if (isXAxis) {
-
-
- each(['minSize', 'maxSize'], function (prop) {
- var length = seriesOptions[prop],
- isPercent = /%$/.test(length);
-
- length = pInt(length);
- extremes[prop] = isPercent ?
- smallestSize * length / 100 :
- length;
-
- });
- series.minPxSize = extremes.minSize;
-
-
- zData = series.zData;
- if (zData.length) {
- zMin = pick(seriesOptions.zMin, math.min(
- zMin,
- math.max(
- arrayMin(zData),
- seriesOptions.displayNegative === false ? seriesOptions.zThreshold : -Number.MAX_VALUE
- )
- ));
- zMax = pick(seriesOptions.zMax, math.max(zMax, arrayMax(zData)));
- }
- }
- }
- });
- each(activeSeries, function (series) {
- var data = series[dataKey],
- i = data.length,
- radius;
- if (isXAxis) {
- series.getRadii(zMin, zMax, extremes.minSize, extremes.maxSize);
- }
-
- if (range > 0) {
- while (i--) {
- if (typeof data[i] === 'number') {
- radius = series.radii[i];
- pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
- pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
- }
- }
- }
- });
-
- if (activeSeries.length && range > 0 && pick(this.options.min, this.userMin) === UNDEFINED && pick(this.options.max, this.userMax) === UNDEFINED) {
- pxMax -= axisLength;
- transA *= (axisLength + pxMin - pxMax) / axisLength;
- this.min += pxMin / transA;
- this.max += pxMax / transA;
- }
- }
- };
- (function () {
-
- var seriesProto = Series.prototype,
- pointerProto = Pointer.prototype,
- colProto;
-
- seriesProto.toXY = function (point) {
- var xy,
- chart = this.chart,
- plotX = point.plotX,
- plotY = point.plotY,
- clientX;
-
-
- point.rectPlotX = plotX;
- point.rectPlotY = plotY;
-
-
- clientX = ((plotX / Math.PI * 180) + this.xAxis.pane.options.startAngle) % 360;
- if (clientX < 0) {
- clientX += 360;
- }
- point.clientX = clientX;
-
-
- xy = this.xAxis.postTranslate(point.plotX, this.yAxis.len - plotY);
- point.plotX = point.polarPlotX = xy.x - chart.plotLeft;
- point.plotY = point.polarPlotY = xy.y - chart.plotTop;
- };
-
- seriesProto.orderTooltipPoints = function (points) {
- if (this.chart.polar) {
- points.sort(function (a, b) {
- return a.clientX - b.clientX;
- });
-
-
- if (points[0]) {
- points[0].wrappedClientX = points[0].clientX + 360;
- points.push(points[0]);
- }
- }
- };
-
- function initArea(proceed, chart, options) {
- proceed.call(this, chart, options);
- if (this.chart.polar) {
-
-
- this.closeSegment = function (path) {
- var center = this.xAxis.center;
- path.push(
- 'L',
- center[0],
- center[1]
- );
- };
-
-
-
- this.closedStacks = true;
- }
- }
- if (seriesTypes.area) {
- wrap(seriesTypes.area.prototype, 'init', initArea);
- }
- if (seriesTypes.areaspline) {
- wrap(seriesTypes.areaspline.prototype, 'init', initArea);
- }
- if (seriesTypes.spline) {
-
- wrap(seriesTypes.spline.prototype, 'getPointSpline', function (proceed, segment, point, i) {
-
- var ret,
- smoothing = 1.5,
- denom = smoothing + 1,
- plotX,
- plotY,
- lastPoint,
- nextPoint,
- lastX,
- lastY,
- nextX,
- nextY,
- leftContX,
- leftContY,
- rightContX,
- rightContY,
- distanceLeftControlPoint,
- distanceRightControlPoint,
- leftContAngle,
- rightContAngle,
- jointAngle;
-
-
- if (this.chart.polar) {
-
- plotX = point.plotX;
- plotY = point.plotY;
- lastPoint = segment[i - 1];
- nextPoint = segment[i + 1];
-
-
- if (this.connectEnds) {
- if (!lastPoint) {
- lastPoint = segment[segment.length - 2];
- }
- if (!nextPoint) {
- nextPoint = segment[1];
- }
- }
-
- if (lastPoint && nextPoint) {
-
- lastX = lastPoint.plotX;
- lastY = lastPoint.plotY;
- nextX = nextPoint.plotX;
- nextY = nextPoint.plotY;
- leftContX = (smoothing * plotX + lastX) / denom;
- leftContY = (smoothing * plotY + lastY) / denom;
- rightContX = (smoothing * plotX + nextX) / denom;
- rightContY = (smoothing * plotY + nextY) / denom;
- distanceLeftControlPoint = Math.sqrt(Math.pow(leftContX - plotX, 2) + Math.pow(leftContY - plotY, 2));
- distanceRightControlPoint = Math.sqrt(Math.pow(rightContX - plotX, 2) + Math.pow(rightContY - plotY, 2));
- leftContAngle = Math.atan2(leftContY - plotY, leftContX - plotX);
- rightContAngle = Math.atan2(rightContY - plotY, rightContX - plotX);
- jointAngle = (Math.PI / 2) + ((leftContAngle + rightContAngle) / 2);
-
-
-
- if (Math.abs(leftContAngle - jointAngle) > Math.PI / 2) {
- jointAngle -= Math.PI;
- }
-
-
- leftContX = plotX + Math.cos(jointAngle) * distanceLeftControlPoint;
- leftContY = plotY + Math.sin(jointAngle) * distanceLeftControlPoint;
- rightContX = plotX + Math.cos(Math.PI + jointAngle) * distanceRightControlPoint;
- rightContY = plotY + Math.sin(Math.PI + jointAngle) * distanceRightControlPoint;
-
-
- point.rightContX = rightContX;
- point.rightContY = rightContY;
- }
-
-
-
- if (!i) {
- ret = ['M', plotX, plotY];
- } else {
- ret = [
- 'C',
- lastPoint.rightContX || lastPoint.plotX,
- lastPoint.rightContY || lastPoint.plotY,
- leftContX || plotX,
- leftContY || plotY,
- plotX,
- plotY
- ];
- lastPoint.rightContX = lastPoint.rightContY = null;
- }
-
-
- } else {
- ret = proceed.call(this, segment, point, i);
- }
- return ret;
- });
- }
-
- wrap(seriesProto, 'translate', function (proceed) {
-
-
- proceed.call(this);
-
-
- if (this.chart.polar && !this.preventPostTranslate) {
- var points = this.points,
- i = points.length;
- while (i--) {
-
- this.toXY(points[i]);
- }
- }
- });
-
- wrap(seriesProto, 'getSegmentPath', function (proceed, segment) {
-
- var points = this.points;
-
-
- if (this.chart.polar && this.options.connectEnds !== false &&
- segment[segment.length - 1] === points[points.length - 1] && points[0].y !== null) {
- this.connectEnds = true;
- segment = [].concat(segment, [points[0]]);
- }
-
-
- return proceed.call(this, segment);
-
- });
- function polarAnimate(proceed, init) {
- var chart = this.chart,
- animation = this.options.animation,
- group = this.group,
- markerGroup = this.markerGroup,
- center = this.xAxis.center,
- plotLeft = chart.plotLeft,
- plotTop = chart.plotTop,
- attribs;
-
- if (chart.polar) {
-
-
-
- if (chart.renderer.isSVG) {
- if (animation === true) {
- animation = {};
- }
-
-
- if (init) {
-
-
- attribs = {
- translateX: center[0] + plotLeft,
- translateY: center[1] + plotTop,
- scaleX: 0.001,
- scaleY: 0.001
- };
-
- group.attr(attribs);
- if (markerGroup) {
-
- markerGroup.attr(attribs);
- }
-
-
- } else {
- attribs = {
- translateX: plotLeft,
- translateY: plotTop,
- scaleX: 1,
- scaleY: 1
- };
- group.animate(attribs, animation);
- if (markerGroup) {
- markerGroup.animate(attribs, animation);
- }
-
-
- this.animate = null;
- }
- }
-
-
- } else {
- proceed.call(this, init);
- }
- }
-
- wrap(seriesProto, 'animate', polarAnimate);
-
- wrap(seriesProto, 'setTooltipPoints', function (proceed, renew) {
-
- if (this.chart.polar) {
- extend(this.xAxis, {
- tooltipLen: 360
- });
- }
-
- return proceed.call(this, renew);
- });
- if (seriesTypes.column) {
- colProto = seriesTypes.column.prototype;
-
- wrap(colProto, 'animate', polarAnimate);
-
- wrap(colProto, 'translate', function (proceed) {
-
- var xAxis = this.xAxis,
- len = this.yAxis.len,
- center = xAxis.center,
- startAngleRad = xAxis.startAngleRad,
- renderer = this.chart.renderer,
- start,
- points,
- point,
- i;
-
- this.preventPostTranslate = true;
-
-
- proceed.call(this);
-
-
- if (xAxis.isRadial) {
- points = this.points;
- i = points.length;
- while (i--) {
- point = points[i];
- start = point.barX + startAngleRad;
- point.shapeType = 'path';
- point.shapeArgs = {
- d: renderer.symbols.arc(
- center[0],
- center[1],
- len - point.plotY,
- null,
- {
- start: start,
- end: start + point.pointWidth,
- innerR: len - pick(point.yBottom, len)
- }
- )
- };
-
- this.toXY(point);
- point.tooltipPos = [point.plotX, point.plotY];
- point.ttBelow = point.plotY > center[1];
- }
- }
- });
-
- wrap(colProto, 'alignDataLabel', function (proceed, point, dataLabel, options, alignTo, isNew) {
-
- if (this.chart.polar) {
- var angle = point.rectPlotX / Math.PI * 180,
- align,
- verticalAlign;
-
-
- if (options.align === null) {
- if (angle > 20 && angle < 160) {
- align = 'left';
- } else if (angle > 200 && angle < 340) {
- align = 'right';
- } else {
- align = 'center';
- }
- options.align = align;
- }
- if (options.verticalAlign === null) {
- if (angle < 45 || angle > 315) {
- verticalAlign = 'bottom';
- } else if (angle > 135 && angle < 225) {
- verticalAlign = 'top';
- } else {
- verticalAlign = 'middle';
- }
- options.verticalAlign = verticalAlign;
- }
-
- seriesProto.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
- } else {
- proceed.call(this, point, dataLabel, options, alignTo, isNew);
- }
-
- });
- }
-
- wrap(pointerProto, 'getIndex', function (proceed, e) {
- var ret,
- chart = this.chart,
- center,
- x,
- y;
-
- if (chart.polar) {
- center = chart.xAxis[0].center;
- x = e.chartX - center[0] - chart.plotLeft;
- y = e.chartY - center[1] - chart.plotTop;
-
- ret = 180 - Math.round(Math.atan2(x, y) / Math.PI * 180);
-
- } else {
-
-
- ret = proceed.call(this, e);
- }
- return ret;
- });
-
- wrap(pointerProto, 'getCoordinates', function (proceed, e) {
- var chart = this.chart,
- ret = {
- xAxis: [],
- yAxis: []
- };
-
- if (chart.polar) {
- each(chart.axes, function (axis) {
- var isXAxis = axis.isXAxis,
- center = axis.center,
- x = e.chartX - center[0] - chart.plotLeft,
- y = e.chartY - center[1] - chart.plotTop;
-
- ret[isXAxis ? 'xAxis' : 'yAxis'].push({
- axis: axis,
- value: axis.translate(
- isXAxis ?
- Math.PI - Math.atan2(x, y) :
- Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)),
- true
- )
- });
- });
-
- } else {
- ret = proceed.call(this, e);
- }
-
- return ret;
- });
- }());
- }(Highcharts));
|