Zum Hauptinhalt gehen

How to make a chart from a workflow?

Kommentare

7 Kommentare

  • Pairin Mason

    Hi Kees,

     

    There are two ways to configure charts with Workflows.

     

    Firstly, you can use a Workflow to create a data set of Features - either by querying a layer that's outside the application or manually creating new Features from some other data source(s). You can then use the "Run Command" activity to execute "charts.display" and pass the created Features along in the arguments. If you use this method, you will need to configure the Chart in Designer by either using the provided form elements or a custom Arcade script in the "Advanced Mode"; this configuration is what translates the Features into the data that the chart displays.

     

    Secondly, you can work directly with the HighCharts API (https://api.highcharts.com/highcharts/) to create a chart object with raw data, which you can compile within the Workflow itself. You can then use the "Run Command" activity to execute "charts.update-definition" and pass the Highcharts.chart object along in the arguments. You can then activate the chart using the "Run Command" activity to execute "ui.activate" and pass in the ID of the chart (which can be found in the Layout's XML) into the arguments.

     

    Cheers,

    Pairin

     

    (Thank you for the detail @Mathew Sedgwick? )

    0
  • Permanently deleted user

    Hi Pairin,

     

    Do you have an example that compiles the chart object with the HighCharts API? I have a feature layer and try to create a chart with workflow on GXW.

     

    0
  • Andrew Adamson

    Attached is a quick and dirty example of how I do them. Same idea as Pairins 2nd method but charts.display vs ui.activate at the end. IMO, the first method - workflow as source through the Web UI - is a PITA, have to deal with arcade, and less options. Just build the chart def/data in a workflow.

     

    To note, Pairins second point. Being able to work directly with the HighCharts API is massive and adds loads of freedom to what you can do in Web/Charts. Once you get a simple chart to render with your data, you will spend most of your time in their API configuring the chart to meet your needs.

     

    1
  • Nelson Dobbs

    Andrew Adamson - are you able to share your workflow here again?  I think it got removed when they moved to the new community platform.

    I am working through this currently and looking for examples and it sounds like your method is the way to go.

     

    Thank you!

    0
  • Peter Haddrill

    I attempted both options as suggested by Pairin without any luck. The only thing that works is the ui.activate command, which opens an existing chart if any layer is set as the data source (chart auto-displays if you do an Identify anyway. If I close that chart with Identify result still open, the ui.activate command in my workflow re-opens it). No success setting a workflow as the data source though.

    What I really want to achieve is the 2nd option to obtain the input data from the workflow and pass that into a chart. For context, I need to query a raster surface based on sample points along a user drawn polyline, then pass the query results into a chart.

    As an initial test, I tried to use this very basic Highcharts definition from their API page here https://www.highcharts.com/docs/getting-started/your-first-chart but without success. Browser console shows the commands execute without any errors/exceptions. Tested about 15 variations, but I feel like this should be the closest config based on Pairin’s option 2 and the sdk doco. “chart-93daedd1” is ID of an existing chart with default config in my VS Web app.

    >>Run Command activity

    Command Name: charts.update-definition

    Command Parameter: ={ "chart": "chart-93daedd1", "definition": {"chart":{"type":"bar"},"title":{"text":"Fruit Consumption"},"xAxis":{"categories":["Apples","Bananas","Oranges"]},"yAxis":{"title":{"text":"Fruit eaten"}},"series":[{"name":"Jane","data":[1,0,4]},{"name":"John","data":[5,7,3]}]} }

    >>Run Command activity

    Command Name: ui.activate

    Command Parameter: ="chart-93daedd1"

    >>Run Command activity

    Command Name: charts.display

    Command Parameter: ={ "chart": "chart-93daedd1" }

    >>VSW app and workflows I used for testing are saved in this folder https://drive.google.com/drive/folders/1zDtf8HJHBf6wfTmrcqGVrjXygZsBCQs4?usp=sharing

    Does anyone have a basic working example they can kindly share?

    0
  • Hadrien Bourdon

    Any news on this topic? I am also stuck at the run command on the workflow side which doesn't work...

    EDIT: https://support.vertigis.com/hc/en-us/community/posts/15149828513682-Chart-does-not-get-data-from-Workflow-in-Studio-Web

    1
  • Peter Haddrill

    Following the advice in Hadrien's link above, I was able to get this working in these scenarios; 1. chart using workflow as the data source, 2. chart using a Web Map layer as the data source. The 2nd scenario however, only works if the Query Layer takes its input layer from Get Layer activity.

    I feel like something is baked into the object that holds those specific query results, so only its allowed to supply the chart with data. That data still flows to the chart even if its modified along way, e.g. attributes/geometry changed inside its features collection. But if you try and append feature/s to the features collection that came from another layer or manually constructed feature/s, data from those is excluded from the chart (even though the schema's match). Perhaps I'm missing something.

    Anyway, I uploaded a copy of my VertiGIS Web app and workflows to demonstrate the above 2 scenarios as working examples. ZIP saved here: https://drive.google.com/file/d/179E5SavsQXBY_yaUSI3EQfJoiskOuSys/view?usp=sharing

    Also, a video demo of the workflows working: https://drive.google.com/file/d/14daLyimOTUqtOhvvo2LEhsFa-KK5r27m/view?usp=sharing  

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.