Code Monkey home page Code Monkey logo

Comments (5)

zhengniu avatar zhengniu commented on June 16, 2024 1

Thanks alot for pointing out the tricky part - using different field names in outStatisticFieldName and orderByFields
I kept trying to use "cast" for onStatisticField but using the same field names for those two fields. It always gives me error like "MAX_MAX_De_sum is not valid parameter".

really appreciated for your help!!

from cedar.

zhengniu avatar zhengniu commented on June 16, 2024

anyone from ESRI team can help please?

from cedar.

tomwayson avatar tomwayson commented on June 16, 2024

You might try balloonFunction in your overrides instead of balloonText.

Alternatively, instead of calling chart.show() w/ overrides you can call chart.query(), chart.updateData(), and chart.render() like:

chart.query().then(response => {
  // query returns an object with dataset names as keys and the corresponding query responses as values
  // in your case, there's only one dataset, `dataset1`
  const datasetData = response['dataset1'];
  // pass the data to a function that performs any calculations and/or formatting
  const transformedData = myFunctionToTransformData(datasetData);
  // update the chart instance data and render the chart
  return chart.updateData({ dataset1: transformedData }).render();
});

from cedar.

zhengniu avatar zhengniu commented on June 16, 2024

You might try balloonFunction in your overrides instead of balloonText.

Alternatively, instead of calling chart.show() w/ overrides you can call chart.query(), chart.updateData(), and chart.render() like:

chart.query().then(response => {
  // query returns an object with dataset names as keys and the corresponding query responses as values
  // in your case, there's only one dataset, `dataset1`
  const datasetData = response['dataset1'];
  // pass the data to a function that performs any calculations and/or formatting
  const transformedData = myFunctionToTransformData(datasetData);
  // update the chart instance data and render the chart
  return chart.updateData({ dataset1: transformedData }).render();
});

Hi Tom, @tomwayson

because I am trying to apply above JSON Chart Definition to the Chart Card in ArcGIS Hub.

so I try below in overrides

"balloonFunction": "function(graphDataItem){
   return {graphDataItem.values.value}.numberFormat( "#,###.00")   

}"

it returns error
VM241:47 Uncaught SyntaxError: Unexpected token
in JSON at position 1209

from cedar.

tomwayson avatar tomwayson commented on June 16, 2024

I'm sorry, I missed that you are in Hub. You are correct, the balloonFunction would not be allowed in that context.

You've already tried many of the same things I would have (numberFormatter), as well as some things that I would not have thought of (cast() - good idea!) and you got very close. I was able to expand on your idea of using cast() to make it work:

image

What I did was include a non-cast stat column for sorting purposes and then I was able to remove many of the overrides:

{
  "type": "bar-horizontal",
  "datasets": [
    {
      "name": "dataset1",
      "query": {
        "where": "FIRST_Stre <>' ' and FIRST_Stre <> 'Hwy 7'",
        "orderByFields": "MAX_MAX_De_sum DESC",
        "groupByFieldsForStatistics": "FIRST_Stre",
        "having": "SUM(MAX_MAX_De)>24",
        "outStatistics": [
          {
            "statisticType": "sum",
            "onStatisticField": "Cast(MAX_MAX_De as decimal(10,2))",
            "outStatisticFieldName": "MAX_MAX_De_sum_formatted"
          },
          {
            "statisticType": "sum",
            "onStatisticField": "MAX_MAX_De",
            "outStatisticFieldName": "MAX_MAX_De_sum"
          }
        ]
      },
      "url": "https://services.arcgis.com/6iGx1Dq91oKtcE7x/arcgis/rest/services/UUID_Delay_Summary_Hourly_pub_view1/FeatureServer/0"
    }
  ],
  "series": [
    {
      "source": "dataset1",
      "category": {
        "field": "FIRST_Stre",
        "label": "Highway"
      },
      "value": {
        "field": "MAX_MAX_De_sum_formatted",
        "label": "Delay (in sec)"
      }
    }
  ],
  "style": {
    "colors": [
      "#026873"
    ]
  },
  "overrides": {
  "valueAxes": [{
    "title": "Elevation (feets)"
  }]
}
}

from cedar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.