Einzelnen Beitrag anzeigen

wschrabi

Registriert seit: 16. Jan 2005
448 Beiträge
 
#4

AW: Die TEECHART TDATAIMPORT Komponente.

  Alt 18. Apr 2017, 09:51
KOnnte das Laden von Quandl nachvollziehen, auch mit German Local Settings.

Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, VclTee.TeeGDIPlus,
  VCLTee.TeEngine, Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.TeeImport,
  VCLTee.TeeEdit, VCLTee.TeeComma;

type
  TForm1 = class(TForm)
    Button1: TButton;
    DataImport1: TDataImport;
    Chart1: TChart;
    TeeCommander1: TTeeCommander;
    ChartPreviewer1: TChartPreviewer;
    Edit1: TEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private-Deklarationen }
   procedure SetLocaleInfoSample;
   procedure RestoreLocaleInfo;
       
  public
    { Public-Deklarationen }
  end;

var
   Form1: TForm1;
   import: TDataIMport;
implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
   import:=TDataImport.Create(self);
   import.Chart:=chart1;
   SetLocaleInfoSample ;

   import.ImportFromURL('https://www.quandl.com/api/v3/datasets/CLSH/USDZAR_SWP_TRD.csv?api_key='+trim(edit1.text));
   Chart1.Title.Text.Add('USDZAR FX Swap trades');
   RestoreLocaleInfo;
   import.Free;

end;

procedure TForm1.RestoreLocaleInfo;
const cs1 : pchar = 'Windows';
begin
  // Restore original settings
    SetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_SDECIMAL,',');
    SetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_STHOUSAND,'''');
    SetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_SLIST,';');
    SendMessage( HWND_BROADCAST, WM_SETTINGCHANGE, 0, LongInt(cs1));



end;

procedure TForm1.SetLocaleInfoSample;
const cs1 : pchar = 'Windows';
begin
    SetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_SDECIMAL,'.');
    SetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_STHOUSAND,'''');
    SetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_SLIST,',');
    SendMessage( HWND_BROADCAST, WM_SETTINGCHANGE, 0, LongInt(cs1));



end;

{
The function produces the following output for US English locale:

0.7
0,7
,7
}



procedure TForm1.Button1Click(Sender: TObject);
begin
   import:=TDataImport.Create(self);
   import.Chart:=chart1;
   SetLocaleInfoSample ;

   //import.ImportFromURL('https://www.quandl.com/api/v3/datasets/CLSH/USDZAR_SWP_TRD.csv?api_key=');
   //Chart1.Title.Text.Add('USDZAR FX Swap trades');
   import.ImportFromURL('https://www.quandl.com/api/v3/datasets/EIA/ELEC_PLANT_CONS_EG_BTU_57506_SUN_PV_Q.csv?api_key='+trim(edit1.text));
   Chart1.Title.Text.Add('Electric fuel consumption MMBtu ; FRV SI Transport Solar LP (57506) ');
   RestoreLocaleInfo;
   import.Free;
   
end;

end.
  Mit Zitat antworten Zitat