Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

plotting time on the x-axis in ni graph

i am developing an application in VC++ using MFC application wizard(.exe).i have used CWGraph for the graph portion of my appliction.i have declared an array of 10 strings as follows:

CString time[10]={"07:04:10","07:04:15","07:04:20","07:04:25","07:04:30","07:04:35","07:04:40","07:04:45","07:04:50","07:04:55"};

i need to plot this array of strings on the x axis of the graph with time[0]as the first parameter and time[9]as the last parameter and the other values in between.i have tried using SetMinMax()function but to no avail.
is there any function through which i can set the time on the x-axis.

my graph should always pick the time values from an array of strings and plot the same with the corresponding y values.

eag
erly waiting for a solution,
regards,
farooq.
0 Kudos
Message 1 of 2
(2,769 Views)
You could do this with value pairs. Here's an example that will set up the x axis as you specified in your post:

CNiAxis axis = m_graph.Axes.Item(1);
CNiTicks ticks = axis.Ticks;
ticks.MajorDivisions = 0;
ticks.MajorUnitsBase = 0;
ticks.MajorUnitsInterval = 0;
ticks.MinorDivisions = 0;
ticks.MinorUnitsInterval = 0;

CString time[10] =
{
"07:04:10",
"07:04:15",
"07:04:20",
"07:04:25",
"07:04:30",
"07:04:35",
"07:04:40",
"07:04:45",
"07:04:50",
"07:04:55"
};

CNiValuePairs valuePairs = axis.ValuePairs;
for (int i = 0; i < 10; ++i)
{
CNiValuePair pair = valuePairs.Add();
pair.Name = time[i];

pair.Value = i;
}

If your x axis values must be an actual date/time and not a string, you'll have to convert it to a double. For more information, see the CNiAxis overview page. The easiest way to get to this page is to type "CNiAxis" in the Measurement Studio Reference index.

- Elton
0 Kudos
Message 2 of 2
(2,769 Views)