簡體   English   中英

使用C#或cli / c ++在Visual Studio中的Winforms中上色或突出顯示圖中的數據點

[英]Color or Highlight a data point in graph in winforms in visual studio using c# or cli/c++

我正在通過從數據庫中選取數據在Winform中繪制圖形。 它工作正常。 我需要的是,如果某些數據值大於最大值,則圖形中的該點將變為高亮或紅色。 我怎樣才能做到這一點? 請幫忙。

String^  constring = L"datasource=localhost;port=3306;username=root;password=root;";
                 MySqlConnection^ conDataBase = gcnew MySqlConnection(constring);
                 MySqlCommand^ cmdDataBase = gcnew MySqlCommand("select * from `data`.`test`;",conDataBase); 
                 MySqlDataReader^ myReader;

                 try{
                     conDataBase->Open();
                     myReader = cmdDataBase->ExecuteReader();
                    // MessageBox::Show("Data Inserted");
                     while(myReader->Read()){

                         String^ v_datetime;
                         String^ v_temp;
                         v_datetime = myReader->GetString("datetime");
                         v_pressure = myReader->GetInt32("temp").ToString();

                         String^ status;
                         if (myReader->GetInt32("temp") > 1000 && myReader->GetInt32("temp") < 50 )


 {
                                 status = " Abnormal ";
**// and this point only should be highlited or different color in the graph**
                                                             }
                         else{
                            status = " Normal";
                         }

                         this->label3->Text = status;

                         this->chart2->Series["Temperature"]->Points->AddXY(v_datetime,myReader->GetInt32("temp"));
                        // comboBox1->Items->Add(vName);

                     }
                 }catch(Exception^ex){
                     MessageBox::Show(ex->Message);
                 }

您不能在類中添加表示要繪制的對象的屬性,並且在繪制圖形時要在此屬性上進行測試並更改顏色,形狀和大小。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM