電力の使用状況グラフ表示ソフト
東京電力さんがcsvを公開しはじめたので、こんなソフトを作ってみました。
>>バージョンv1_3はコチラ
HSPのサンプルソースこんなかんじです。
「HSP3で、ネット上のcsvをダウンロードしてきて加工して表示」ってのの参考にもなるかと思います。
※下記はv1_0のものです
title "電力の使用状況:小松菜屋" color 0,0,0:boxf 0,0,640,480:redraw 0 #include "hspinet.as" #include "hspda.as" //初期化 *init cls netinit if stat : dialog "インターネットに接続できません。" : end neturl "http://www.tepco.co.jp/forecast/html/images/" //ベースになるサイトのURLを指定する netload "juyo-j.csv" //ファイル名を指定して読込 fname="juyo-j.csv" //HSP上で扱えるようにしておく //ヘッダデータ初期化しとく time_stamp = "" //データの更新日時 //データ読込 *data_load exist fname sz=strsize if sz<0 : dialog "ファイルがありません。" : end notesel org noteload fname sdim cline,500 ; 1行データバッファ sdim data,64,10 ; 1フィールドバッファ sdim d_date,24,10 ; 日付 sdim d_time,24,10 ; 時間 sdim d_today,24,10 ; 当日実績 sdim d_yesterday,24,10 ; 前日実績 noteget cline,0 csvstr data, cline time_stamp = data.0 //データの更新日時を格納 //24時間分ループ repeat 24 cnt_time = cnt noteget cline,cnt_time+2 csvstr data, cline d_date.cnt_time = data.0 d_time.cnt_time = data.1 d_today.cnt_time = data.2 d_yesterday.cnt_time= data.3 loop *data_draw redraw 0 //まずは真っ黒に塗潰す color 0,0,0 boxf 0,0,640,480 font "MS Pゴシック", 11, 0 //更新日時を画面の左上に出しとく color 0,200,0 pos 8,8 print "更新日時"+time_stamp //凡例の描画 //横軸 color 0,200,0 repeat 24 cnt_time = cnt pos cnt_time * 20 + 84,402 print cnt_time loop //文字 pos 535,420 print "時台" //縦軸 repeat 7,1 cnt_time = cnt color 0,100,0 line 70,400 - cnt_time * 33,565,400 - cnt_time * 33 pos 45,396 - cnt_time * 33 color 0,200,0 print cnt_time * 1000 loop //0だけ別で描画 color 0,100,0 line 70,400,565,400 pos 63,396 color 0,200,0 print "0" //文字 pos 40,140 print "(万kW)" //前日実績:24時間分ループ color 0,0,0 repeat 24 cnt_time = cnt cnt_p_y = int(d_yesterday.cnt_time) cnt_p_y = cnt_p_y / 30 gradf cnt_time * 20 + 80,400,18,-cnt_p_y,1,$0000ff,$555555 loop //当日実績:24時間分ループ repeat 24 cnt_time = cnt cnt_p_y = int(d_today.cnt_time) cnt_p_y = cnt_p_y / 30 gradf cnt_time * 20 + 80,400,14,-cnt_p_y,1,$00ff00,$ffffff loop redraw 1 pos 564,420 button goto "再読込",*init stop