โมดูล ui.Chart.feature
มีชุดฟังก์ชันสำหรับการแสดงผลแผนภูมิจากออบเจ็กต์ Feature
และ FeatureCollection
การเลือกฟังก์ชันจะเป็นตัวกำหนดการจัดเรียงข้อมูลในแผนภูมิ เช่น ข้อมูลที่ใช้กำหนดค่าแกน x และแกน y รวมถึงข้อมูลที่ใช้กำหนดชุดข้อมูล ใช้คำอธิบายและตัวอย่างฟังก์ชันต่อไปนี้เพื่อเลือกฟังก์ชันและประเภทแผนภูมิที่เหมาะกับวัตถุประสงค์ของคุณมากที่สุด
ฟังก์ชันแผนภูมิ
ใช้ผังผนวกต่อไปนี้เป็นคู่มือภาพเพื่อทำความเข้าใจว่าฟังก์ชันแต่ละรายการจัดเรียงองค์ประกอบและพร็อพเพอร์ตี้ขององค์ประกอบเหล่านั้นในแผนภูมิอย่างไร กล่าวคือ องค์ประกอบใดกำหนดค่า x, ค่า y และชุด
ระบบจะพล็อตองค์ประกอบตามแกน X ตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลจะกำหนดโดยรายการชื่อพร็อพเพอร์ตี้ที่มีค่าซึ่งผังตามแนวแกน y
ระบบจะพล็อตพร็อพเพอร์ตี้องค์ประกอบตามชื่อบนแกน X ส่วนค่าของพร็อพเพอร์ตี้ที่ระบุจะพล็อตบนแกน Y ชุดคือฟีเจอร์ที่ติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก
ระบบจะพล็อตองค์ประกอบตามแกน X ตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลจะกำหนดโดยค่าที่ไม่ซ้ำของพร็อพเพอร์ตี้หนึ่งๆ ตำแหน่งในแนวตั้งจะกำหนดโดยค่าของพร็อพเพอร์ตี้หนึ่งๆ
ฮิสโตแกรมความถี่สำหรับค่าของพร็อพเพอร์ตี้ที่เลือก
- แกน X: ที่เก็บข้อมูลฮิสโตแกรมสําหรับค่าของพร็อพเพอร์ตี้ที่เลือก
- แกน Y: ความถี่ของฟีเจอร์ที่มีสิทธิ์สำหรับแต่ละที่เก็บข้อมูลฮิสโตแกรม
ตัวอย่างข้อมูล
ตัวอย่างต่อไปนี้ใช้ FeatureCollection
ที่ประกอบด้วยองค์ประกอบเขตนิเวศ 3 รายการที่มีพร็อพเพอร์ตี้ที่อธิบายสภาพภูมิอากาศปกติ
ดูวิธีสร้างข้อมูลตัวอย่าง
เครื่องมือแก้ไขโค้ด (JavaScript)
// Define three representative ecoregions in the USA. var desert = ee.Feature( ee.Geometry.Rectangle(-109.21, 31.42, -108.3, 32.03), {label: 'Desert', value: 0}); var forest = ee.Feature( ee.Geometry.Rectangle(-122.73, 43.45, -122.28, 43.91), {label: 'Forest', value: 1}); var grassland = ee.Feature( ee.Geometry.Rectangle(-101.81, 41.7, -100.53, 42.51), {label: 'Grassland', value: 2}); // Combine features into a feature collection. var ecoregions = ee.FeatureCollection([desert, forest, grassland]); // Load PRISM climate normals image collection; convert images to bands. var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands(); // Summarize climate normals for each ecoregion feature as a set or properties. ecoregions = normClim.reduceRegions( {collection: ecoregions, reducer: ee.Reducer.mean(), scale: 5e4}); // Add a property for whether January temperature is warm or not. ecoregions = ecoregions.map(function(ecoregion) { return ecoregion.set('warm', ee.Number(ecoregion.get('01_tmean')).gt(0)); });
ui.Chart.feature.byFeature
แผนภูมิคอลัมน์
ระบบจะพล็อตองค์ประกอบตามแกน X โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลจะแสดงด้วยคอลัมน์ที่อยู่ติดกันซึ่งกำหนดโดยรายการชื่อพร็อพเพอร์ตี้ที่มีค่าผังตามแนวแกน y
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define the chart and print it to the console. var chart = ui.Chart.feature .byFeature({ features: ecoregions.select('[0-9][0-9]_tmean|label'), xProperty: 'label', }) .setSeriesNames([ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]) .setChartType('ColumnChart') .setOptions({ title: 'Average Monthly Temperature by Ecoregion', hAxis: {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}}, vAxis: { title: 'Temperature (°C)', titleTextStyle: {italic: false, bold: true} }, colors: [ '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07', 'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969' ] }); print(chart);
แผนภูมิแท่ง
ระบบจะพล็อตองค์ประกอบตามแกน y โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลจะแสดงด้วยแถบที่อยู่ติดกันซึ่งกำหนดโดยรายการชื่อพร็อพเพอร์ตี้ที่มีค่าผังตามแกน x
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define the chart and print it to the console. var chart = ui.Chart.feature .byFeature({ features: ecoregions.select('[0-9][0-9]_tmean|label'), xProperty: 'label', }) .setSeriesNames([ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]) .setChartType('BarChart') .setOptions({ title: 'Average Monthly Temperature by Ecoregion', hAxis: { title: 'Temperature (°C)', titleTextStyle: {italic: false, bold: true} }, vAxis: {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}}, colors: [ '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07', 'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969' ] }); print(chart);
แผนภูมิคอลัมน์แบบซ้อน
สัมบูรณ์
ระบบจะพล็อตองค์ประกอบตามแกน X โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลจะแสดงด้วยคอลัมน์ที่ซ้อนกันซึ่งกำหนดโดยรายการชื่อพร็อพเพอร์ตี้ที่มีค่าซึ่งผังตามแนวแกน y เป็นผลรวมชุดข้อมูลที่สะสม
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define the chart and print it to the console. var chart = ui.Chart.feature .byFeature({ features: ecoregions.select('[0-9][0-9]_ppt|label'), xProperty: 'label' }) .setSeriesNames([ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]) .setChartType('ColumnChart') .setOptions({ title: 'Average Monthly Precipitation by Ecoregion', hAxis: {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}}, vAxis: { title: 'Precipitation (mm)', titleTextStyle: {italic: false, bold: true} }, colors: [ '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07', 'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969' ], isStacked: 'absolute' }); print(chart);
ญาติ
ระบบจะพล็อตองค์ประกอบตามแกน X โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลจะแสดงด้วยคอลัมน์ที่ซ้อนกันซึ่งกำหนดโดยรายการชื่อพร็อพเพอร์ตี้ที่มีค่าซึ่งผังตามแนวแกน y เป็นเปอร์เซ็นต์ของชุดข้อมูลที่รวมกัน
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define the chart and print it to the console. var chart = ui.Chart.feature .byFeature({ features: ecoregions.select('[0-9][0-9]_ppt|label'), xProperty: 'label' }) .setSeriesNames([ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]) .setChartType('ColumnChart') .setOptions({ title: 'Average Monthly Precipitation by Ecoregion', hAxis: {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}}, vAxis: { title: 'Precipitation (mm)', titleTextStyle: {italic: false, bold: true} }, colors: [ '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07', 'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969' ], isStacked: 'percent' }); print(chart);
แผนภูมิกระจาย
ระบบจะพล็อตองค์ประกอบตามแกน X โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลจะแสดงด้วยจุดที่กําหนดโดยรายการชื่อพร็อพเพอร์ตี้ซึ่งมีค่าที่ผังตามแนวแกน y
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define the chart and print it to the console. var chart = ui.Chart.feature .byFeature({ features: ecoregions, xProperty: 'label', yProperties: ['01_tmean', '07_tmean'] }) .setSeriesNames(['Jan', 'Jul']) .setChartType('ScatterChart') .setOptions({ title: 'Average Monthly Temperature by Ecoregion', hAxis: {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}}, vAxis: { title: 'Temperature (°C)', titleTextStyle: {italic: false, bold: true} }, pointSize: 10, colors: ['1d6b99', 'cf513e'], }); print(chart);
แผนภูมิผสม
ระบบจะพล็อตองค์ประกอบตามแกน X โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก ชุดข้อมูลแสดงด้วยจุดและคอลัมน์ที่กําหนดโดยรายการชื่อพร็อพเพอร์ตี้ ซึ่งค่าจะแสดงบนแกน y แผนภูมินี้สร้างขึ้นโดยใช้แกน 2 แกนและการจัดรูปแบบเฉพาะชุด
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define the chart and print it to the console. var chart = ui.Chart.feature .byFeature({ features: ecoregions, xProperty: 'label', yProperties: ['06_ppt', '06_tmean'] }) .setSeriesNames(['Precipitation', 'Temperature']) .setChartType('ColumnChart') .setOptions({ title: 'Average June Temperature and Precipitation by Ecoregion', series: { 0: {targetAxisIndex: 1, type: 'bar', color: '1d6b99'}, 1: { targetAxisIndex: 0, type: 'line', lineWidth: 0, pointSize: 10, color: 'e37d05' } }, hAxis: {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}}, vAxes: { 0: { title: 'Temperature (°C)', baseline: 0, titleTextStyle: {italic: false, bold: true, color: 'e37d05'} }, 1: { title: 'Precipitation (mm)', titleTextStyle: {italic: false, bold: true, color: '1d6b99'} }, }, bar: {groupWidth: '40%'}, }); print(chart);
ui.Chart.feature.byProperty
ตัวอย่างการตั้งค่า
ฟังก์ชัน ui.Chart.feature.byProperty
ยอมรับพจนานุกรมที่ช่วยให้คุณควบคุมป้ายกำกับและลำดับชื่อพร็อพเพอร์ตี้ตามแกน x ได้โดยการกำหนดค่าตัวเลขให้กับชื่อ แผนภูมิตารางกริดคาร์ทีเซียนต่อไปนี้ใช้ตัวเลือกนี้เพื่อตั้งค่าป้ายกำกับเดือนและจัดเรียงชื่อเดือนตามลำดับเวลาสำหรับปริมาณน้ำฝนเฉลี่ยรายเดือน
แผนภูมิคอลัมน์
ระบบจะพล็อตพร็อพเพอร์ตี้องค์ประกอบตามแกน x โดยติดป้ายกำกับและจัดเรียงตามข้อมูลพจนานุกรม ส่วนค่าของพร็อพเพอร์ตี้ที่ระบุจะพล็อตตามแกน y ชุดคือองค์ประกอบที่แสดงด้วยคอลัมน์ซึ่งมีป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก หากต้องการแปลงเป็นแผนภูมิแท่ง ให้ใช้ .setChartType('BarChart')
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define a dictionary that associates property names with values and labels. var precipInfo = { '01_ppt': {v: 1, f: 'Jan'}, '02_ppt': {v: 2, f: 'Feb'}, '03_ppt': {v: 3, f: 'Mar'}, '04_ppt': {v: 4, f: 'Apr'}, '05_ppt': {v: 5, f: 'May'}, '06_ppt': {v: 6, f: 'Jun'}, '07_ppt': {v: 7, f: 'Jul'}, '08_ppt': {v: 8, f: 'Aug'}, '09_ppt': {v: 9, f: 'Sep'}, '10_ppt': {v: 10, f: 'Oct'}, '11_ppt': {v: 11, f: 'Nov'}, '12_ppt': {v: 12, f: 'Dec'} }; // Organize property information into objects for defining x properties and // their tick labels. var xPropValDict = {}; // Dictionary to codify x-axis property names as values. var xPropLabels = []; // Holds dictionaries that label codified x-axis values. for (var key in precipInfo) { xPropValDict[key] = precipInfo[key].v; xPropLabels.push(precipInfo[key]); } // Define the chart and print it to the console. var chart = ui.Chart.feature .byProperty({ features: ecoregions, xProperties: xPropValDict, seriesProperty: 'label' }) .setChartType('ColumnChart') .setOptions({ title: 'Average Ecoregion Precipitation by Month', hAxis: { title: 'Month', titleTextStyle: {italic: false, bold: true}, ticks: xPropLabels }, vAxis: { title: 'Precipitation (mm)', titleTextStyle: {italic: false, bold: true} }, colors: ['f0af07', '0f8755', '76b349'], }); print(chart);
แผนภูมิเส้น
ระบบจะพล็อตพร็อพเพอร์ตี้องค์ประกอบตามแกน x โดยติดป้ายกำกับและจัดเรียงตามข้อมูลพจนานุกรม ส่วนค่าของพร็อพเพอร์ตี้ที่ระบุจะพล็อตตามแกน y ชุดข้อมูลคือองค์ประกอบที่แสดงด้วยเส้น โดยมีการติดป้ายกำกับด้วยค่าของพร็อพเพอร์ตี้ที่เลือก
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define a dictionary that associates property names with values and labels. var precipInfo = { '01_ppt': {v: 1, f: 'Jan'}, '02_ppt': {v: 2, f: 'Feb'}, '03_ppt': {v: 3, f: 'Mar'}, '04_ppt': {v: 4, f: 'Apr'}, '05_ppt': {v: 5, f: 'May'}, '06_ppt': {v: 6, f: 'Jun'}, '07_ppt': {v: 7, f: 'Jul'}, '08_ppt': {v: 8, f: 'Aug'}, '09_ppt': {v: 9, f: 'Sep'}, '10_ppt': {v: 10, f: 'Oct'}, '11_ppt': {v: 11, f: 'Nov'}, '12_ppt': {v: 12, f: 'Dec'} }; // Organize property information into objects for defining x properties and // their tick labels. var xPropValDict = {}; // Dictionary to codify x-axis property names as values. var xPropLabels = []; // Holds dictionaries that label codified x-axis values. for (var key in precipInfo) { xPropValDict[key] = precipInfo[key].v; xPropLabels.push(precipInfo[key]); } // Define the chart and print it to the console. var chart = ui.Chart.feature .byProperty({ features: ecoregions, xProperties: xPropValDict, seriesProperty: 'label' }) .setChartType('ScatterChart') .setOptions({ title: 'Average Ecoregion Precipitation by Month', hAxis: { title: 'Month', titleTextStyle: {italic: false, bold: true}, ticks: xPropLabels }, vAxis: { title: 'Precipitation (mm)', titleTextStyle: {italic: false, bold: true} }, colors: ['f0af07', '0f8755', '76b349'], lineSize: 5, pointSize: 0 }); print(chart);
แผนภูมิพื้นที่
ระบบจะพล็อตพร็อพเพอร์ตี้องค์ประกอบตามแกน x โดยติดป้ายกำกับและจัดเรียงตามข้อมูลพจนานุกรม ส่วนค่าของพร็อพเพอร์ตี้ที่ระบุจะพล็อตตามแกน y ชุดข้อมูลคือองค์ประกอบที่แสดงด้วยเส้นและพื้นที่แรเงา โดยมีการติดป้ายกำกับด้วยค่าของพร็อพเพอร์ตี้ที่เลือก
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define a dictionary that associates property names with values and labels. var precipInfo = { '01_ppt': {v: 1, f: 'Jan'}, '02_ppt': {v: 2, f: 'Feb'}, '03_ppt': {v: 3, f: 'Mar'}, '04_ppt': {v: 4, f: 'Apr'}, '05_ppt': {v: 5, f: 'May'}, '06_ppt': {v: 6, f: 'Jun'}, '07_ppt': {v: 7, f: 'Jul'}, '08_ppt': {v: 8, f: 'Aug'}, '09_ppt': {v: 9, f: 'Sep'}, '10_ppt': {v: 10, f: 'Oct'}, '11_ppt': {v: 11, f: 'Nov'}, '12_ppt': {v: 12, f: 'Dec'} }; // Organize property information into objects for defining x properties and // their tick labels. var xPropValDict = {}; // Dictionary to codify x-axis property names as values. var xPropLabels = []; // Holds dictionaries that label codified x-axis values. for (var key in precipInfo) { xPropValDict[key] = precipInfo[key].v; xPropLabels.push(precipInfo[key]); } // Define the chart and print it to the console. var chart = ui.Chart.feature .byProperty({ features: ecoregions, xProperties: xPropValDict, seriesProperty: 'label' }) .setChartType('AreaChart') .setOptions({ title: 'Average Ecoregion Precipitation by Month', hAxis: { title: 'Month', titleTextStyle: {italic: false, bold: true}, ticks: xPropLabels }, vAxis: { title: 'Precipitation (mm)', titleTextStyle: {italic: false, bold: true} }, colors: ['f0af07', '0f8755', '76b349'], lineSize: 5, pointSize: 0, curveType: 'function' }); print(chart);
แผนภูมิวงกลม
วงกลมคือฟีเจอร์ ส่วนแต่ละส่วนคือป้ายกำกับพร็อพเพอร์ตี้ที่มีค่าเป็นเปอร์เซ็นต์ของผลรวมของค่าทั้งหมดของพร็อพเพอร์ตี้ที่ประกอบกันเป็นวงกลม
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Subset the forest ecoregion feature and select the monthly precipitation // properties, rename them as abbreviated months. var thisForest = ecoregions.filter(ee.Filter.eq('label', 'Forest')) .select(Object.keys(precipInfo), [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]); // Define the chart and print it to the console. var chart = ui.Chart.feature .byProperty({ features: thisForest, xProperties: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] }) .setChartType('PieChart') .setOptions({ title: 'Average Monthly Precipitation for Forest Ecoregion', colors: [ '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07', 'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969' ] }); print(chart);
แผนภูมิโดนัท
แปลงแผนภูมิวงกลมเป็นแผนภูมิโดนัทโดยการตั้งค่าตัวเลือกแผนภูมิ pieHole
ตัวเลขระหว่าง 0.4 ถึง 0.6 จะดูดีที่สุดในแผนภูมิส่วนใหญ่
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Subset the forest ecoregion feature and select the monthly precipitation // properties, rename them as abbreviated months. var thisForest = ecoregions.filter(ee.Filter.eq('label', 'Forest')) .select(Object.keys(precipInfo), [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]); // Define the chart and print it to the console. var chart = ui.Chart.feature .byProperty({ features: thisForest, xProperties: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] }) .setChartType('PieChart') .setOptions({ title: 'Average Monthly Precipitation for Forest Ecoregion', colors: [ '604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07', 'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969' ], pieHole: 0.4, }); print(chart);
ui.Chart.feature.groups
แผนภูมิคอลัมน์
ระบบจะพล็อตองค์ประกอบตามแกน X โดยติดป้ายกำกับตามค่าของพร็อพเพอร์ตี้ที่เลือก
ชุดจะแสดงด้วยคอลัมน์ที่กําหนดโดยชุดค่าที่ไม่ซ้ำกันของพร็อพเพอร์ตี้หนึ่งๆ ตำแหน่งในแนวตั้งจะกำหนดโดยค่าของพร็อพเพอร์ตี้หนึ่งๆ แผนภูมินี้เปลี่ยนเป็นผังกระจายได้โดยการตั้งค่าประเภทแผนภูมิเป็น 'ScatterChart'
(.setChartType('ScatterChart')
) หรือหากเวลาเป็นตัวแปรแกน X คุณอาจต้องใช้แผนภูมิเส้น .setChartType('LineChart')
เครื่องมือแก้ไขโค้ด (JavaScript)
// Import the example feature collection. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example'); // Define the chart and print it to the console. var chart = ui.Chart.feature .groups({ features: ecoregions, xProperty: 'label', yProperty: '01_tmean', seriesProperty: 'warm' }) .setSeriesNames(['Warm', 'Cold']) .setChartType('ColumnChart') .setOptions({ title: 'Average January Temperature by Ecoregion', hAxis: {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}}, vAxis: { title: 'Jan temp (°C)', titleTextStyle: {italic: false, bold: true} }, bar: {groupWidth: '80%'}, colors: ['cf513e', '1d6b99'], isStacked: true }); print(chart);
ui.Chart.feature.histogram
แกน X กำหนดโดยกลุ่มค่าสำหรับช่วงค่าของพร็อพเพอร์ตี้ที่เลือก ส่วนแกน Y คือจํานวนองค์ประกอบในกลุ่มที่ระบุ
เครื่องมือแก้ไขโค้ด (JavaScript)
// Load PRISM climate normals image collection; convert images to bands. var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands(); // Make a point sample of climate variables for a region in western USA. var region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14); var climSamp = normClim.sample(region, 5000); // Define the chart and print it to the console. var chart = ui.Chart.feature .histogram({features: climSamp, property: '07_ppt', maxBuckets: 30}) .setOptions({ title: 'July Precipitation Distribution for NW USA', hAxis: { title: 'Precipitation (mm)', titleTextStyle: {italic: false, bold: true} }, vAxis: { title: 'Pixel count', titleTextStyle: {italic: false, bold: true} }, colors: ['1d6b99'], legend: {position: 'none'} }); print(chart);