<%pre> #include #include #include #include #include "gd-cpp/gdpp.h" #include #include <%config> dburl; <%args> int id; <{ GD::Image image; image.CreateTrueColor( GD::Size(600,350)); //Black color scheme //GD::TrueColor decoration(45,95,0); //GD::TrueColor text(200,200,200); //GD::TrueColor line(255,0,0); //White color scheme image.Fill( GD::Point(1,1), GD::TrueColor(255,255,255).Int() ); GD::TrueColor decoration(60,60,60); GD::TrueColor text(0,0,0); GD::TrueColor line(255,0,0); image.String(gdFontSmall, 250,5, "Temperature graph", text.Int()); for (int i=0; i<11; ++i) { std::stringstream marker; marker << (100- (i*10)); int y = (i*30) + 25; image.Line( 30, y, 590, y, decoration.Int()); image.String(gdFontSmall, 5, y-7, marker.str().c_str(), text.Int()); } ///////////////////////////////////////////////// tntdb::Connection conn = tntdb::connect(dburl); std::stringstream query; query << "SELECT temperature FROM ( "; query << " SELECT messagenr,temperature FROM logtable "; query << " WHERE installationnr = " << id << " "; query << " ORDER BY messagenr DESC LIMIT 20 "; query << ") query "; query << "ORDER BY messagenr ASC"; tntdb::Result res = conn.select(query.str()); GD::Point previous; for (int i=0; i0) { image.Line( GD::Point(x,y), previous, line.Int()); } previous = GD::Point(x,y); } ////////////////////////////////////////////////// // echo the image to the browser... reply.setContentType("image/png"); int size; unsigned char* ptr = (unsigned char*) image.Png(&size); for (int i=0; i