Jump to content
Software FX Community

Creating legends for a multiplecolor XY plot


User (Legacy)

Recommended Posts

I have the following code to populate a MuitipleColor XY-plot.  I plot the +/- as Blue/Red.  I would like to create a legend that would always be consistant so that Blue is always + and Red is always - regardless of the order in which they exist in the array.  It seems that now it automatically grabs the color for the first legend from the color of the first element in the array.  

Help???

int array[] = {-3,-2,-1,1,2,3};

// I plot the data into chart

m_pChartFX2->OpenDataEx(COD_XVALUES, 1, 6);

for(int i=0; i<6; i++)

{

m_pChartFX2->ValueEx[0][i] = array[i];

m_pChartFX2->XValueEx[0][i] = i;

}

m_pChartFX2->CloseDAtaEx(COD_XVALUES);

// I then set the colors for each point

m_pChartFX2->MultipleColors = true;

m_pChartFX2->OpenDataEx(COD_COLORS, 6, 0);

for(i=0; i<6; i++)

{

if (array[i] < 0)

m_pChartFX2->Color[i] = RGB(255,0,0);

else

m_pChartFX2->Color[i] = RGB(0,0,255);

}

m_pChartFX2->CloseData(COD_COLORS);

// I create two legend labels

m_pChartFX2->SerLeg[0] = "Positive Values";

m_pChartFX2->SerLeg[1] = "Negative Values";

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...