ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Utility to Specify Color as int
Posted by MarkZB on Jun-05-2018 14:13
Is there an extension to specify color as hex int? Similar to:

https://stackoverflow.com/questions/39137486/converting-colour-name-to-hex-in-c-sharp

public static class HexColorExtensions {
        public static string ToHex(this Color c) => $"#{c.R:X2}{c.G:X2}{c.B:X2}";
}

I prefer not to have to specify color in hex int.

  Re: Utility to Specify Color as int
Posted by Peter Kwan on Jun-05-2018 23:46
Hi MarkZB,

ChartDirector uses integers to represent colors. Do you mean to convert the .NET System.Drawing.Color object to an integer? The API is Chart.CColor. For example:

c.addBarLayer(myData, Chart.CColor(Color.Red));

Hope this can help.

Regards
Peter Kwan

  Re: Utility to Specify Color as int
Posted by MarkZB on Jun-05-2018 23:56
Yes thats it. I prefer

chart.addCandleStick(Chart.CColor(Color.Red), Chart.CColor(Color.LightBlue));

over...

chart.addCandleStick(0x00ff00, 0xff0000);