Creating a graph template
To use the code in this topic, modify the following parameter:
pathToOutImage—The output file containing an image of the graph. Refer to the application programming interface (API) documentation for the appropriate format extension in IDataGraphBase.ExportToFile.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
IAoInitialize ao = new AoInitializeClass();
ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeBasic);
SampleTemplate(@"path to your output image");
ao.Shutdown();
}
static void SampleTemplate(String pathToOutImage)
{
// Create a data graph.
IDataGraphT dataGraphT = new DataGraphTClass();
// Set the graph title as an example of graph furniture to be saved in the graph template.
dataGraphT.GeneralProperties.Title =
"This title was loaded from a graph template";
dataGraphT.Update(null);
// Create the name of the graph template file. The file must have a .tee extension.
string templateName = System.IO.Path.GetTempFileName();
templateName = System.IO.Path.ChangeExtension(templateName, ".tee");
// Export the graph as a template.
dataGraphT.ExportToFile(templateName);
// Create a new data graph.
IDataGraphT dataGraphT2 = new DataGraphTClass();
// Load the previously exported template to the new graph.
dataGraphT2.LoadTemplate(templateName);
// Update the data graph.
dataGraphT2.Update(null);
// Export the graph to file (the format depends on the file extension).
// Look for a graph title as an example of graph furniture loaded from the graph template.
dataGraphT2.ExportToFile(pathToOutImage);
// Delete the intermediate template file.
System.IO.File.Delete(templateName);
}
}
}
[VB.NET]
Namespace ConsoleApplication1VBNET
Class Program
Shared Sub Main(ByVal args() As String)
Dim ao As IAoInitialize = New AoInitializeClass()
ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeBasic)
SampleTemplate("path to your output image")
ao.Shutdown()
End Sub
Shared Sub SampleTemplate(ByVal pathToOutImage As String)
' Create a data graph.
Dim dataGraphT As IDataGraphT = New DataGraphTClass()
' Set the graph title as an example of graph furniture to be saved in the graph template.
dataGraphT.GeneralProperties.Title = "This title was loaded from a graph template"
dataGraphT.Update(Nothing)
' Create the name of the graph template file. The file must have a .tee extension.
Dim templateName As String = System.IO.Path.GetTempFileName()
templateName = System.IO.Path.ChangeExtension(templateName, ".tee")
' Export the graph as a template.
dataGraphT.ExportToFile(templateName)
' Create a new data graph.
Dim dataGraphT2 As IDataGraphT = New DataGraphTClass()
' Load the previously exported template to the new graph.
dataGraphT2.LoadTemplate(templateName)
' Update the data graph.
dataGraphT2.Update(Nothing)
' Export the graph to file (the format depends on the file extension).
' Look for a graph title as an example of graph furniture loaded from the graph template.
dataGraphT2.ExportToFile(pathToOutImage)
' Delete the intermediate template file.
System.IO.File.Delete(templateName)
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):
ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)ESRI.ArcGIS.Geodatabase ESRI.ArcGIS.DataSourcesFile ESRI.ArcGIS.Catalog ESRI.ArcGIS.Display ESRI.ArcGIS.Carto ESRI.ArcGIS.CartoUI System System.Collections.Generic System.Text
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |