Support for Delimited Sequential Files With Esri HTML5 Charts

How to:

When you generate an Esri map chart in HTML5 format, your request needs to point to a location that describes the geography for the request location values. Starting in this release, you can point to a comma-separated value (.csv) file, or other delimited file, that contains the names of the regions you want to show on the map and their longitude and latitude values.

Syntax: How to Define Properties for a Delimited File

If you are using a delimited file for your geometry data, you can add a csvOptions object to the layer that will access the file for its geometry data. However, there are defaults for all of the options. Therefore, if your file conforms to the default options, you do not need to include the csvOptions object.

The default .file will not have a first row containing field names (titles). It will be comma-delimited with a \n line-end character at the end of each line. It will contain the following three values per line:

  1. The name of the geometric location enclosed in single or double quotation marks. This field will be referred to as region in the map extensions properties.
  2. The longitude that corresponds to the region, which is referred to as lng in the map extensions properties.
  3. The latitude that corresponds to the region, which is referred to as lat in the map extensions properties.

If your file does not conform to these criteria, you can describe the structure of your file using the csvOptions object in your layer properties.

extensions: {
  "com.esri.map": {
    overlayLayers:
    [
     {
        csvOptions :
         {fieldNames: ['fld1', 'fld2', 'fld3'], 
          fieldSep: 'fsep', 
          lineSep: 'lsep', 
          firstRowIsTitles: tboolean, 
          removeSurroundingQuotes: qboolean} 
       }
    ],
                   } 
                     }

where:

['fld1', 'fld2', 'fld3']

Are the field names in your .csv file. The default values are ['region', 'lng', 'lat'].

'fsep'

Is the field separator character in your .csv file. The default value is a comma (','). It can be any printable character.

'lsep'

Is the line separator string in your .csv file. The default value is a line end character ('\n').

tboolean

Specifies whether the first row in your file contains titles. Valid values are:

  • true, if your file has a first row containing titles. If it does, these names will take precedence over the field names listed in the fieldNames object. When you specify the value of geometryLocateField, use the title from the delimited file.
  • false, if your file does not have a first row containing titles. This is the default value. If you specified a fieldNames object, use the value of the appropriate field name as the geometryLocateField value.
qboolean

Specifies whether to remove quotation marks surrounding values in your file. Valid values are:

  • true, to remove quotation marks surrounding values. This is the default value.
  • false, if your file does not have quotation marks surrounding values.

The following are the default values for the csvOptions object:

csvOptions:
     {
      fieldNames: ['region', 'lng', 'lat'], 
      fieldSep: ',', 
      lineSep: '\n', 
      firstRowIsTitles: false, 
      removeSurroundingQuotes: true
     }

The following layer properties must then be set to values that correspond to your csvOptions:

title: "layertitle",
layerType: "layertype",
geometrySourceType: "csv",
geometryLocateField: ["locationfld"],
url:"url_to_csv_file"

where:

"layertitle"

Is a title for the layer.

"layertype"

Is the type of layer. Valid values are:

  • choropleth. Displays a WebFOCUS choropleth layer.
  • bubble. Displays a WebFOCUS bubblemap layer.
"locationfld"

Is the field name for the geometry locator field. If your .csv file has titles, the value should come from the file. If not, it should be the appropriate field name from the fieldNames property of your csvOptions object. If neither of these is specified, use the default, which is 'region'.

"url_to_csv_file"

Is the url that points to your .csv file.

Example: Using a .csv File to Generate a Bubblemap

The country.csv file contains longitude and latitude values for each country.

Following are the first few lines of the country.csv file:

"Argentina",-64.00000000,-34.00000000
"Australia",133.00000000,-27.00000000
"Austria",13.33330000,47.33330000
"Belgium",4.00000000,50.83330000
"Brazil",-55.00000000,-10.00000000
"Canada",-95.00000000,60.00000000
"Chile",-71.00000000,-30.00000000
"China",105.00000000,35.00000000
"Colombia",-72.00000000,4.00000000

The following request generates a bubblemap chart that shows days delayed by country using the country.csv file as the geometry data file. This file conforms to the default structure, so no csvOptions object is included in the layer properties:

GRAPH FILE WF_RETAIL_LITE
SUM DAYSDELAYED 
MIN.DAYSDELAYED
BY COUNTRY_NAME
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET LOOKGRAPH BUBBLEMAP
ON GRAPH SET STYLE *
TYPE=REPORT, CHART-LOOK=com.esri.map, $
TYPE=DATA, COLUMN=country_name, BUCKET=location, $
TYPE=DATA, COLUMN=daysdelayed, BUCKET=size, $
TYPE=DATA, COLUMN=min.daysdelayed, BUCKET=color, $
*GRAPH_JS
"extensions": {
  "com.esri.map": {
    "drawToc": "true",
    "baseLayer": {
      "title": "base title",
      "basemap": "streets"
                },
    "overlayLayers": [
      {
         "title": "csv default",
         "layerType": "bubble",
        "geometrySourceType": "csv",
        "geometryLocateField": ["region"],
         "url": "http://ecl.informationbuilders.com/jschart/country.csv"
      }
                       ],
                    }
                  }
*END
ENDSTYLE
END

The output is shown in the following image:

The following file (named countryp.txt) has a row with titles as the first row, the separator is a pipe character (|), and the values are enclosed in double quotation marks. The first several lines in the file are shown below:

"Country"|"lng"|"lat"
"Argentina"|"-64.0000000"|"-34.0000000"
"Australia"|"133.0000000"|"-27.0000000"
"Austria"|"13.3333000"|"47.3333000"
"Belgium"|"4.0000000"|"50.8333000"
"Brazil"|"-55.0000000"|"-10.0000000"
"Canada"|"-95.0000000"|"60.0000000"

The following version of the request uses this file. It has a csvOptions object to describe the non-default options. Since the file has titles, no fieldNames object is included. The title row in the file specifies “Country” as the geometry locator field:

GRAPH FILE WF_RETAIL_LITE
SUM DAYSDELAYED 
MIN.DAYSDELAYED
BY COUNTRY_NAME
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET LOOKGRAPH BUBBLEMAP
ON GRAPH SET STYLE *
TYPE=REPORT, CHART-LOOK=com.esri.map, $
TYPE=DATA, COLUMN=country_name, BUCKET=location, $
TYPE=DATA, COLUMN=daysdelayed, BUCKET=size, $
TYPE=DATA, COLUMN=min.daysdelayed, BUCKET=color, $
*GRAPH_JS
"extensions": {
  "com.esri.map": {
    "drawToc": "true",
    "baseLayer": {
      "title": "base title",
      "basemap": "streets"
                       },
    "overlayLayers": [
      {
        "title": "csv options",
     
        csvOptions:
         {
            fieldSep: '|',
            firstRowIsTitles: true, 
            removeSurroundingQuotes: true
         } ,
        "layerType": "bubble",
        "geometrySourceType": "csv",       
        "geometryLocateField": ["Country"],
         "url": "http://ecl.informationbuilders.com/jschart/countryp.txt"
       }
                               ],
                                  }
                           }
*END
ENDSTYLE
END

The output is shown in the following image:

WebFOCUS

Feedback