This document is archived and information here might be outdated.  Recommended version.

How to create a function series graph (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Interacting with and configuring maps, layers, and graphics > Working with graphs > How to create a function series graph

How to create a function series graph

This topic shows how to create a function graph and make changes to function-specific parameters.

Creating a function series graph

To create a function series graph, modify the following parameters:
  • pathToShapeFile - The path to shapefile to build the function graph.
  • seriesFieldName - The numerical field used to build the bar series as the data source for function series.
  • pathToOutImage - The output file containing an image of the graph (see the application programming interface [API] documentation for the appropriate format extension in IDataGraphBase.ExportToFile).
See the following code example:
namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            IAoInitialize ao=new AoInitializeClass();
            SampleFunctionSmoothing(@"path to your shapefile", "field name", @
                "path to your output image");

        static void SampleFunctionSmoothing(String pathToShapeFile, String
            seriesFieldName, String pathToOutImage)

            // Open workspace for input shapefile.
            IWorkspaceFactory shapefileWorkspaceFactory=new
            IWorkspace shapefileWorkspace;
                (System.IO.Path.GetDirectoryName(pathToShapeFile), 0);
            IFeatureWorkspace featureWorkspace=(IFeatureWorkspace)

            // Get table for input shapefile.
            ITable table=(ITable)featureWorkspace.OpenFeatureClass

            // Create data graph.
            IDataGraphT dataGraphT=new DataGraphTClass();

            // Add bar series.
            ISeriesProperties seriesProps=dataGraphT.AddSeries("bar:vertical");
            seriesProps.SetField(1, seriesFieldName);

            // Add function series.
            ISeriesProperties funcSeriesProps=dataGraphT.AddSeries("ftSmoothing");

            // The only valid data source for the function series is another nonfunction series unique name.

            // Set smoothing function-specific parameters.
            IFunctionSeriesProperties funcProps=(IFunctionSeriesProperties)
            funcProps.set_Property("FACTOR", 4);
            funcProps.set_Property("LINE_PASSES_POINTS", true);

            // Update data graph.

            // Export graph to file (format depends on file extension).
Namespace ConsoleApplication1VBNET

Class Program
    Shared Sub Main(ByVal args() As String)
    Dim ao As IAoInitialize=New AoInitializeClass()
    SampleFunctionSmoothing("path to your shapefile", "field name", "path to your output image")
End Sub

Shared Sub SampleFunctionSmoothing(ByVal pathToShapeFile As String, ByVal seriesFieldName As String, ByVal pathToOutImage As String)

' Open workspace for input shapefile.
Dim shapefileWorkspaceFactory As IWorkspaceFactory=New ShapefileWorkspaceFactoryClass()
Dim shapefileWorkspace As IWorkspace
shapefileWorkspace=shapefileWorkspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(pathToShapeFile), 0)
Dim featureWorkspace As IFeatureWorkspace=CType(shapefileWorkspace, IFeatureWorkspace)

' Get table for input shapefile.
Dim table As ITable=CType(featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(pathToShapeFile)), ITable)

' Create data graph.
Dim dataGraphT As IDataGraphT=New DataGraphTClass()

' Add bar series.
Dim seriesProps As ISeriesProperties=dataGraphT.AddSeries("bar:vertical")
seriesProps.SetField(1, seriesFieldName)

' Add function series.
Dim funcSeriesProps As ISeriesProperties=dataGraphT.AddSeries("ftSmoothing")

' The only valid data source for the function series is another nonfunction series unique name.

' Set smoothing function-specific parameters.
Dim funcProps As IFunctionSeriesProperties=CType(funcSeriesProps, IFunctionSeriesProperties)

' Update data graph.

' Export graph to file (format depends on file extension).
End Sub

End Class

End Namespace

To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced