|
!function(c){function n(e){if(g[e])return g[e].exports;var t=g[e]={i:e,l:!1,exports:{}};return c[e].call(t.exports,t,t.exports,n),t.l=!0,t.exports}var g={};n.m=c,n.c=g,n.i=function(c){return c},n.d=function(c,g,e){n.o(c,g)||Object.defineProperty(c,g,{configurable:!1,enumerable:!0,get:e})},n.n=function(c){var g=c&&c.__esModule?function(){return c.default}:function(){return c};return n.d(g,"a",g),g},n.o=function(c,n){return Object.prototype.hasOwnProperty.call(c,n)},n.p="",n(n.s=0)}([function(module,exports,__webpack_require__){"use strict";eval("\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar d3 = window.d3;\n\n// selection passed in is a d3 selection\nd3.areaCircle = function (selection, value, config) {\n config = _extends({\n width: 300,\n height: 300,\n axis: [25, 50, 75, 100],\n domain: [0, 100],\n title: '',\n bgRectColor: '#eee',\n bgGridColor: '#00b8b8',\n circleColor: '#de3d83',\n circleTextColor: '#e4bd0b'\n }, config);\n\n console.log('config', config);\n\n var _config = config,\n width = _config.width,\n height = _config.height,\n axis = _config.axis,\n domain = _config.domain;\n\n\n var distance = width > height ? height : width;\n\n var sqrtScale = d3.scaleSqrt().domain(domain).range([0, distance / 3]);\n\n if (selection.select('.area-circle').empty()) {\n // append background rect\n selection.append('g').attr('class', 'bg-rect').append('rect').attr('width', width).attr('height', height).style('fill', config.bgRectColor);\n // append titles\n selection.append('g').attr('class', 'bg-title').append('text').attr('x', 20).attr('y', 40).style('font-size', '24px').style('fill', '#454545').text(config.title);\n // append the axis circles\n selection.append('g').attr('class', 'axis-wrap').selectAll('circle').data(axis).enter().append('circle').attr('class', function (d) {\n return 'axis axis-' + d;\n }).attr('r', function (d) {\n return sqrtScale(d);\n }).attr('cx', width / 2).attr('cy', height / 2).style('fill', 'none').style('stroke', config.bgGridColor).style('opacity', 0.5);\n\n // append some axis labels\n selection.append('g').attr('class', 'axis-labels-wrap').selectAll('.axis-labels').data(axis).enter().append('text').attr('x', width / 2).attr('y', function (d) {\n return height / 2 + sqrtScale(d) + 5;\n }).style('text-anchor', 'end').style('fill', config.bgGridColor).text(function (d) {\n return d + '%';\n });\n\n // append a circle for the value\n selection.append('circle').attr('class', 'area-circle').attr('cx', width / 2).attr('cy', height / 2).style('fill', config.circleColor).style('opacity', 0.9);\n // append it's value\n selection.append('text').attr('class', 'area-label').attr('x', width / 2).attr('y', height / 2 + 12).style('text-anchor', 'middle').style('font-size', '48px').style('fill', config.circleTextColor);\n }\n // update\n selection.select('.area-circle').transition().ease(d3.easeLinear).duration(500).attr('r', function (d) {\n return sqrtScale(value);\n });\n selection.select('.area-label').transition().delay(100).duration(500).text(value + '%');\n};//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zY3JpcHQuanM/OWE5NSJdLCJzb3VyY2VzQ29udGVudCI6WyJjb25zdCBkMyA9IHdpbmRvdy5kM1xuXG4vLyBzZWxlY3Rpb24gcGFzc2VkIGluIGlzIGEgZDMgc2VsZWN0aW9uXG5kMy5hcmVhQ2lyY2xlID0gZnVuY3Rpb24gKHNlbGVjdGlvbiwgdmFsdWUsIGNvbmZpZykge1xuICBjb25maWcgPSB7XG4gICAgd2lkdGg6IDMwMCxcbiAgICBoZWlnaHQ6IDMwMCxcbiAgICBheGlzOiBbMjUsIDUwLCA3NSwgMTAwXSxcbiAgICBkb21haW46IFswLCAxMDBdLFxuICAgIHRpdGxlOiAnJyxcbiAgICBiZ1JlY3RDb2xvcjogJyNlZWUnLFxuICAgIGJnR3JpZENvbG9yOiAnIzAwYjhiOCcsXG4gICAgY2lyY2xlQ29sb3I6ICcjZGUzZDgzJyxcbiAgICBjaXJjbGVUZXh0Q29sb3I6ICcjZTRiZDBiJyxcbiAgICAuLi5jb25maWdcbiAg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