开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