Jump to content
Software FX Community

Changing colors on series using C# (.NET) and Labels/Legends


User (Legacy)

Recommended Posts

Hello again,

I have two questions today.

1) First a problem when trying to change colors on ceratin series in the

chart. It works fine for constant lines, but nothing happens when I try it

on the series. I use the following code:

chart.OpenDataEx(CfxCod.COD_VALUES, 4, dsLength);

...

(insert the values)

...

chart.CloseData(CfxCod.COD_VALUES);

Then I try to change the colors using this code:

chart.OpenDataEx(CfxCod.COD_COLORS, 2, 0);

chart.Series[2].Color = uiColRed;

chart.Series[3].Color = uiColGreen;

chart.CloseData(CfxCod.COD_COLORS);

Is this the correct way of doing it? The series do change colors, but not to

the ones I chose, and I can't change them to any other colors.

2) Is there a way to use "labels" with series, like with constant lines? I

know I can use legends but I'd like the text inside the chart, just

above/below a series. Is an annotation the only solution to this?

TIA,

Rolle

NB. I'm using version Cfx IE 5.5 with C# (.NET)

Link to comment
Share on other sites

Yes, I am passing the correct value for the color red with uiColRed. But

it's not of type RGB(255,0,0) since this doesn't work in .NET/C#.

It works fine for constant lines. But when I try to change the color for a

series it doesn't matter what I use, it doesn't care. I have even tried not

sending any color at all, and I still get the color chosed by Chart FX. So

in other words, it doesn't matter if I set any color when using

chart.OpenDataEx(CfxCod.COD_COLORS, 2, 0) because it changes automatically

to some standard color. If I don't use CfxCod.COD_COLORS it uses some other

standard color. The following code gives the same result (pseudo):

chart.OpenDataEx(CfxCod.COD_COLORS, 2, 0);

chart.Series[2].Color = uiColRed;

chart.Series[3].Color = uiColGreen;

chart.CloseData(CfxCod.COD_COLORS);

chart.OpenDataEx(CfxCod.COD_COLORS, 2, 0);

// Do nothing

chart.CloseData(CfxCod.COD_COLORS);

But it works when I do this:

chart.ConstantLine[0].LineColor = uiColRed;

chart.ConstantLine[1].LineColor = uiColGreen;

But I am not sure on how to use chart.OpenDataEx(CfxCod.COD_COLORS, 2, 0),

so I might be doing something wrong..? It should work in .NET too...right..?

Regards,

Rolle

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:z#3HREZDDHA.2720@webserver1.softwarefx.com...

> 1) What is uiColRed ? you need to pass an OLE color like RGB(255,0,0)

>

> 2) The series legend only shows in the series legend box. It can not be

> displayed in the chart itself. You can indeed use annotation objects to do

> this.

>

> --

> FP

> Software FX, Inc.

>

>

Link to comment
Share on other sites

Sorry, I didn't realize this before but you are doing:

chart.OpenDataEx(CfxCod.COD_COLORS, 2, 0);

chart.Series[2].Color = uiColRed;

chart.Series[3].Color = uiColGreen;

chart.CloseData(CfxCod.COD_COLORS);

This code allocates two (2) colors only, Series[0] and Series[1] but then

you are trying to assign Series[2] and Series[3]. If you have 4 series you

need to do:

chart.OpenDataEx(CfxCod.COD_COLORS, 4, 0);

chart.Series[0].Color = ???;

chart.Series[1].Color = ???;

chart.Series[2].Color = uiColRed;

chart.Series[3].Color = uiColGreen;

chart.CloseData(CfxCod.COD_COLORS);

--

FP

Software FX, Inc.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...