First, our top tool absolutely, absolutely gorgeous. If necessary code, you can add my micro letter request. 18500591275
A few days ago a customer to find me and asked if I can not do this, I see myself 10 years ago did end, so I really can not do, then people say you can do it for you 10000? I said to consider, when I have the money to move.
Wife is PharmD, Pa absolute science, go back and give my wife a look, and says to do, I write algorithm, you write the program does not get away with it? Well, a thousand dollars hand
2, step by step, we analyze the process of drawing.
First, we initialize canves object.
c = document.getElementById("canvas_circle");
ctx = c.getContext("2d");
Set local variables
= c.height RADIUS / 2 - 60; // radius OX RADIUS + = 450, RADIUS + Oy = 70; // center width = 30, height = 10; // legend width and height posX = ox * 2 + 20, = 30 posY; // textX = + width +. 5 posX, posY textY with the + = 10 ; IMG = $ ( "# logo_name") GET (0. ); ctx.drawImage (IMG, 30, 30, 100, 800 ); IMG = $ ( "# Tuli") GET (0. ); ctx.drawImage (IMG, 1250, 100, 220, 300);
Then the following sequence of operations.
// Draw outer pie DrawPie (OX, Oy, RADIUS); var innerWhiteR RADIUS = - 100 @ drawing white ring drawCircular (OX, Oy, innerWhiteR, "#fff" ) // draw a yellow ring var innerYellowR = the RADIUS - 130 ; drawCircular (ox, Oy, innerYellowR, "# fff34f" ) // draw a blue circle drawCircular (ox, Oy, the RADIUS - 135, "# 0445e1" ) // again draw a blue circle drawCircular (ox , Oy, the RADIUS - 140, "# 3370ff" )
// Draw inner pie var innerRPi RADIUS = - 195 ; DrawPie (OX, Oy, innerRPi, to true ); var radius1 to RADIUS + = 40 ; var outerSpaceR1 = + 20 is RADIUS ; var outerSpaceR2 RADIUS + = 40 ; var xixian. 3 = ; var cuxian = 15 ; // draw wire drawLine (OX, Oy, 0, innerRPi, cuxian, "#fff", 7.5 ); drawLine (OX, Oy, 0, innerRPi, xixian, "# 000", 7.5 ) ; drawLine (OX, Oy, innerYellowR, outerSpaceR2, cuxian,"#fff", 7.5); drawLine(ox, oy, innerYellowR, outerSpaceR2, xixian, "#000", 7.5,"xiaolan","07:30 日盘开始起动系统",1); drawLine(ox, oy, 0, innerRPi, cuxian, "#fff", 8 + (45/60)); drawLine(ox, oy, 0, innerRPi, xixian, "#000", 8 + (45 / 60)); drawLine(ox, oy, innerYellowR, outerSpaceR2, cuxian, "#fff", 8 + (45 / 60)); drawLine(ox, oy, innerYellowR, outerSpaceR2, xixian, "#000", 8 + (45 / 60), "xiaohong","08:55日盘集合竞价",2); drawLine(ox, oy, 0, innerRPi, cuxian, "#fff", 15); drawLine(ox, oy, 0, innerRPi, xixian, "#000", 15); DrawLine (OX, Oy, innerYellowR, outerSpaceR2, cuxian, "#fff", 15 ); drawLine (OX, Oy, innerYellowR, outerSpaceR2, xixian, "# 000", 15, "xiaoing", '15: 00 days Bi starts clearing disc tray ',. 7 ); the drawLine (OX, Oy, 0, innerRPi, cuxian, "#fff", 19.5 ); the drawLine (OX, Oy, 0, innerRPi, 2, "# 000", 19.5 ); drawLine (OX, Oy, innerYellowR, outerSpaceR2, cuxian, "#fff", 19.5 ); drawLine (OX, Oy, innerYellowR, outerSpaceR2, xixian, "# 000", 19.5, "xiaoing", '19: 30 nightplate start starting system ', 12 is ); the drawLine (OX, Oy,0, innerRPi, cuxian, "#fff", 20+(55/60)); drawLine(ox, oy, 0, innerRPi, 2, "#000", 20 + (55 / 60)); drawLine(ox, oy, innerYellowR, outerSpaceR2, cuxian, "#fff", 20 + (45 / 60)); drawLine(ox, oy, innerYellowR, outerSpaceR2, xixian, "#000", 20 + (45 / 60), "xiaoqiu", '20:55夜盘集合竞价',13); drawLine(ox, oy, 0, innerRPi, cuxian, "#fff", 23.5); drawLine(ox, oy, 0, innerRPi, xixian, "#000", 23.5); drawLine(ox, oy, innerYellowR, outerSpaceR2, cuxian, "#fff", 23.5); drawLine(ox, oy, innerYellowR, outerSpaceR2, xixian, "# 000 ", 23.5," xiaoing "," 23:30 began to shut down the system ", 15); // draw double // Draw a single line drawLine (OX, Oy, innerYellowR, innerWhiteR, xixian, "# 000", 9 ); drawLine (OX, Oy, innerWhiteR, the RADIUS, xixian, "#eee", 9 ) ; drawLine (OX, Oy, the RADIUS, outerSpaceR1, xixian, "# 000", 9, "xiaoing", '9: 00 solar disk consecutive trading began', 3 ); drawLine (OX, Oy, innerYellowR, innerWhiteR, xixian, "# 000", 10.25 ); drawLine (OX, Oy, innerWhiteR, the RADIUS, xixian, "#eee", 10.25 ); drawLine (OX, Oy, the RADIUS, outerSpaceR1, xixian, "# 000", 10.25, "xiaoqiu" "10:15 solar disk closed to 10:30",4); drawLine(ox, oy, innerYellowR, innerWhiteR, xixian, "#000", 11.5); drawLine(ox, oy, innerWhiteR, radius, xixian, "#eee", 11.5); drawLine(ox, oy, radius, outerSpaceR1, xixian, "#000", 11.5, "xiaoqiu",'11:30 日盘休市至13:30',5); drawLine(ox, oy, innerYellowR, innerWhiteR, xixian, "#000", 13.5); drawLine(ox, oy, innerWhiteR, radius, xixian, "#eee", 13.5); drawLine(ox, oy, radius, outerSpaceR1, xixian, "#000", 13.5, "xiaoqiu", '13:30 日盘持续交易',6); drawLine(ox, oy,innerYellowR, interior whiter, Xixian, "# 000", 15.5); drawLine(ox, oy, innerWhiteR, radius, xixian, "#eee", 15.5); drawLine(ox, oy, radius, outerSpaceR1, xixian, "#000", 15.5, "xiaoqiu","15:30 结算完成",8); drawLine(ox, oy, innerYellowR, innerWhiteR, xixian, "#000", 16.67); drawLine(ox, oy, innerWhiteR, radius, xixian, "#eee", 16.67); drawLine(ox, oy, radius, outerSpaceR1, xixian, "#000", 16.67, "xiaoqiu",'16:40 日盘开始关闭系统',9); drawLine(ox, oy, innerYellowR, innerWhiteR, xixian, "#000", 17); drawLine(ox, oy, innerWhiteR, radius, xixian, "#eee", 17); DrawLine (OX, Oy, the RADIUS, outerSpaceR1, xixian, "# 000", 17, "xiaoqiu", "solar disk three centers in two data backup", 10 ); drawLine (OX, Oy, innerYellowR, innerWhiteR, xixian , "# 000", 18 ); drawLine (OX, Oy, innerWhiteR, the RADIUS, xixian, "#eee", 18 ); drawLine (OX, Oy, the RADIUS, outerSpaceR1, xixian, "# 000", 18, "xiaoqiu "'17: 00 to 19:00 for system maintenance ', 11 ); drawLine (OX, Oy, innerYellowR, innerWhiteR, xixian, " # 000 ", 21 ); drawLine (OX, Oy, innerWhiteR, the RADIUS, xixian, " #eee ", 21 ); drawLine (OX, Oy,radius, outerSpaceR1, xixian, "# 000", 21, " xiaoqiu", '21:00 nightplate consecutive trading began', 14 ); drawLine (OX, Oy, innerYellowR, innerWhiteR, xixian, "# 000", 23.75 ); drawLine (OX, Oy , innerWhiteR, the RADIUS, xixian, "#eee", 23.75 ); drawLine (OX, Oy, the RADIUS, outerSpaceR1, xixian, "# 000", 23.75, "xiaoqiu", 'night 23:35 disk data backup', 16 ) ; // draw pictures drawPic (); no classification ();
There are writing function
function DrawPie(oxInput, oyInput, radiusInput, drawText) {
///////////////// 绘制扇面
//第一个点
var begAngle = 0 - (Math.PI / 12) * 6.5;
var endAngle = 0 + (Math.PI / 12) * 1.5;
ctx.fillStyle = '#8e97e4';
ctx.beginPath();
ctx.moveTo(oxInput, oyInput);
ctx.arc(oxInput, oyInput, radiusInput, begAngle, endAngle);
ctx.closePath();
ctx.fill();
if (drawText) {
ctx.save();
= ctx.textAlign 'Center';
ctx.textBaseline = 'Middle';
ctx.font = 'Arial Bold 11pt'
ctx.fillStyle = '# 000';
ctx.translate (oxInput, oyInput);
ctx.fillText ( "nightplate data backup ", Math.sin (Math.PI * 2/ 24 * 3) * radiusInput * .7 + 10, Math.cos (Math.PI * 2/24 * 3) * radiusInput * (-1) *. 7 );
ctx.fillText ( "night disc closing", Math.sin (Math.PI * 2/ 24 * 3) * radiusInput * .7 + 10, Math.cos (Math.PI * 2/24 * 3) * radiusInput * (-1) * + 20 is .7);
ctx.fillText ( "closed system", Math.sin (Math.PI * 2/ 24 * 3) * radiusInput * .7 + 10, Math.cos (Math. PI * 2/24 * 3) * radiusInput * (-1) * .7 + 40);
ctx.restore();
}
//第二个点
begAngle = endAngle
endAngle += (Math.PI / 720) * 85;
ctx.fillStyle = '#8de3e4';
ctx.beginPath();
ctx.moveTo(oxInput, oyInput);
ctx.arc(oxInput, oyInput, radiusInput, begAngle, endAngle);
ctx.closePath();
ctx.fill();
if (drawText) {
ctx.save();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = 'bold 11pt Arial'
ctx.fillStyle = '#000';
ctx.translate(Math.sin(Math.PI * 2 / 24 * 8.25) * (radiusInput*0.76) + oxInput,
oyInput - Math.cos(Math.PI * 2 / 24 * 8.25) * (radiusInput * 0.76));
ctx.rotate(Math.PI * 2 / 24 * 2.2);
ctx.fillText("日盘系统起动", 0, 0);
ctx.restore();
}
// third point
begAngle = endAngle
endAngle + = (Math.PI / 720.) * 365;
ctx.fillStyle = '#8de398';
ctx.beginPath();
ctx.moveTo(oxInput, oyInput);
ctx.arc(oxInput, oy, radiusInput, begAngle, endAngle);
ctx.closePath();
ctx.fill();
if (drawText) {
ctx.save();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = 'bold 11pt Arial'
ctx.fillStyle = '#000';
ctx.translate(oxInput, oyInput);
ctx.fillText("日盘连续交易", Math.sin(Math.PI * 2 / 24 * 12) * radiusInput * .7 , Math.cos(Math.PI * 2 / 24 * 12) * radiusInput * (-1) * .7);
ctx.restore();
}
// fourth points
begAngle = endAngle
endAngle + = (Math.PI / 720.) * 270;
ctx.fillStyle = '#e3e38d';
ctx.beginPath();
ctx.moveTo(oxInput, oyInput);
ctx.arc(oxInput, oyInput, radiusInput, begAngle, endAngle);
ctx.closePath();
ctx.fill();
if (drawText) {
ctx.save();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = 'bold 11pt Arial'
ctx.fillStyle = '#000';
ctx.translate(oxInput, oyInput);
ctx.fillText("每日结算", Math.sin(Math.PI * 2 / 24 * 17) * radiusInput * .7 + 10, Math.cos(Math.PI * 2 / 24 * 17) * radiusInput * (-1) * .7-40);
ctx.fillText("数据备份", Math.sin(Math.PI * 2 / 24 * 17) * radiusInput * .7 + 10, Math.cos(Math.PI * 2 / 24 * 17) * radiusInput * (-1) * .7-20 );
ctx.fillText("日盘闭市", Math.sin(Math.PI * 2 / 24 * 17) * radiusInput * .7 + 10, Math.cos(Math.PI * 2 / 24 * 17) * radiusInput * (-1) * .7 );
ctx.fillText("系统维护", Math.sin(Math.PI * 2 / 24 * 17) * radiusInput * .7 + 10, Math.cos(Math.PI * 2 / 24 * 17) * radiusInput * (-1) * .7 + 20);
ctx.restore();
}
// The fifth point
begAngle = endAngle
endAngle + = (Math.PI / 720) * 85;
ctx.fillStyle = '#e2b58c';
ctx.beginPath();
ctx.moveTo(oxInput, oyInput);
ctx.arc(oxInput, oyInput, radiusInput, begAngle, endAngle);
ctx.closePath();
ctx.fill();
if (drawText) {
ctx.save();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = 'bold 11pt Arial'
ctx.fillStyle = '#000';
ctx.translate(Math.sin(Math.PI * 2 / 24 * 20.25) * (radiusInput * 0.76) + oxInput,
oyInput - Math.cos(Math.PI * 2 / 24 * 20.25) * (radiusInput * 0.76));
ctx.rotate(Math.PI * 2 / 24 * 2.2);
ctx.fillText("夜盘系统起动", 0, 0);
ctx.restore();
}
// first six points
begAngle = endAngle
endAngle + = (Math.PI / 720.) * 155;
ctx.fillStyle = '#e38d8e';
ctx.beginPath();
ctx.moveTo(oxInput, oyInput);
ctx.arc(oxInput, oyInput, radiusInput, begAngle, endAngle);
ctx.closePath();
ctx.fill();
if (drawText) {
ctx.save();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = 'bold 11pt Arial'
ctx.fillStyle = '#000';
ctx.translate(Math.sin(Math.PI * 2 / 24 * 22) * (radiusInput * 0.7) + oxInput,
oyInput - Math.cos(Math.PI * 2 / 24 * 22) * (radiusInput * 0.7));
ctx.rotate(Math.PI * 2 / 24 *4);
ctx.fillText("夜盘连续交易", 0, 0);
ctx.restore();
}
////////////////////////
}
function drawCircular(oxInput, oyInput, radiusInput, fillStyle) { ctx.beginPath(); ctx.arc(oxInput, oyInput, radiusInput, 0, Math.PI * 2, false); ctx.fillStyle = fillStyle; ctx.fill(); }