如何以编程方式使用arcgis的datagraphwindow

时间:2010-07-22 11:08:45

标签: arcgis

我一直在尝试在axmapcontrol上绘制地图,并使用相同的ITable在IDataGraphwindow2中创建散点图。不幸的是,图表显示的数据正确,但图表上没有点击事件。左键单击显示内存错误,右键单击显示禁用的菜单。对于左键单击我认为DataGraphTUI.dll是负责任的。当我们加载IDataGraphWindow2时,我们不会初始化它,因为它可能会出错。

请找到以下代码。

IDataGraphWindow2 pDGWin;
IDataGraphT dataGraphT = new DataGraphTClass();
IWorkspace shapefileWorkspace = null;
IWorkspaceFactory shapefileWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
shapefileWorkspace = shapefileWorkspaceFactory.OpenFromFile("C:\\abc.shp "), 0);
featureWorkspace = (IFeatureWorkspace)shapefileWorkspace;

featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension("c:\\abc.shp"));

ITable gobjJoinedTable = (ITable)featureLayer.FeatureClass;

LoadaxMap(); /// a method to load up the axmapcontrol

dataGraphT.UseSelectedSet = true;
dataGraphT.HighlightSelection = true;
dataGraphT.GeneralProperties.Title = "Scatter Graph";
dataGraphT.LegendProperties.Visible = false;
dataGraphT.get_AxisProperties(0).Title = "Y Axis";
dataGraphT.get_AxisProperties(0).Logarithmic = false;
dataGraphT.get_AxisProperties(2).Title = "X Axis";
dataGraphT.get_AxisProperties(2).Logarithmic = false;

ISeriesProperties seriesProps = dataGraphT.AddSeries("scatter_plot");
seriesProps.SourceData = axMap.get_Layer(0) as ITable; // axMap is the map control. Itable direct binding also works here

seriesProps.SetField(0, "abc.shp-fieldname"); // you may add any fieldname
seriesProps.SetField(1, "abc.shp-fieldname");

dataGraphT.Update(null);
dataGraphT.UseSelectedSet = true;
dataGraphT.HighlightSelection = false;
dataGraphT.Update(null);
pDGWin = new DataGraphWindowClass();
pDGWin.DataGraphBase = dataGraphT;
pDGWin.PutPosition(546, 155, 1040, 540);
pDGWin.Show(true);

内存错误是 模块“DatagraphTUI.dll”中地址为0F4E358B的访问冲突。阅读addess 00000000

1 个答案:

答案 0 :(得分:2)

显示图表时遇到同样的问题。 使用以下代码行修正了它:

graphWindow.Application = ArcMap.Application

它需要的只是对ArcMap应用程序的引用。