2014-04-25 25 views
1

我正在使用C/C++語言在Visual Studio 2010中使用Boxplot圖表處理數據和顯示信息的項目。在Visual C++上的BoxPlot圖表

我在MSDN Microsoft documentation上發現了一些例子,但它僅包含C#和Visual Basic中的示例代碼,但我無法在C/C++語言中找到示例。

我嘗試使用這個代碼

this->chart1->Series["dat"]->Points->AddY(10); 
this->chart1->Series["dat"]->Points->AddY(5); 
this->chart1->Series["dat"]->Points->AddY(7); 
this->chart1->Series["dat"]->Points->AddY(4); 
this->chart1->Series["dat"]->Points->AddY(8); 
this->chart1->Series["dat"]->Points->AddY(6); 

代替表示單箱線圖(如下面)

--------- 
    | 
    | 
    ----- 
|  | 
    ----- 
|  | 
    ----- 
    | 
    | 
--------- 

它顯示6個不同的晶須

---     --- 
    | --- ---  | --- 
    | | | --- | | 
    | | | | | | 
--- --- --- --- --- --- 

創建的箱線圖我試圖操作C++指令來創建類似於MSDN中示例代碼的代碼d ocumentation和插入數據到圖表,所以我試過這個:

this->chart1->Series["dat"]->Points->AddY(10); 
this->chart1->Series["dat"]->Points->AddY(5); 
this->chart1->Series["dat"]->Points->AddY(7); 
this->chart1->Series["dat"]->Points->AddY(4); 
this->chart1->Series["dat"]->Points->AddY(8); 
this->chart1->Series["dat"]->Points->AddY(6); 
this->chart1->Series["BoxPlotSeries"]["BoxPlotSeries"]="dat"; 

但它沒有奏效。

對於我來說,探索Chart方法和屬性是很困難的,因爲VS2010不提供用於C++/CLI的Intellisense。

您能否提供任何示例代碼來爲Visual C++ 2010創建Boxplot圖表?有任何想法嗎???

在此先感謝。

回答

0
System::Windows::Forms::DataVisualization::Charting::Series^ bpSeries = 
    gcnew System::Windows::Forms::DataVisualization::Charting::Series(); 
bpSeries->Name = "bpSeries"; 

std::vector<int> yValues { 10,5,7,4,8,6 }; 

for(int i = 0; i < yValues.size(); i++) 
    bpSeries->Points->AddY(yValues[i]); 

this->chart1->Series["dat"]["BoxPlotSeries"] = "bpSeries";