MCPcopy Create free account
hub / github.com/CoderOpen/waimai / drawMapDataPoints

Function drawMapDataPoints

front/components/u-charts/u-charts.js:3622–3699  ·  view source on GitHub ↗
(series, opts, config, context)

Source from the content-addressed store, hash-verified

3620
3621
3622function drawMapDataPoints(series, opts, config, context) {
3623 var mapOption=assign({},{
3624 border:true,
3625 borderWidth:1,
3626 borderColor:'#666666',
3627 fillOpacity:0.6,
3628 activeBorderColor:'#f04864',
3629 activeFillColor:'#facc14',
3630 activeFillOpacity:1
3631 },opts.extra.map);
3632 var coords, point;
3633 var data = series;
3634 var bounds= getBoundingBox(data);
3635 var xScale = opts.width / Math.abs(bounds.xMax - bounds.xMin);
3636 var yScale = opts.height / Math.abs(bounds.yMax - bounds.yMin);
3637 var scale = xScale < yScale ? xScale : yScale;
3638 var xoffset=opts.width/2-Math.abs(bounds.xMax - bounds.xMin)/2*scale;
3639 var yoffset=opts.height/2-Math.abs(bounds.yMax - bounds.yMin)/2*scale;
3640 context.beginPath();
3641 context.clearRect(0, 0, opts.width, opts.height);
3642 context.setFillStyle(opts.background||'#FFFFFF');
3643 context.rect(0,0,opts.width,opts.height);
3644 context.fill();
3645 for (var i = 0; i < data.length; i++) {
3646 context.beginPath();
3647 context.setLineWidth(mapOption.borderWidth * opts.pixelRatio);
3648 context.setStrokeStyle(mapOption.borderColor);
3649 context.setFillStyle(hexToRgb(series[i].color, mapOption.fillOpacity));
3650 if (opts.tooltip) {
3651 if (opts.tooltip.index == i ) {
3652 context.setStrokeStyle(mapOption.activeBorderColor);
3653 context.setFillStyle(hexToRgb(mapOption.activeFillColor, mapOption.activeFillOpacity));
3654 }
3655 }
3656 var coorda = data[i].geometry.coordinates
3657 for (var k = 0; k < coorda.length; k++) {
3658 coords = coorda[k];
3659 if (coords.length == 1) {
3660 coords = coords[0]
3661 }
3662 for (var j = 0; j < coords.length; j++) {
3663 point = coordinateToPoint(coords[j][1], coords[j][0],bounds,scale,xoffset,yoffset)
3664 if (j === 0) {
3665 context.beginPath();
3666 context.moveTo(point.x, point.y);
3667 } else {
3668 context.lineTo(point.x, point.y);
3669 }
3670 }
3671 context.fill();
3672 if(mapOption.border == true){
3673 context.stroke();
3674 }
3675 }
3676 if(opts.dataLabel == true){
3677 var centerPoint = data[i].properties.centroid;
3678 if(centerPoint){
3679 point = coordinateToPoint(centerPoint[1], centerPoint[0],bounds,scale,xoffset,yoffset);

Callers 1

drawChartsFunction · 0.85

Calls 5

getBoundingBoxFunction · 0.85
hexToRgbFunction · 0.85
coordinateToPointFunction · 0.85
measureTextFunction · 0.85
drawToolTipBridgeFunction · 0.85

Tested by

no test coverage detected