台灣最大程式設計社群網站
線上人數
1920
 
會員總數:243282
討論主題:188070
歡迎您免費加入會員
討論區列表 >> C# >> SSIS的指令程式碼做直條圖 (C#)
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
SSIS的指令程式碼做直條圖 (C#)
價值 : 50 QP  點閱數:258 回應數:4

樓主

liping
門外漢
0 7
239 29
發送站內信

請問各位大大,若要在SSIS的指令程式碼做直條圖,請問要怎麼做呢?謝謝。
目前只會做到畫線,畫方型等,卡在直條圖要如何做,謝謝。
使用Visual C# 2008(只能支援到.Net Framework 3.5)




搜尋相關Tags的文章: [ SSIS ] , [ C# ] , [ 直條圖 ] ,
本篇文章發表於2018-05-03 15:39
別忘捐VP感謝幫助你的人 新手會員瞧一瞧
1樓
作者回應

liping
檢舉此回應
我是參考網路資料和自己修改後如下資料供大家參考:

string connectionString = "DaTa Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=";
DataTable ds = new DataTable();
using (SqlConnection sqlConn = new SqlConnection(connectionString))
{
sqlConn.Open();
string sqlcmd;
sqlcmd = @"select 條件";
SqlCommand sqlc = new SqlCommand(sqlcmd);
sqlc.Connection = sqlConn;
using (SqlDataAdapter dax = new SqlDataAdapter(sqlc))
{
dax.Fill(ds);
}
}

List<float> arrValues = new List<float>();
for (int i = 0; i < ds.Rows.Count; i++)
{
for (int j = 0; j < ds.Columns.Count; j++)
{
float value = Convert.ToSingle(ds.Rows[i][j]);
arrValues.Add(value);
}
}

string connectionString3 = "DaTa Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=";
DataTable ds2 = new DataTable();
using (SqlConnection sqlConn = new SqlConnection(connectionString3))
{
sqlConn.Open();
string sqlcmd;
sqlcmd = @"select 條件";
SqlCommand sqlc = new SqlCommand(sqlcmd);
sqlc.Connection = sqlConn;
using (SqlDataAdapter dax = new SqlDataAdapter(sqlc))
{
dax.Fill(ds2);
}
}

List<string> arrValues2 = new List<string>();
for (int i = 0; i < ds2.Rows.Count; i++)
{
for (int j = 0; j < ds2.Columns.Count; j++)
{
string value = ds2.Rows[i][j].ToString();
arrValues2.Add(value);
}
}

//在此處放置用戶代碼以初始化頁面
Graphics objGraphis;
int width = 720, height = 300;
Bitmap Bee = new Bitmap(width, height);//畫片的大小
objGraphis = Graphics.FromImage(Bee);
objGraphis.Clear(Color.White);//設置圖片背景顏色
System.Drawing.Pen pen = new System.Drawing.Pen(Brushes.Black, 2);//設置畫筆的颜色粗细
System.Drawing.Pen pen1 = new System.Drawing.Pen(Brushes.Black, 1);//設置畫筆的颜色粗细

//畫圖形的外框
objGraphis.DrawLine(pen, 0, 0, width, 0);
objGraphis.DrawLine(pen, 0, 0, 0, height);
objGraphis.DrawLine(pen, 0, height, width, height);
objGraphis.DrawLine(pen, width, height, width, 0);

//文字標示
string[] arrValueNames = { "0", "0"}; //表示所有的縱座標的標示度名稱
arrValueNames[0] = "Vendor";
arrValueNames[1] = "Buyer";

PointF symbolLeg = new PointF(300, 20);//標識圖的起初位置
//畫標識圖
objGraphis.FillRectangle(Brushes.Blue, symbolLeg.X, symbolLeg.Y, 40, 20);
objGraphis.DrawString(arrValueNames[0], new Font("新細明體", 10), Brushes.Black, new PointF(350, 20));

objGraphis.FillRectangle(Brushes.Red, symbolLeg.X + 200, symbolLeg.Y, 40, 20);
objGraphis.DrawString(arrValueNames[1], new Font("新細明體", 10), Brushes.Black, new PointF(550, 20));

//畫座標
objGraphis.DrawLine(pen1, 60, 50, 60, 270); //Y軸
objGraphis.DrawLine(pen1, 60, 270, 680, 270); //X軸
//畫Y軸座標
for (int i = 0; i < 11; i++)
{
float ykedu = 10 * i;
objGraphis.DrawLine(pen1, 60, 70 + 20 * i, 55, 70 + 20 * i);
objGraphis.DrawString(ykedu.ToString(), new Font("", 10), Brushes.Black, 30, 270 - 20 * i - 5);
}
objGraphis.DrawString("百分比(%)", new Font("新細明體", 10), Brushes.Black, new PointF(6, 7));

//畫X軸座標
for (int i = 0; i < arrValues2.Count; i++)
{
//int xkedu = arrValues2[i];
objGraphis.DrawLine(pen1, 60 + 50 * i, 265, 60 + 50 * i, 270);
//objGraphis.DrawString(xkedu.ToString(), new Font("新細明體", 10), Brushes.Black, 65, 280);
objGraphis.DrawString(arrValues2[i], new Font("新細明體", 10), Brushes.Black, 75 + 45 * i, 280 );
}
objGraphis.DrawString("年月", new Font("新細明體", 10), Brushes.Black, new PointF(680, 280));

//畫矩形圖
PointF RectangStart = new PointF(75, 270);
for (int i = 0; i < arrValues.Count; i++)
{
if (i % 2 == 0)
{
objGraphis.FillRectangle(new SolidBrush(Color.Blue), RectangStart.X, 270 - (2 * arrValues[i]), 25, arrValues[i] * 2);//矩形的寬度為12.5和相應數值的高度
//objGraphis.DrawRectangle(Pens.Black, RectangStart.X, 270 - arrValues[i] * 2, 25, arrValues[i] * 2);
objGraphis.DrawString(arrValues[i].ToString(), new Font("新細明體", 10), Brushes.Black, RectangStart.X + 10, 270 - arrValues[i] * 2 - 15);
}
else
{
objGraphis.FillRectangle(new SolidBrush(Color.Red), RectangStart.X, 270 - 2 * arrValues[i], 25, arrValues[i] * 2);//矩形的寬度為12.5和相應數值的高度
//objGraphis.DrawRectangle(Pens.Black, RectangStart.X, 270 - arrValues[i] * 2, 25, arrValues[i] * 2);
objGraphis.DrawString(arrValues[i].ToString(), new Font("新細明體", 10), Brushes.Black, RectangStart.X + 10, 270 - arrValues[i] * 2 - 15);
RectangStart.X += 50;
}
}
//保存輸出圖片
Bee.Save(strName, System.Drawing.Imaging.ImageFormat.Bmp);
本篇文章回覆於2018-05-24 13:34
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
2樓
回應

春天
檢舉此回應
請問SSIS是什麼
本篇文章回覆於2018-05-24 14:28
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
3樓
作者回應

liping
檢舉此回應
SSIS可用在SQL做排程或BI等資料
SSIS:SQL Server Integration Services 可參考如下:
SSIS
本篇文章回覆於2018-05-24 14:52
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
4樓
作者回應

liping
檢舉此回應
連結有誤,我重新再弄一個~
SSIS
本篇文章回覆於2018-05-24 14:57
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.