Ver Mensaje Individual
  #3  
Antiguo 16-01-2015
Avatar de jeremiselxi
jeremiselxi jeremiselxi is offline
Miembro
 
Registrado: ago 2008
Posts: 199
Reputación: 16
jeremiselxi Va por buen camino
Cita:
Empezado por nlsgarcia Ver Mensaje
jeremiselxi,



Revisa esta información:
Espero sea útil

Nelson.
Muchisisimas gracias nlsgarcia.

Adjunto el código que me funcionó.

Primero debemos agregar un adoquery y renombrarlo como "table".

Hay que agregar un dbtchart y dando doble click agregar una serie.

Adjunto el código:

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, DbChart, Grids,
  DBGrids, DB, ADODB, StdCtrls, DBClient;

type
  TForm1 = class(TForm)
    table: TADOQuery;
    ADOConnection1: TADOConnection;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button1: TButton;
    tableACTIVIDADESREALIZADAS: TWideStringField;
    tableTOTALES: TIntegerField;
    DBChart1: TDBChart;
    Series1: TPieSeries;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


  
//las constantes
const
  GColor : Array[1..12] of TColor = (clGreen, clOlive, clNavy, clPurple, clTeal,
                                     clGray, clSilver, clRed, clLime, clYellow,
                                     clBlue, clFuchsia);
var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
end;

procedure TForm1.Button1Click(Sender: TObject);

var
   actividades : String;
   totales : Integer;
   i : Integer;

begin

   if Assigned(Table) then
   begin

      i := 1;

      with DBChart1 do
      begin
         Title.Text.Clear;
         Title.Text.Add('Relación porcentual de las tareas rutinarias realizadas en el año'); //Aquí va el titulo del Grafico
         Legend.Visible := true;
         LeftAxis.Title.Caption := 'TOTALES'; //aquí va el titulo de la columna totales
         LeftAxis.Title.Font.Color := clBlue;
         BottomAxis.Title.Caption := 'ACTIVIDADES REALIZADAS';  //aquí va el titulo de la columna de las actividades
         BottomAxis.Title.Font.Color := clBlue;
      end;

      with Series1 do
      begin

         Clear;

         Marks.Style := smsPercent;

         with Table do
         begin
            Open;
            while not eof do
            begin
               actividades := Table.FieldByName('ACTIVIDADES REALIZADAS').AsString;
               totales := Table.FieldByName('TOTALES').AsInteger;
               Add(totales, actividades, GColor[i]);
               inc(i);
               Next;
            end;
            //Close;
         end;

      end;

   end;

end;

Ahora solo tengo un solo problema y es como hacer para que el porcentaje del grafico este un poco desagrupado, ya que aparecen uno arriba de otro como muestra la imagen adjunta.

Alguien tiene alguna idea de como solucionarlo?.

Saludos y gracias
Imágenes Adjuntas
Tipo de Archivo: jpg Captura.jpg (17,2 KB, 6 visitas)
__________________
Cristo te ama, ven a d él, ya k te espera con los brazos abiertos. Dios te bendiga mucho
Responder Con Cita