Biểu đồ Feature và FeatureCollection

Mô-đun ui.Chart.feature chứa một tập hợp các hàm để kết xuất biểu đồ từ các đối tượng FeatureFeatureCollection. Lựa chọn hàm xác định cách sắp xếp dữ liệu trong biểu đồ, tức là những gì xác định giá trị trục x và trục y cũng như những gì xác định chuỗi. Hãy sử dụng nội dung mô tả và ví dụ về hàm sau đây để xác định hàm và loại biểu đồ phù hợp nhất với mục đích của bạn.

Hàm biểu đồ

Hãy sử dụng các sơ đồ biểu đồ sau đây làm hướng dẫn trực quan để hiểu cách mỗi hàm sắp xếp các tính năng và thuộc tính của các tính năng đó trong biểu đồ; tức là những phần tử nào xác định giá trị x, giá trị y và chuỗi.

ui.Chart.feature.byFeature

Các đặc điểm được lập biểu đồ dọc theo trục x theo các giá trị của một thuộc tính đã chọn. Chuỗi được xác định bằng danh sách tên thuộc tính có giá trị được lập biểu đồ dọc theo trục y.

ui.Chart.feature.byProperty

Các thuộc tính của đối tượng được lập biểu đồ dọc theo trục x theo tên; các giá trị của các thuộc tính nhất định được lập biểu đồ dọc theo trục y. Chuỗi là các đặc điểm được gắn nhãn theo giá trị của một thuộc tính đã chọn.

ui.Chart.feature.groups

Các đặc điểm được lập biểu đồ dọc theo trục x theo các giá trị của một thuộc tính đã chọn. Chuỗi được xác định bằng các giá trị riêng biệt của một thuộc tính nhất định. Vị trí trục Y được xác định bằng giá trị của một thuộc tính nhất định.

ui.Chart.feature.histogram

Biểu đồ tần suất cho các giá trị của một thuộc tính đã chọn.

  • Trục X: các nhóm biểu đồ cho các giá trị của một thuộc tính đã chọn
  • Trục Y: tần suất của các đặc điểm đủ điều kiện cho mỗi bộ chứa biểu đồ

Dữ liệu mẫu

Các ví dụ sau đây dựa trên FeatureCollection bao gồm ba tính năng vùng sinh thái có các thuộc tính mô tả thông tin bình thường về khí hậu.

Xem cách tạo dữ liệu mẫu

