Hi Bernhard,
Please regerence to the following function:
void PlotWeightedHistogram()
{
// assume the active worksheet has two columns, first column contains value data, another column contains counts data.
Worksheet wks = Project.ActiveLayer();
if( wks )
{
DataRange dr;
dr.Add(wks, 0, "Range1");
dr.Add(wks, 1, "Range2");
vector vValues;
vector vCounts;
dr.GetData(&vValues, 0); // 1st range for Values data
dr.GetData(&vCounts, 1); // 2nd range for Counts data
vector vData;
for(int ii=0; ii<vCounts.GetSize(); ii++)
{
vector vTemp;
vTemp.SetSize(vCounts[ii]);
vTemp = (double)vValues[ii];
vData.Append(vTemp);
}
// add a new column and put data from vData to it
DataRange dr2;
dr2.Add(wks, wks.AddCol(), "X");
dr2.SetData(vData);
// plot histogram
GraphPage gp;
gp.Create("HIST"); // HIST is the graph template for histogram plot
GraphLayer gl = gp.Layers(-1); // get active layer
int index = gl.AddPlot(dr2, IDM_PLOT_HISTOGRAM_TYPE);
if(index >= 0)
{
out_str("Successfully plot histogram");
gl.Rescale();
}
}
}
Iris