Function AddChart(var name:string;
ChartType:integer):boolean;
begin
AddChart:=true;
try
name:=E.Charts.Add.Name;
E.Charts.Item[name].ChartType:=ChartType;
except
AddChart:=false;
end;
End;
Function SetSourceData(Name,Sheet:variant;
Range:string;XlRowCol:integer):boolean;
begin
SetSourceData:=true;
try
E.ActiveWorkbook.Charts.Item[name].SetSourceData
(Source:=E.ActiveWorkbook.Sheets.Item
[Sheet].Range[Range],PlotBy:=XlRowCol);
except
SetSourceData:=false;
end;
End;
Function PositionChart(Name:variant;
Left,Top,Width,Height:real):boolean;
begin
PositionChart:=true;
try
E.Charts.Item[name].ChartArea.Left:=Left;
E.Charts.Item[name].ChartArea.Top:=Top;
E.Charts.Item[name].ChartArea.Width:=Width;
E.Charts.Item[name].ChartArea.Height:=Height;
except
PositionChart:=false;
end;
End;
Function BorderChartArea(Name:variant;
Color,LineStyle,Weight:integer):boolean;
begin
BorderChartArea:=true;
try
E.Charts.Item[name].ChartArea.Border.Color:=Color;
E.Charts.Item[name].ChartArea.Border.Weight:=Weight;
E.Charts.Item[name].ChartArea.Border.LineStyle:=LineStyle;
except
BorderChartArea:=false;
end;
End;
Function BrushChartArea(Name:variant;
Color,Pattern,PatternColor:integer):boolean;
begin
BrushChartArea:=true;
try
E.Charts.Item[name].ChartArea.Interior.Color:=Color;
E.Charts.Item[name].ChartArea.Interior.Pattern:=Pattern;
E.Charts.Item[name].ChartArea.Interior.PatternColor:=PatternColor;
except
BrushChartArea:=false;
end;
End;
Function
BrushChartAreaFromFile(Name:variant;File_:string):boolean;
begin
BrushChartAreaFromFile:=true;
try
E.Charts.Item[name].ChartArea.Fill.UserPicture(PictureFile:=File_);
E.Charts.Item[name].ChartArea.Fill.Visible:=True;
except
BrushChartAreaFromFile:=false;
end;
End;
Function PositionPlotArea(Name:variant;
Left,Top,Width,Height:real):boolean;
begin
PositionPlotArea:=true;
try
E.Charts.Item[name].PlotArea.Left:=Left;
E.Charts.Item[name].PlotArea.Top:=Top;
E.Charts.Item[name].PlotArea.Width:=Width;
E.Charts.Item[name].PlotArea.Height:=Height;
except
PositionPlotArea:=false;
end;
End;
Function BorderPlotArea(Name:variant;
Color,LineStyle,Weight:integer):boolean;
begin
BorderPlotArea:=true;
try
E.Charts.Item[name].PlotArea.Border.Color:=Color;
E.Charts.Item[name].PlotArea.Border.Weight:=Weight;
E.Charts.Item[name].PlotArea.Border.LineStyle:=LineStyle;
except
BorderPlotArea:=false;
end;
End;
Function BrushPlotArea(Name:variant;
Color,Pattern,PatternColor:integer):boolean;
begin
BrushPlotArea:=true;
try
E.Charts.Item[name].PlotArea.Interior.Color:=Color;
E.Charts.Item[name].PlotArea.Interior.Pattern:=Pattern;
E.Charts.Item[name].PlotArea.Interior.PatternColor:=PatternColor;
except
BrushPlotArea:=false;
end;
End;
Function
BrushPlotAreaFromFile(Name:variant;File_:string):boolean;
begin
BrushPlotAreaFromFile:=true;
try
E.Charts.Item[name].PlotArea.Fill.UserPicture(PictureFile:=
File_);
E.Charts.Item[name].PlotArea.Fill.Visible:=True;
except
BrushPlotAreaFromFile:=false;
end;
End;
Pone el título a un Chart
E.Charts.Item[name].HasTitle:=True;
E.Charts.Item[name].ChartTitle.Text:='Gráfico de ventas';
E.Charts.Item[name].ChartTitle.Left:=Left;
E.Charts.Item[name].ChartTitle.Top:=Top;
E.Charts.Item[name].ChartTitle.Border.Color:=Color;
E.Charts.Item[name].ChartTitle.Border.Weight:=Weight;
E.Charts.Item[name].ChartTitle.Border.LineStyle:=LineStyle;
E.Charts.Item[name].ChartTitle.Interior.Color:=Color;
E.Charts.Item[name].ChartTitle.Interior.Pattern:=Pattern;
E.Charts.Item[name].ChartTitle.Interior.PatternColor:=PatternColor;
E.Charts.Item[name].ChartTitle.Fill.UserPicture(PictureFile:=
File_);
E.Charts.Item[name].ChartTitle.Fill.Visible:=True;
E.Charts.Item[name].Walls.Border.Color:=Color;
E.Charts.Item[name].Walls.Border.Weight:=Weight;
E.Charts.Item[name].Walls.Border.LineStyle:=LineStyle;
E.Charts.Item[name].Walls.Interior.Color:=Color;
E.Charts.Item[name].Walls.Interior.Pattern:=Pattern;
E.Charts.Item[name].Walls.Interior.PatternColor:=PatternColor;
E.Charts.Item[name].Walls.Fill.UserPicture(PictureFile:=File_);
E.Charts.Item[name].Walls.Fill.Visible:=True;
E.Charts.Item[name].Floor.Border.Color:=Color;
E.Charts.Item[name].Floor.Border.Weight:=Weight;
E.Charts.Item[name].Floor.Border.LineStyle:=LineStyle;
E.Charts.Item[name].Floor.Interior.Color:=Color;
E.Charts.Item[name].Floor.Interior.Pattern:=Pattern;
E.Charts.Item[name].Floor.Interior.PatternColor:=PatternColor;
E.Charts.Item[name].Floor.Fill.UserPicture(PictureFile:=File_);
E.Charts.Item[name].Floor.Fill.Visible:=True;
Function SetChartType
(Name:variant;ChartType:integer):boolean;
begin
SetChartType:=true;
try
E.Charts.Item[name].ApplyCustomType(ChartType:=ChartType);
except
SetChartType:=false;
end;
End;
Function SetChartLocation (var
name:variant;sheet:variant;
xlLocation:integer):boolean;
begin
SetChartLocation:=true;
try
name:=E.Charts.Item[name].Location(Where:=
xlLocationAsObject,Name:=sheet).name;
except
SetChartLocation:=false;
end;
End;
Function ElevationChart
(Name:variant;Elevation:real):boolean;
begin
ElevationChart:=true;
try
E.Charts.Item[name].Elevation:=Elevation;
except
ElevationChart:=false;
end;
End;
Function
RotationChart(Name:variant;Rotation:real):boolean;
begin
RotationChart:=true;
try
E.Charts.Item[name].Rotation:=Rotation;
except
RotationChart:=false;
end;
End;
Function PositionSizeLegend (Name:variant;
Left,Top,Width,Height:real):boolean;
begin
PositionSizeLegend:=true;
try
E.Charts.Item[name].Legend.Left:=Left;
E.Charts.Item[name].Legend.Top:=Top;
E.Charts.Item[name].Legend.Width:=Width;
E.Charts.Item[name].Legend.Height:=Height;
except
PositionSizeLegend:=false;
end;
End;
Function BorderLegend (Name:variant;
Color,LineStyle,Weight:integer):boolean;
begin
BorderLegend:=true;
try
E.Charts.Item[name].Legend.Border.Color:=Color;
E.Charts.Item[name].Legend.Border.Weight:=Weight;
E.Charts.Item[name].Legend.Border.LineStyle:=LineStyle;
except
BorderLegend:=false;
end;
End;
Function BrushLegend (Name:variant;
Color,Pattern,PatternColor:integer):boolean;
begin
BrushLegend:=true;
try
E.Charts.Item[name].Legend.Interior.Color:=Color;
E.Charts.Item[name].Legend.Interior.Pattern:=Pattern;
E.Charts.Item[name].Legend.Interior.PatternColor:=PatternColor;
except
BrushLegend:=false;
end;
End;
Function BrushLegendFromFile (Name:variant;File_:
string):boolean;
begin
BrushLegendFromFile:=true;
try
E.Charts.Item[name].Legend.Fill.UserPicture(PictureFile:=File_);
E.Charts.Item[name].Legend.Fill.Visible:=True;
except
BrushLegendFromFile:=false;
end;
End;
Function FontToEFont (font:Tfont;EFont:variant):boolean;
Begin
FontToEFont:=true;
try
EFont.Name:=font.Name;
if
fsBold in
font.Style
then
EFont.Bold:=True
else
EFont.Bold:=False;
if
fsItalic in
font.Style
then
EFont.Italic:=True
else
EFont.Italic:=False;
EFont.Size:=font.Size;
if
fsStrikeOut in
font.Style
then
EFont.Strikethrough:=True
else
EFont.Strikethrough:=False;
if
fsUnderline in
font.Style
then
EFont.Underline:=xlUnderlineStyleSingle
else
EFont.Underline:=xlUnderlineStyleNone;
EFont.Color:=font.Color;
except
FontToEFont:=false;
end;
End;
Function FontLegendEntries(Name,LegendEntries:variant;
Font:TFont):boolean;
begin
FontLegendEntries:=true;
try
FontLegendEntries:=
FontToEFont(Font,E.Charts.Item[name].Legend.LegendEntries.Item[LegendEntries].Font);
except
FontLegendEntries:=false;
end;
End;
Function AxisChart
(Name:variant;Category,Series,Value:string):boolean;
begin
AxisChart:=true;
try
if
Category<>''
then E.Charts.Item[name].Axes[xlCategory].HasTitle:=True
else
E.Charts.Item[name].Axes[xlCategory].HasTitle:=False;
if
Series<>''
then E.Charts.Item[name].Axes[xlSeries].HasTitle:=True
else
E.Charts.Item[name].Axes[xlSeries].HasTitle:=False;
if
Value<>''
then E.Charts.Item[name].Axes[xlValue].HasTitle:=True
else
E.Charts.Item[name].Axes[xlValue].HasTitle:=False;
E.Charts.Item[name].Axes[xlCategory].AxisTitle.Text:=Category;
E.Charts.Item[name].Axes[xlSeries].AxisTitle.Text:=Series;
E.Charts.Item[name].Axes[xlValue].AxisTitle.Text:=Value;
except
AxisChart:=false;
end;
End;
Function SeriesCount (Name:variant):integer;
begin
SeriesCount:=-1;
try
SeriesCount:=E.Charts.Item[name].SeriesCollection.Count;
except
SeriesCount:=-1;
end;
End;
Function BarShapeSeries
(Name:variant;series,BarShape:integer):boolean;
begin
BarShapeSeries:=true;
try
E.Charts.Item[name].SeriesCollection.Item[series].BarShape:=BarShape;
except
BarShapeSeries:=false;
end;
End;
E.Charts.Item[name].SeriesCollection.Item[series].Border.Color:=Color;
E.Charts.Item[name].SeriesCollection.Item[series].Border.Weight:=Weight;
E.Charts.Item[name].SeriesCollection.Item[series].Border.LineStyle:=LineStyle;
E.Charts.Item[name].SeriesCollection.Item[series].Interior.Color:=Color;
E.Charts.Item[name].SeriesCollection.Item[series].Interior.Pattern:=Pattern;
E.Charts.Item[name].SeriesCollection.Item[series].Interior.PatternColor:=PatternColor;
E.Charts.Item[name].SeriesCollection.Item[series].Fill.UserPicture(PictureFile:=File_);
E.Charts.Item[name].SeriesCollection.Item[series].Fill.Visible:=True;
Fuente: www.kornjakov.ru/st2_6.zip
www.kornjakov.ru/st2_5.zip
No hay comentarios:
Publicar un comentario