Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

2D Histogram - annotation locations

Hi,

I'm making a 2D Histogram (so instead of a bar graph, I need a bunch of tiled rectangles, each of a different color to represent its value). I'd like to know how I can draw rectangles of a user-defined size and place them on my graph.

my current code is ...
///////////////////////////

m_graph.Axes.Item(1).SetMinMax(minX, maxX); //x-axis
m_graph.Axes.Item(2).SetMinMax(minY, maxY); //y-axis

CNiAnnotation newAnnotation = m_graph.Annotations.Add();

newAnnotation.SnapMode = CNiAnnotation::SnapFixed;
newAnnotation.CoordinateType = CNiAnnotation::AxesCoordinates;
CNiShape shape = newAnnotation.Shape;
shape.Type = CNiShape:: Rectangle;

CNiReal64Vector xC,yC;

xC.Append(20); //random numbers to see what happens
yC.Append(2);
xC.Append(3);
yC.Append(5);

shape.SetCoordinates(xC,yC);

newAnnotation.Visible = true;

////////////////////////////////////

...but the SetCoordinates() function doesnt let you place the annotation based on the graph axes... and that's what i need to do. also... i'm going to have a LOT of annotations, so is there a way to create a variable # of annotations easily?

..or is there just an easier way to draw a bunch of colored rectangles to a graph? 😃

thanks,
Ryan
0 Kudos
Message 1 of 2
(3,032 Views)
CNiAnnotation::SnapFixed!! thx all!!



m_graph.Annotations.Add();
m_graph.Annotations.Item(1).Plot = m_graph.Plots.Item(1);
m_graph.Annotations.Item(1).SnapMode = CNiAnnotation::SnapFixed; m_graph.Annotations.Item(1).Shape.Type = CNiShape::Rectangle;
CNiReal64Vector xC,yC;
xC.Append(valminX); xC.Append(valmaxX);
yC.Append(valminY); yC.Append(valminY);
m_graph.Annotations.Item(1).Shape.SetCoordinates(xC,yC);
0 Kudos
Message 2 of 2
(3,026 Views)