|
CD colours using ClickHotSpot event |
Posted by Daniel on Dec-16-2010 07:55 |
|
Hello Peter,
I have created a small example in VB6 trying to change the colours of a barchart using a Common Dialog control. Almost all your example (from documentation) either are colours stored in an array or are randomly set by CD (by default). My purpose is to valorize the ClickHotSpot event for sending the colour values of the Color Control to a bar or other from my project. As you may see, the bars are clickable and the control works fine but something is not very clear for me in transfering the colour values to main chart... To be more specific, how could be included the colour values in the line Set layer = c.addBarLayer3(data, colors(1)). Is it possible? Thank you in advance.
Kind regards,
Daniel Duta
|
Re: CD colours using ClickHotSpot event |
Posted by Peter Kwan on Dec-17-2010 01:33 |
|
Hi Daniel,
I suggest you may use the following code structure:
(a) Initialize the colors array to the initial colors of the bars. Then draw chart.
(b) When the user clicks on a bar, pop up a Color Dialog to allow the user to select a color. Then update the colors array based the which bar the user has clicked, and the color the user has choose. Then draw chart.
I have updated your Form2.frm to provide an example.
Hope this can help.
Regards
Peter Kwan
|
Re: CD colours using ClickHotSpot event |
Posted by Daniel on Dec-17-2010 08:00 |
|
Hello Peter,
Your idea based on initialization is interesting even it is not very clear for me how does DataColor property work...It takes values starting with -65528 (I think the values are pixels stored in a memory because the real function is created inside the CD libraries). It should be a relationship between DataColor parameters and standard RGB or HexaDecimal conversion.
Now, returning to my example, I observed that values of Color Dialog are not properly recognized by the "drawChart" subroutine - even they are not sent randomly...Something goes wrong. For instance, let say I want to have an orange colour for the first bar. Instead of orange I will have a light blue colour and viceversa (I have to choose light blue to obtain an orange colour). Do you think is it a conflict between this common control and CD colour sistem? How could be explained this unusual behaviour while the code lines suggested by you seem to follow a good logic? Simply, the value of "CommonDialog1.Color" does not replace (update) the initial colour value stored in the colors array - of course, according with the index: in our case being related by hotspot function CInt(hotSpot("x")).
On the other hand, reading the CD documentation it seems that CD considers 4 dimensions for a colour (apart of RGB is added an alpha channel for transparency). Each dimension takes integer values on 0-255 range. Is it possible that first 8 bits allocated for alpha transparency to missing from Color Dialog? Because it has allocated just 24 bits for a colour. Taking into account all of these, between ARGB and RGB should be a conversion (setting alpha to zero). Depending on your response I intend to have other approach in my attempt to respresent the CD colours properly (to create a special form with 4 sliders). Thank you in advance.
Kind regards,
Daniel Duta
|
Re: CD colours using ClickHotSpot event |
Posted by Peter Kwan on Dec-17-2010 16:14 |
|
Hi Daniel,
The cd.DataColor refers to the starting point of the palatte entry that contains the "automatic colors" (the colors that would be used if you do not provide a colors array at all when you call addBarLayer2). You may refer to the ChartDirector documentation on "Color Specification" for more details. The code I use sets the initial colors to the automatic colors
For the color dialog, sorry that I forgot to add a line cd.CColor to convert the OLE color to ChartDirector color. The code should be:
CommonDialog1.ShowColor
Dim cd As New ChartDirector.API
colors(CInt(hotSpot("x"))) = cd.CColor(CommonDialog1.Color)
In modern systems, the color system used is RGB. For example, the color used in HTML, and in new Microsoft languages (VB.NET/2002/2003/2005/2008, C#, etc) is RGB.
However, classical COM/VB uses the OLE color system, in which the color components are specified as BGR. Also, like ChartDirector, there are special values in the OLE color system that are interpreted as system palatte colors (instead of BGR). The ChartDirector CColor function converts the OLE colors to ChartDirector RGB colors.
ChartDirector also supports an additional alpha component ARGB. If the alpha component is 0, ChartDirector will just treat the color as RGB. So you can use RGB in ChartDirector as well.
Hope this can help.
Regards
Peter Kwan |
Re: CD colours using ClickHotSpot event |
Posted by Daniel on Dec-17-2010 22:08 |
|
Hello Peter,
Thank you very much for your help. Now, all my issues have disappeared. As usual you have offered me many useful details about ChartDirector and its color system.
I wish you a Merry Christmas!
Best regards,
Daniel |
|