Trình soạn thảo mã (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

Biểu đồ cột

Các đặc điểm được lập biểu đồ dọc theo trục x, được gắn nhãn theo giá trị của một thuộc tính đã chọn. Chuỗi được biểu thị bằng các cột liền kề được xác định bằng danh sách tên thuộc tính có giá trị được lập biểu đồ dọc theo trục y.

Trình soạn thảo mã (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);

Biểu đồ thanh

Các đặc điểm được lập biểu đồ dọc theo trục y, được gắn nhãn theo giá trị của một thuộc tính đã chọn. Chuỗi được biểu thị bằng các thanh liền kề được xác định bằng danh sách tên thuộc tính có giá trị được lập biểu đồ dọc theo trục x.

Trình soạn thảo mã (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);

Biểu đồ cột xếp chồng

Tuyệt đối

Các đặc điểm được lập biểu đồ dọc theo trục x, được gắn nhãn theo giá trị của một thuộc tính đã chọn. Chuỗi được biểu thị bằng các cột xếp chồng được xác định bằng danh sách tên thuộc tính có giá trị được lập biểu đồ dọc theo trục y dưới dạng tổng tích luỹ của chuỗi.

Trình soạn thảo mã (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);

Họ hàng

Các đặc điểm được lập biểu đồ dọc theo trục x, được gắn nhãn theo giá trị của một thuộc tính đã chọn. Chuỗi được biểu thị bằng các cột xếp chồng được xác định bằng danh sách tên thuộc tính có giá trị được lập biểu đồ dọc theo trục y dưới dạng phần trăm của chuỗi tổng hợp.

Trình soạn thảo mã (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);

Biểu đồ tán xạ

Các đặc điểm được lập biểu đồ dọc theo trục x, được gắn nhãn theo giá trị của một thuộc tính đã chọn. Chuỗi được biểu thị bằng các điểm được xác định theo danh sách tên thuộc tính có giá trị được lập biểu đồ dọc theo trục y.

Trình soạn thảo mã (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);

Biểu đồ kết hợp

Các đặc điểm được lập biểu đồ dọc theo trục x, được gắn nhãn theo các giá trị của một thuộc tính đã chọn. Chuỗi được biểu thị bằng các điểm và cột được xác định bằng danh sách tên thuộc tính có giá trị được lập biểu đồ dọc theo trục y. Biểu đồ này được tạo bằng cách sử dụng hai trục và kiểu dành riêng cho chuỗi.

Trình soạn thảo mã (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

Ví dụ về cách thiết lập

Hàm ui.Chart.feature.byProperty chấp nhận một từ điển cho phép bạn kiểm soát nhãn và thứ tự của tên thuộc tính dọc theo trục x bằng cách chỉ định giá trị số cho các tên đó. Các biểu đồ lưới Descartes sau đây sử dụng tuỳ chọn này để đặt nhãn tháng và sắp xếp tên tháng theo thứ tự thời gian cho lượng mưa trung bình hằng tháng.

Biểu đồ cột

Các thuộc tính của đối tượng được lập biểu đồ dọc theo trục x, được gắn nhãn và sắp xếp theo đầu vào từ điển; các giá trị của các thuộc tính nhất định được lập biểu đồ dọc theo trục y. Chuỗi là các đặc điểm, được biểu thị bằng cột, được gắn nhãn bằng giá trị của một thuộc tính đã chọn. Để chuyển đổi sang biểu đồ thanh, hãy sử dụng .setChartType('BarChart').

Trình soạn thảo mã (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);

Biểu đồ dạng đường

Các thuộc tính của đối tượng được lập biểu đồ dọc theo trục x, được gắn nhãn và sắp xếp theo đầu vào từ điển; các giá trị của các thuộc tính nhất định được lập biểu đồ dọc theo trục y. Chuỗi là các đặc điểm, được biểu thị bằng các đường, được gắn nhãn bằng giá trị của một thuộc tính đã chọn.

Trình soạn thảo mã (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);

Biểu đồ vùng

Các thuộc tính của đối tượng được lập biểu đồ dọc theo trục x, được gắn nhãn và sắp xếp theo đầu vào từ điển; các giá trị của các thuộc tính nhất định được lập biểu đồ dọc theo trục y. Chuỗi là các đặc điểm, được biểu thị bằng các đường và vùng được tô bóng, được gắn nhãn bằng các giá trị của một thuộc tính đã chọn.

Trình soạn thảo mã (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);

Biểu đồ hình tròn

Biểu đồ hình tròn là một tính năng, mỗi lát là một nhãn thuộc tính có giá trị được chuyển đổi dưới dạng tỷ lệ phần trăm của tổng tất cả giá trị của các thuộc tính tạo nên biểu đồ hình tròn.

Trình soạn thảo mã (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);

Biểu đồ vòng

Chuyển đổi biểu đồ hình tròn thành biểu đồ vòng bằng cách đặt tuỳ chọn biểu đồ pieHole; các con số từ 0,4 đến 0,6 sẽ hiển thị tốt nhất trên hầu hết các biểu đồ.

Trình soạn thảo mã (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

Biểu đồ cột

Các đặc điểm được lập biểu đồ dọc theo trục x, được gắn nhãn theo các giá trị của một thuộc tính đã chọn. Chuỗi được biểu thị bằng các cột được xác định theo tập hợp giá trị riêng biệt của một thuộc tính nhất định. Vị trí trục Y được xác định bằng giá trị của một thuộc tính nhất định. Bạn có thể thay đổi biểu đồ này thành biểu đồ tán xạ bằng cách đặt loại biểu đồ thành 'ScatterChart' (.setChartType('ScatterChart')). Ngoài ra, nếu thời gian là biến trục x, bạn nên sử dụng biểu đồ đường: .setChartType('LineChart').

Trình soạn thảo mã (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

Trục x được xác định bằng các nhóm giá trị cho phạm vi giá trị của một thuộc tính đã chọn; trục y là số lượng phần tử trong nhóm đã cho.

Trình soạn thảo mã (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);