zoukankan      html  css  js  c++  java
  • Delphi ArcEngine 创建Chart专题

    type 

       ChartType = (ctBarChart, ctPieChart, ctStackedChart);

    //创建柱状 饼状 stacked 专题

    //参数依次为 图层,字段集合,专题样式,chart大小,是否垂直放置(默认为否)

    function ChartRenderer(pLayer: ILayer; sField: TStringList; eChartSyle: ChartType; iChartSize: Byte; IsVerticalBar:   Boolean = False): Boolean;
    var
       pGeoLayer: IGeoFeatureLayer;
       pRenderer: IChartRenderer;
       pMarkerSymbol: IMarkerSymbol;
       pRendererFields: IRendererFields;
       vMaxVaule, value: Variant;
       pCursor  : ICursor;

       pDataStatics: IDataStatistics;
       pChartSymbol: IChartSymbol;
       pSymbolArray: ISymbolArray;
       pFillSymbol: ISimpleFillSymbol;
       pNormaliztion: IDataNormalization;
       pColor   : IColor;

       pBarChartSymbol: IBarChartSymbol;
       pPieChartRenderer: IPieChartRenderer;
       pPieChartSymbol: IPieChartSymbol;
       pStackedChartSymbol: IStackedChartSymbol;
       I        : Integer;

    begin
       pGeoLayer := pLayer as IGeoFeatureLayer;
       pRenderer := CoChartRenderer.Create as IChartRenderer;

       case eChartSyle of
          ctBarChart:
             begin
                pBarChartSymbol := CoBarChartSymbol.Create as IBarChartSymbol;
                pBarChartSymbol.VerticalBars := IsVerticalBar;
                pBarChartSymbol.Width := 5;
                pChartSymbol := pBarChartSymbol as IChartSymbol;
             end;
          ctPieChart:
             begin
                pPieChartSymbol := CoPieChartSymbol.Create as IPieChartSymbol;
                pPieChartSymbol.Clockwise := True;
                pPieChartSymbol.UseOutline := True;
                //使用  IPieChartRenderer 接口,来设置Piechart的高级属性
                pPieChartRenderer := pRenderer as IPieChartRenderer;
                pPieChartRenderer.ProportionalBySum := True; //饼图的直径和值相关
                pPieChartRenderer.MinSize := 2; //最小符号大小
                pPieChartRenderer.MinValue := 0.07; //用于渲染的最小值

                pChartSymbol := pPieChartSymbol as IChartSymbol;
             end;
          ctStackedChart:
             begin
                pStackedChartSymbol := CoStackedChartSymbol.Create as IStackedChartSymbol;
                pStackedChartSymbol.Width := 5;
                pStackedChartSymbol.VerticalBar := IsVerticalBar;

                pChartSymbol := pStackedChartSymbol as IChartSymbol;
             end;
       end;

       pSymbolArray := pChartSymbol as ISymbolArray;
       pRendererFields := pRenderer as IRendererFields;

       vMaxVaule := 0;
       //循环,统计所有值中的最大值并为每个要渲染的属性创建填充符号
       pDataStatics := CoDataStatistics.Create as IDataStatistics;

       for I := 0 to sField.Count - 1 do
       begin

          pRendererFields.AddField(sField.ValueFromIndex[I], sField.Names[I]);
          pDataStatics.Cursor := pGeoLayer.Search(nil, True) as ICursor;

          pDataStatics.Field := sField.ValueFromIndex[I];
          value := pDataStatics.Statistics.Maximum;

          if value > vMaxVaule then
          begin
             vMaxVaule := value;
          end;

          //创建统计图表各个部分的填充颜色
          pFillSymbol := CoSimpleFillSymbol.Create as ISimpleFillSymbol;
          pFillSymbol.Color := GetRandomColor();

          pSymbolArray.AddSymbol(pFillSymbol as ISymbol);
       end;

       pChartSymbol.MaxValue := vMaxVaule;

       pMarkerSymbol := pChartSymbol as IMarkerSymbol;
       pMarkerSymbol.Size := iChartSize;
       //填充背景
       pFillSymbol := CoSimpleFillSymbol.Create as ISimpleFillSymbol;
       pFillSymbol.Color := getRGB(157, 225, 215, 255);
       pRenderer.ChartSymbol := pChartSymbol;
       pRenderer.Label_ := '刘军生';
       pRenderer.UseOverposter := True; //当位置不够时可以移位
       pRenderer.CreateLegend;

       if pRenderer <> nil then
       begin
          pRenderer.BaseSymbol := pFillSymbol as ISymbol;
          pGeoLayer.Renderer := pRenderer as IFeatureRenderer;
          Result := True;
       end
       else
          Result := False;
    end;
  • 相关阅读:
    语句被终止。完成执行语句前已用完最大递归 100
    Sql日期时间格式转换(转)
    MVC 记录操作日志与过滤特殊字符
    掌握这些,自学效率嗖嗖的!
    正式开始聊聊自学那些事儿!
    《可执行的自学编程方法体系》前言-为什么我要分享自己的自学经验总结?
    系统化的学习才是有效的学习!
    知识学了就忘怎么办?
    “面试”是绝佳的学习方式!
    分水岭:知识的深度拓展
  • 原文地址:https://www.cnblogs.com/chinacodegear/p/1418750.html
Copyright © 2011-2022 走看看