使用c#或cli/c++在visual studio中的winforms中为图形中的数据点着色或高亮显示

本文关键字:图形 数据 显示 高亮 winforms cli c++ 中的 studio visual 使用 | 更新日期: 2023-09-27 18:23:40

我通过从数据库中提取数据,以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);
                 }

使用c#或cli/c++在visual studio中的winforms中为图形中的数据点着色或高亮显示

您不能将一个属性添加到表示要绘制的对象的类中吗?在绘制图形时,您可以测试该属性并更改颜色、形状和大小。