Это все необходимые константы для работы с диаграммами.
Код:
interface
uses Graphics;
const
//----------- Виды диаграмм ----------------------------------
xlColumnClustered=51; //Column Clustered Column
xl3DColumnClustered=54; // 3D Clustered Column
xlColumnStacked=52; // Stacked Column
xl3DColumnStacked=55; // 3D Stacked Column
xlColumnStacked100=53; // 100% Stacked Column
xl3DColumnStacked100=56; // 3D 100% Stacked Column
xl3DColumn=-4100; // 3D Column
xlBarClustered=57; // Bar Clustered Bar
xl3DBarClustered=60; // 3D Clustered Bar
xlBarStacked=58; // Stacked Bar
xl3DBarStacked=61; // 3D Stacked Bar
xlBarStacked100=59; // 100% Stacked Bar
xl3DBarStacked100=62; // 3D 100% Stacked Bar
xlLine=4; // Line Line
xlLineMarkers=65; // Line with Markers
xlLineStacked=63; //Stacked Line
xlLineMarkersStacked=66; // Stacked Line with Markers
xlLineStacked100=64; // 100% Stacked Line
xlLIneMarkersStacked100=67; // 100% Stacked Line with Markers
xl3DLine=-4101; // 3D Line
xlPie=5; // Pie Pie
xlPieExploded=69; // Exploded Pie
xl3Dpie=-4102; // 3D Pie
xl3DPieExploded=70; // Exploded 3D Pie
xlPieOfPie=68; // Pie of Pie
xlBarOfPie=71; // Bar of Pie
xlXYScatter=-4169; // XY (Scatter) Scatter
xlXYScatterSmooth=72; // Scatter with Smoothed Lines
xlXYScatterSmoothNoMarkers=73; // Scatter with Smoothed Lines and No Data Markers
xlXYScatterLines=74; // Scatter with Lines
xlXYScatterLinesNoMarkers=75; // Scatter with Lines and No Data Markers
xlBubble=15; // Bubble Bubble
xlBubble3DEffect=87; // Bubble with 3D effects
xlArea=1; // Area Area
xl3DArea=-4098; // 3D Area
xlAreaStacked=76; // Stacked Area
xl3DAreaStacked=78; // 3D Stacked Area
xlAreaStacked100=77; // 100% Stacked Area
xl3DAreaStacked100=79; // 3D 100% Stacked Area
xlDoughnut=-4120; // Doughnut Doughnut
xlDoughnutExploded=80; // Exploded Doughnut
xlRadar=-4151; // Radar Radar
xlRadarMarkers=81; // Radar with Data Markers
xlRadarFilled=82; // Filled Radar
xlSurface=83; // Surface 3D Surface
xlSurfaceTopView=85; // Surface (Top View)
xlSurfaceWireframe=84; // 3D Surface (wireframe)
xlSurfaceTopViewWireframe=86; // Surface (Top View wireframe)
xlStockHLC=88; // Stock Quotes High-Low-Close
xlStockVHLC=90; // Volume-High-Low-Close
xlStockOHLC=89; // Open-High-Low-Close
xlStockVOHLC=91; // Volume-Open-High-Low-Close
xlCylinderColClustered=92; // Cylinder Clustered Cylinder Column
xlCylinderBarClustered=95; // Clustered Cylinder Bar
xlCylinderColStacked=93; // Stacked Cylinder Column
xlCylinderBarStacked=96; // Stacked Cylinder Bar
xlCylinderColStacked100=94; // 100% Stacked Cylinder Column
xlCylinderBarStacked100=97; // 100% Stacked Cylinder Bar
xlCylinderCol=98; // 3D Cylinder Column
xlConeColClustered=99; // Cone Clustered Cone Column
xlConeBarClustered=102; // Clustered Cone Bar
xlConeColStacked=100; // Stacked Cone Column
xlConeBarStacked=103; // Stacked Cone Bar
xlConeColStacked100=101; // 100% Stacked Cone Column
xlConeBarStacked100=104; // 100% Stacked Cone Bar
xlConeCol=105; // 3D Cone Column
xlPyramidColClustered=106; // Pyramid Clustered Pyramid Column
xlPyramidBarClustered=109; // Clustered Pyramid Bar
xlPyramidColStacked=107; // Stacked Pyramid Column
xlPyramidBarStacked=110; // Stacked Pyramid Bar
xlPyramidColStacked100=108; // 100% Stacked Pyramid Column
xlPyramidBarStacked100=111; // 100% Stacked Pyramid Bar
xlPyramidCol=112; // 3D Pyramid Column
//----- Размещение диаграмм -------
xlLocationAsNewSheet=1; //на отдельном новом листе
xlLocationAsObject=2; // Разместить диаграмму листе с данными
//----- Подписи осей ----
xlCategory=1;
xlValue=2;
xlSeries=3;
C const покончено. перейдем к процедурам. К сожалению это все, котрые я знаю...
Код:
Function AddChart(var Name:variant;ChartType:integer):boolean;
Function SetSourceData(Name,Sheet:variant;Range:string;XlRowCol:integer):boolean;
Function PositionChart(Name:variant;Left,Top,Width,Height:real):boolean;
Function PositionPlotArea(Name:variant;Left,Top,Width,Height:real):boolean;
Function BorderPlotArea(Name:variant;Color,LineStyle,Weight:integer):boolean;
Function BrushPlotArea(Name:variant;Color,Pattern,PatternColor:integer):boolean;
Function BrushPlotAreaFromFile(Name:variant;File_:string):boolean;
Function BorderChartArea(Name:variant;Color,LineStyle,Weight:integer):boolean;
Function BrushChartArea(Name:variant;Color,Pattern,PatternColor:integer):boolean;
Function BrushChartAreaFromFile(Name:variant;File_:string):boolean;
Function BorderChartTitle(Name:variant;Color,LineStyle,Weight:integer):boolean;
Function BrushChartTitle(Name:variant;Color,Pattern,PatternColor:integer):boolean;
Function BrushChartTitleFromFile(Name:variant;File_:string):boolean;
Function TextChartTitle(Name:variant;text_:string):boolean;
Function PositionChartTitle(Name:variant;Left,Top:real):boolean;
Function SetChartType(Name:variant;ChartType:integer):boolean;
Function SetChartLocation(var name:variant;sheet:variant;xlLocation:integer):boolean;
Function PositionSizeLegend(Name:variant;Left,Top,Width,Height:real):boolean;
Function BorderLegend(Name:variant;Color,LineStyle,Weight:integer):boolean;
Function BrushLegend(Name:variant;Color,Pattern,PatternColor:integer):boolean;
Function BrushLegendFromFile(Name:variant;File_:string):boolean;
Function FontLegendEntries(Name,LegendEntries:variant;Font:TFont):boolean;
Function AxisChart(Name:variant;Category,Series,Value:string):boolean;
Function ElevationChart(Name:variant;Elevation:real):boolean;
Function RotationChart(Name:variant;Rotation:real):boolean;
Function BorderWalls(Name:variant;Color,LineStyle,Weight:integer):boolean;
Function BrushWalls(Name:variant;Color,Pattern,PatternColor:integer):boolean;
Function BrushWallsFromFile(Name:variant;File_:string):boolean;
Function BorderFloor(Name:variant;Color,LineStyle,Weight:integer):boolean;
Function BrushFloor(Name:variant;Color,Pattern,PatternColor:integer):boolean;
Function BrushFloorFromFile(Name:variant;File_:string):boolean;
Function SeriesCount(Name:variant):integer;
Function BorderSeries(Name:variant;series:integer;Color,LineStyle,Weight:integer):boolean;
Function BrushSeries(Name:variant;series:integer;Color,Pattern,PatternColor:integer):boolean;
Function BrushSeriesFromFile(Name:variant;series:integer;File_:string):boolean;
Function BarShapeSeries(Name:variant;series,BarShape:integer):boolean;
Теперь использование всего этого:
//Создаем новую диаграмму.
Код:
procedure TForm1.Button21Click(Sender: TObject);
begin
AddChart(ChartName,xl3DColumn);
SetSourceData(1{ChartName},2,'A1:F6',xlRows);
end;
//Начинаем работу с диаграммой
Код:
procedure TForm1.Button25Click(Sender: TObject);
var a_:integer;
rng_:string;
begin
//заполняем данными
randomize;
SetRange(2,'A1','AAAA');
SetRange(2,'B1','BBBB');
SetRange(2,'C1','CCCC');
SetRange(2,'D1','AAAA');
SetRange(2,'E1','BBBB');
SetRange(2,'F1','CCCC');
for a_:=2 to 5 do begin
SetRange(2,'A'+inttostr(a_),a_-1);
SetRange(2,'B'+inttostr(a_),random(1000));
SetRange(2,'C'+inttostr(a_),random(1000));
SetRange(2,'D'+inttostr(a_),random(1000));
SetRange(2,'E'+inttostr(a_),random(1000));
SetRange(2,'F'+inttostr(a_),random(1000));
end;
TextChartTitle(ChartName,'Заголовок Диаграммы');
PositionChartTitle(ChartName,1,1); //координаты заголовка
BorderChartTitle(ChartName,RGB(100,150,245),1,1); //рамка заголовка
BrushChartTitle(ChartName,RGB(100,120,210),1,rgb(45,120,170)); //цвет заголовка
PositionPlotArea(ChartName,1,1,200,200); //координаты области
SetChartLocation(ChartName,'Новый лист',xlLocationAsNewSheet); // размещение диаграммы. Вместо 'Новый лист' поставь или название своего листа, или его номер!
end;
|