ပြန်လည်ပေးရန် ဂျက်လီ
- အရေးပါသော ဂျက်တာစက် ဂဲဂူ
- နောက်ပိုင်း ဂျက်တာစက် အမှတ်ပြု
D3.js သည် အမြန်မြန်သော HTML အခြေခံ အကျယ်အဝန်း အသုံးပြုကြည့်သည်
D3.js ကို အသုံးပြုခြင်း လွယ်ကူသည်
အကြောင်းကြားချက်
ကျွန်ုပ်တို့ ဘုတ်အသုံးပြုကာ D3.js ကို စက်တင်ကြည့်သည်
<script src="//d3js.org/d3.v3.min.js"></script>
အဲဒါ့ သည် ဘုတ်အသုံးပြုကာ "Hello World!" စကားလုံး ပါဝင်သော ပုံစံကို တိုက်ရိုက် စက်တင်ကြည့်သည်
d3.select("body").append("p").text("Hello World!");
အနောက်ပိုင်းဆန်
အမှုထမ်း
// အကျယ်အဝန်း ကျသည် const xSize = 500; const ySize = 500; const margin = 40; const xMax = xSize - margin*2; const yMax = ySize - margin*2; // လျှပ်စီးသည်များ ဖန်တီးကြည့်သည် const numPoints = 100; const data = []; for (let i = 0; i < numPoints; i++) { data.push([Math.random() * xMax, Math.random() * yMax]); } // ပြည်ဘာသာပြင်အရာဝတ္တုကို စက်တင်ကြည့်သည် const svg = d3.select("#myPlot") .append("svg") .append("g") .attr("transform","translate(\" + margin + \",\" + margin + \")"); // X အစိတ် const x = d3.scaleLinear(); .domain([0, 500]); .range([0, xMax]); svg.append("g"); .attr("transform", "translate(0," + yMax + ")"); .call(d3.axisBottom(x)); // Y အစိတ် const y = d3.scaleLinear(); .domain([0, 500]); .range([ yMax, 0]); svg.append("g"); .call(d3.axisLeft(y)); // နီးပါး svg.append('g'); .selectAll("dot"); .data(data).enter(); .append("circle"); .attr("cx", function (d) { return d[0] }); .attr("cy", function (d) { return d[1] }); .attr("r", 3); .style("fill", "Red");
- အရေးပါသော ဂျက်တာစက် ဂဲဂူ
- နောက်ပိုင်း ဂျက်တာစက် အမှတ်ပြု