您好,登錄后才能下訂單哦!
這個有現成的代碼,把代碼做一個簡要的說明,具體實現效果,是在TE的地圖畫一個餅狀圖。
<script type="text/javascript">
function createpie() {
//設置簡單參數,包括半徑等參數
var sum = 0;
var radius = 100;
var angle = 0;
var i;
//根據餅狀圖的分塊,設置不同的顏色
var color = [0x0000a0, 0x00ff60, 0x8000a0, 0xa0ff00, 0xff00ff, 0xff2000, 0x20c080, 0x402020, 0x8020a0, 0xff6060, 0xc0ffff, 0xff6060, 0x800040, 0xa00020];
for (i = 1; i < 10; i++) {
sum += i;
}
//選擇中心的位置,也可以自定義進行設置
var cenpoint = SGWorld.Window.CenterPixelToWorld(0);
var cpoint = cenpoint.Position;
var sx = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, radius, 0).X;
var sy = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, radius, 0).Y;
//根據每塊的比例,設置旋轉的角度,在polygon添加點
for (i = 1; i < 10; i++) {
var color1 = color[i];
var langle = angle + parseFloat(i) / parseFloat(sum) * 360;
var east = radius * Math.cos(2 * Math.PI * langle / 360);
var north = radius * Math.sin(2 * Math.PI * langle / 360);
var movcod = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, east, north);
var polygon = "POLYGON((" + cpoint.X.toString() + " " + cpoint.Y.toString() + "," + sx.toString() + " " + sy.toString();
var spl = (langle - angle) / 2;
for (var j = 0; j < spl; j++) {
var sinint = Math.sin((angle + j * 2) * Math.PI / 180) * radius;
var cosint = Math.cos((angle + j * 2) * Math.PI / 180) * radius;
var movcodspl = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, cosint, sinint);
polygon += "," + movcodspl.X.toString() + " " + movcodspl.Y.toString();
}
polygon += "," + movcod.X.toString() + " " + movcod.Y.toString() + "," + cpoint.X.toString() + " " + cpoint.Y.toString() + "))";
var igeometry = SGWorld.Creator.GeometryCreator.CreateGeometryFromWKT(polygon);
//根據點創建polygon
var ipolygon = SGWorld.Creator.CreatePolygon(igeometry, color1, color1, 0, 0, "polygon");
ipolygon.FillStyle.Color.SetAlpha(0.5);
sx = movcod.X;
sy = movcod.Y;
angle = langle;
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。