• 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;
  • 相关阅读:
    redis集群登陆
    锁机制
    关系型数据库事务遵循ACID原则
    前端之Css
    Python之操作redis数据库
    前端之HTML
    Excel之批量改变特定字体颜色(转载)
    jmeter之批量修改请求路径
    Python之time模块
    Python之os模块
  • 原文地址:https://www.cnblogs.com/chinacodegear/p/1418750.html
Copyright © 2020-2023  润新知