▾
Average hail size and property damage estimates over months, with two y-axes measuring different types of values (inches vs dollars).
What is a combo bar line chart?
Combo bar line charts provide the visualization of bar and line series in a single chart, allowing you to use the appropriate series type for the data, while also being able to compare and analyze the relationship between the two series.
The x-axis represents discrete categories or continuous values depending on the field type. The y-axis or y-axes represent the associated numeric value that corresponds to each category or continuous interval on the x-axis.
Data configurations
This section covers a few data configuration examples for combo bar line charts, each configured using the combo bar line chart model. See the combo bar line chart model reference for the full list of available properties and methods.
With one y-axis
When both the bar and line series are all measuring the same type of value, or are at least in a similar range, use a single y-axis to visualize the data.
- Set the
xAxisFieldproperty to"mo"to use the unique values in the months field as the x-axis categories. - Set the
numericFieldsproperty to["loss", "closs"]to specify the fields that will be visualized. - Next use the
setSeriesTypemethod to set the series type for each field. In this case, set the"loss"field (property damage) to be rendered as bars and the"closs"field (agricultural loss) to be rendered as a line.
32 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Combo Bar Line Chart</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "5972242f44714758b97c415a62a49ad5", }, }); const chartElement = document.querySelector("arcgis-chart"); const comboBarLineChartModel = await createModel({ layer: featureLayer, chartType: "comboBarLineChart", }); comboBarLineChartModel.xAxisField = "mo"; comboBarLineChartModel.numericFields = ["loss", "closs"]; // Set series type for each numeric fieid comboBarLineChartModel.setSeriesType(0, "barSeries"); comboBarLineChartModel.setSeriesType(1, "lineSeries");12 collapsed lines
comboBarLineChartModel.setSeriesColor([78, 121, 167, 100], 0); comboBarLineChartModel.setSeriesColor([242, 142, 44, 100], 1); comboBarLineChartModel.setSeriesLineWidth(5, 1); comboBarLineChartModel.setAxisTitleText("Months", 0); comboBarLineChartModel.setAxisTitleText("Dollar Value", 1); comboBarLineChartModel.titleText = "Average Property Damage Estimates and Crop Loss Over Months"; comboBarLineChartModel.legendPosition = "top"; chartElement.model = comboBarLineChartModel; chartElement.actionMode = "none"; </script> </body></html>With two y-axes
When the two series are measuring different types of values, or are in very different ranges, use two y-axes to visualize the data. The primary y-axis will be used for the first series, and the secondary y-axis will be used for the second series.
- With the similar data configuration steps as the previous example, set the x-axis field and numeric fields, and define the series type for each field.
- Then use the
setSeriesToSecondaryYAxismethod to assign the second series to the secondary y-axis.
37 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Combo Dual Axes</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "5972242f44714758b97c415a62a49ad5", }, }); const chartElement = document.querySelector("arcgis-chart"); const comboBarLineChartModel = await createModel({ layer: featureLayer, chartType: "comboBarLineChart", }); comboBarLineChartModel.xAxisField = "mo"; comboBarLineChartModel.numericFields = ["mag", "loss"]; comboBarLineChartModel.aggregationType = "avg"; comboBarLineChartModel.setSeriesType(0, "lineSeries"); comboBarLineChartModel.setSeriesType(1, "barSeries"); comboBarLineChartModel.setSeriesToSecondaryYAxis(true, 1);13 collapsed lines
comboBarLineChartModel.setSeriesColor([78, 121, 167, 100], 0); comboBarLineChartModel.setSeriesColor([242, 142, 44, 100], 1); comboBarLineChartModel.setSeriesLineWidth(8, 1); comboBarLineChartModel.setAxisTitleText("Months", 0); comboBarLineChartModel.setAxisTitleText("Inches", 1); comboBarLineChartModel.setAxisTitleText("Dollar Value", 2); comboBarLineChartModel.titleText = "Average Hail Size and Average Property Damage Estimates Over Months"; comboBarLineChartModel.legendPosition = "top"; chartElement.model = comboBarLineChartModel; chartElement.actionMode = "none"; </script> </body></html>