<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Drawing a chart to show average values in a column when Scene Layer is selected in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/drawing-a-chart-to-show-average-values-in-a-column/m-p/424586#M39063</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trying to create a chart based on average values in a column, tried usiing this script, where Z is the column that has my values, but the chart doesn't work, the values are also below zero but my chart axis seem to start from -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 function updateSceneLayer() {
 const query = sceneLayerView.createQuery();
 query.geometry = sketchGeometry;
 query.distance = bufferSize;
 return sceneLayerView.queryObjectIds(query).then(highlightBuildings);
 }

var depthChart = null;

function queryStatistics() {
 const statDefinitions = [
 {
 onStatisticField:
 "Z",
 outStatisticFieldName: "depth",
 statisticType: "avg"
 }
 ];
 const query = sceneLayerView.createQuery();
 query.geometry = sketchGeometry;
 query.distance = bufferSize;
 query.outStatistics = statDefinitions;

return sceneLayerView.queryFeatures(query).then(function(result) {
 const allStats = result.features[0].attributes;
 
 updateChart(depthChart, [
 allStats.depth
 
 ]);
 }, console.error);
 }

// Updates the given chart with new data
 function updateChart(chart, dataValues) {
 chart.data.datasets[0].data = dataValues;
 chart.update();
 }

function createDepthChart() {
 const depthCanvas = document.getElementById("depth-chart");
 yearChart = new Chart(depthCanvas.getContext("2d"), {
 type: "horizontalBar",
 data: {
 labels: [
 "A1"
 ],
 datasets: [
 {
 label: "Depth",
 backgroundColor: "#149dcf",
 stack: "Stack 0",
 data: [0]
 }
 ]
 },
 options: {
 responsive: true,
 legend: {
 display: true
 },
 title: {
 display: true,
 text: "xx"
 },
 scales: {
 xAxes: [
 {
 stacked: true,
 ticks: {
 beginAtZero: false,
 precision: 0
 }
 }
 ],
 yAxes: [
 {
 stacked: true
 }
 ]
 }
 }
 });
 }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:27:29 GMT</pubDate>
    <dc:creator>EniolaBabatunde</dc:creator>
    <dc:date>2021-12-12T16:27:29Z</dc:date>
    <item>
      <title>Drawing a chart to show average values in a column when Scene Layer is selected</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/drawing-a-chart-to-show-average-values-in-a-column/m-p/424586#M39063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trying to create a chart based on average values in a column, tried usiing this script, where Z is the column that has my values, but the chart doesn't work, the values are also below zero but my chart axis seem to start from -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 function updateSceneLayer() {
 const query = sceneLayerView.createQuery();
 query.geometry = sketchGeometry;
 query.distance = bufferSize;
 return sceneLayerView.queryObjectIds(query).then(highlightBuildings);
 }

var depthChart = null;

function queryStatistics() {
 const statDefinitions = [
 {
 onStatisticField:
 "Z",
 outStatisticFieldName: "depth",
 statisticType: "avg"
 }
 ];
 const query = sceneLayerView.createQuery();
 query.geometry = sketchGeometry;
 query.distance = bufferSize;
 query.outStatistics = statDefinitions;

return sceneLayerView.queryFeatures(query).then(function(result) {
 const allStats = result.features[0].attributes;
 
 updateChart(depthChart, [
 allStats.depth
 
 ]);
 }, console.error);
 }

// Updates the given chart with new data
 function updateChart(chart, dataValues) {
 chart.data.datasets[0].data = dataValues;
 chart.update();
 }

function createDepthChart() {
 const depthCanvas = document.getElementById("depth-chart");
 yearChart = new Chart(depthCanvas.getContext("2d"), {
 type: "horizontalBar",
 data: {
 labels: [
 "A1"
 ],
 datasets: [
 {
 label: "Depth",
 backgroundColor: "#149dcf",
 stack: "Stack 0",
 data: [0]
 }
 ]
 },
 options: {
 responsive: true,
 legend: {
 display: true
 },
 title: {
 display: true,
 text: "xx"
 },
 scales: {
 xAxes: [
 {
 stacked: true,
 ticks: {
 beginAtZero: false,
 precision: 0
 }
 }
 ],
 yAxes: [
 {
 stacked: true
 }
 ]
 }
 }
 });
 }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:27:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/drawing-a-chart-to-show-average-values-in-a-column/m-p/424586#M39063</guid>
      <dc:creator>EniolaBabatunde</dc:creator>
      <dc:date>2021-12-12T16:27:29Z</dc:date>
    </item>
  </channel>
</rss>

