From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple YAxis chart, but only first axis getting scaled when data is plotted?

I am using a CNiGraph in an MFC project. I am creating the control and settings all properties programmatically.

I have a single stripchart, with four plots, 2 yaxis on left and 2 yaxis on right. The xaxis is real-time. When data is plotted to the chart, the plots appear with correct values, however, the only yAxis that gets scaled (autoscale is on for each) is the original YAxis that is created by default.

For example, the yaxis-1/plot-1 that is created by default when the control is created I set to Temperature. I then add 3 more yaxis/plots for salinity, conductivity and density. When I plot the data on the chart the plots appear, but the only axis that gets scaled is Temperatur
e. the temp yaxis is scaled to encompass the four datasets, and the other 3 yaxis do not get scaled at all.

It appears that the 3 yaxis/plots that I add after do not get attached to the plots and do not get scaled. Correct me if I'm wrong but the four axis should be independent and should autoscale according to their individual data values??

Anyone have any ideas here???

Thanks
0 Kudos
Message 1 of 2
(2,938 Views)
Each plot object can only be assigned one Y-axis and that is the Y-axis that will autoscale with new data on that plot object. If you want to have multiple axis that apply to the SAME plot object, you would have to scale the other axis manually.

If you are actually trying to make 4 plots and have them all scale an individual axis, you just don't have the plot objects properly assigned to the right axes. Below is code I used to add an axis to the graph, add a plot, and assign the plots to the appropriate axis so it is scaling that axis.

CNiReal64Vector wave(1000);

CNiMath::SineWave(wave, 1.0);

m_graph.Plots.Add().LineColor.SetRed(255);

m_graph.Axes.Add().SetName("YAxis2");
m_graph.Axes.Item("YAxis2").AutoScale = TRUE;

m_graph.Plo
ts.Item(1).SetYAxis(m_graph.Axes.Item("YAxis1"));
m_graph.Plots.Item(2).SetYAxis(m_graph.Axes.Item("YAxis2"));

m_graph.Plots.Item(1).PlotY(wave);
CNiMath::SineWave(wave, 2.0);
m_graph.Plots.Item(2).PlotY(wave);

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 2
(2,938 Views)