Question : Complete the methods that draw a bar chart from an array of integer data
สร้างฟังก์ชันวาดแผนภูมิจาก array ของข้อมูลจำนวนเต็ม
Answer :
void setup() {
size (450, 450);
background(25);
}
void draw () {
int x = 50;
int i = 0;
int y = 50;
int [] B = {13,20, 14,10, 22,28, 32 } ;
while (i < B.length) {
textSize(10);
fill(#1B9AF7);
rect (x, 380, 20, -B[i]*10);
fill (#FC0AA8);
text(B[i]+"", x,400);
i = i + 1;
x = x + 50;
}
textSize(19);
fill (#FC0AA8);
text("integer data ", 50, 50);
}
source : Java for students
Douglas Bell and Mike Parr. -- 2nd ed. page 253
ISBN : 0-13010922-3
ไม่มีความคิดเห็น:
แสดงความคิดเห็น