开发者

How do I offset the labels in a System.Windows.Forms.DataVisualization.Charting.Chart?

开发者 https://www.devze.com 2023-02-01 02:15 出处:网络
I\'m trying to display the results of an FFT with 128 bins, but when I do the following to add new data:

I'm trying to display the results of an FFT with 128 bins, but when I do the following to add new data:

DataVisualization::Charting::Series^ series = m_chart->Series[0];
series->Points->DataBindY(m_dataBuffer);
m_chart->Refresh();

...it labels my spectra from 1 to 128. I need those labels to read 0 to 127. What's the e开发者_JAVA技巧asiest way to achieve this?


Just in case anyone else wants to do something along these lines, you can can do so using custom labels:

System::Windows::Forms::DataVisualization::Charting::ChartArea^ chartArea1 = this->m_chart->ChartAreas[0];
for( int i = 0; i < 128; i += 16 )
{
    System::Windows::Forms::DataVisualization::Charting::CustomLabel^  customLabel1 = (gcnew System::Windows::Forms::DataVisualization::Charting::CustomLabel());
    customLabel1->FromPosition = i-1.5;
    customLabel1->Text = (i).ToString();
    customLabel1->ToPosition = i+1.5;
    chartArea1->AxisX->CustomLabels->Add(customLabel1);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消