I use ArcGIS Pro 2.9.0 and ArcGIS JavaScript. I am new to using my feature sets with ArcGIS JavaScript.

I have a point feature set on ArcGIS Online (https://services2.arcgis.com/iVTT0jpvWSmHS8yL/arcgis/rest/services/GPR_punkt/FeatureServer/layers) that has two attributes I want to show some basic statistics of. It is the column year and hectare.

By doing summarize and create bar chart of the summarization in ArcGIS Pro, I got exactly what I want, a simple and basic statistic over the area (in hecatare) that has been run each year:

statistic hisotgram

The problem arises when I want to show this in my online map (located at https://kartla.xyz/html/gf.html)

I am unsure what tool is the right one for this, and I want one that does not use the current map view or anything like that. Only a statistic for all of the records.

I created a box (I found an example online) that I want to populate with this data:

// UI-element

const titleContent = document.createElement("div");
titleContent.style.padding = "15px";
titleContent.style.backgroundColor = "white";
titleContent.style.width = "500px"; titleContent.innerHTML = [ "

Vi tester

", ].join(" ");

const titleExpand = new Expand({ expandIconClass: "esri-icon-dashboard", expandToottip: "Summary stats", view: view, content: titleContent, expanded: view.widthBreakpoint !== "xsmall" }); view.ui.add(titleExpand, "top-right");

Should I do a query inside this? Or is histogram or StatisticDefinition the best solution? I know I could just paste a picture of my findings from ArcGIS Pro, but then I have a problem when I add more data for 2021.

  • You could use d3.js to draw diagram in your box, see for example observablehq.com/@d3/histogram
    – TomazicM
    Commented Dec 1, 2021 at 18:45
  • I was thinking how to use some of ArcGIS JavaScript modules and widgets to replicate the same results that I have done in ArcGIS Pro, then show it inside the element. Commented Dec 2, 2021 at 9:02
  • Years ago I worked on a project where we pulled data from ArcGIS Server feature services (probably via simple queries to the REST endpoints) and displayed it popup windows using Highcharts. Commented Dec 4, 2021 at 2:41

1 Answer 1


Using the ArcGIS API for JavaScript, once the layer has loaded, you can use a "group by" query on the layer to get the summary statistics that you want. Then display/format the table/chart as you wish.


  gfPunkt.when(() => {
    const statsQuery = gfPunkt.createQuery();
    // create a query for both Count and Hectares
    statsQuery.outStatistics = [
        onStatisticField: "hectare",
        outStatisticFieldName: "Counts",
        statisticType: "count"
        onStatisticField: "hectare",
        outStatisticFieldName: "Hectares",
        statisticType: "sum"
    // group by year
    statsQuery.groupByFieldsForStatistics = ["year"];
    // return the results ordered by year
    statsQuery.orderByFields = "year";

Full example code at https://codepen.io/bsvensson/pen/WNZQoqO

screenshot of table


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.