Select to view content in your preferred language

Add public charting classes to ArcGIS Pro SDK

2388
5
01-17-2018 10:28 AM
Status: Open
Labels (1)
StephenRhea
Regular Contributor

I'm able to create line charts, profile graphs, etc. on a feature layer, but I have to use the CIMChart classes in the ArcGIS.Core.Internal.CIM namespace. I don't see any documentation online (yay IntelliSense), and the namespace implies that it isn't intended for "public" use. The solution is built solely on trial and error.

I was informed that charting built into the Python library (Chart—ArcPy classes | ArcGIS Desktop), but it isn't currently available in the .NET SDK. We have a tool in a few ArcMap extensions that allows users to sketch a line segment, then runs LOS analysis on the segment and generates a profile graph so the user has multiple visualizations. We're trying to migrate to ArcGIS Pro, so this functionality would be very beneficial.

5 Comments
StephenRhea

I found a workaround in the meantime. It's not ideal since we aren't a Python shop, but it works.

  1. Create a Python toolbox containing a tool that creates the chart. (Creating a new Python toolbox—Geoprocessing and Python | ArcGIS Desktop)
  2. In the Add-In, create a new project item from the .pyt file and add it to the project.
  3. Call the tool the same way a geoprocessing tool is called.

var toolboxPath = @"C:\PythonScripts\CustomExtensions.pyt";
var newItem = ItemFactory.Instance.Create(toolboxPath) as IProjectItem;

await QueuedTask.Run(() =>
{
   Project.Current.RemoveItem(newItem);
   Project.Current.AddItem(newItem);
});

var cancellableProgressor = new CancelableProgressorSource("Calling the script", "");

Geoprocessing.ExecuteToolAsync("ChartTool_CustomExtensions", new List<string>(), null, cancellableProgressor.Progressor);
KarenMeinstein

Hey Stephen,  I'm currently trying to create a simple line chart in Pro.  You said you were able to do that using the CIMChart classes.  I've been poking around trying to do that without any luck.  Could you possible provide the code that you used?

TimWhiteaker

+1 for charting functionality in Pro via the SDK!

I am porting an ArcMap add-in to Pro. In ArcMap, a user could click a feature in the map to create a plot from data in a related time series table (standalone table in the map). If the user clicked another feature, a second line would be added to the same graph if it was still visible.  And so on.

Another tool would generate a separate graph for each selected feature in a layer.

If a unique value renderer is applied to the feature layer, the graphed line shows up as the same color as the feature.

No brushing capabilities (e.g., selecting a data point in the graph will also select the related time series row) are required.

I shipped a template tee chart (*.tee) in the add-in file to set a lot of default properties for the appearance of the chart, so that I only had to deal with minimal adjustments in the code.

Thanks, Stephen, for initiating this Idea!

TimWhiteaker

Actually, brushing is not only not required, but is avoided. The user may want to show different time ranges in each plot, and would thus not want previously generated plots to be automatically updated to reflect whatever selection was on the table.