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

Message ListMessage List     Post MessagePost Message

  Incorrect Dash Line Color On Track Line
Posted by Robert on Apr-15-2013 13:19
Hi,

I was playing around with the awesome Track Line function :-)
One problem I found is that the client side dataset color it is always Red when I set the
dataset color to dashLineColor.

e.g. ds.setDataColor(c.dashLineColor(color, Chart.DashLine))

If I remove the above line from my code the client side color become correct again.
Not sure If I missed something or this is a bug.

Regards

Robert

  Re: Incorrect Dash Line Color On Track Line
Posted by Peter Kwan on Apr-16-2013 02:33
Hi Robert,

If you are writing a web application, currently, the browser side code cannot support ChartDirector "dynamic colors" used on the server side (dash line colors, zone colors, various types of gradients, etc).

In a web application, the track cursor has to be drawn on the browser side, using whatever feature the browser provides. Common Javascript/CSS/HTML standards do not support the most of the "dynamic colors" used by ChartDirector (such as dash line with configurable mark space patterns, x-zone/y-zone colors, using gradient colors or wall paper patterns as line colors, gradient colors with varying transparency, etc). As a result, ChartDirector dynamic colors would not be rendered correctly on the browser side.

For your case, if you must use a dash line color (or other dynamic color) on the server side, then on the browser side, you cannot use the same color to draw the track cursor or the track "dot". Instead, you would need to use an alternative color supported by Javascript/HTML/CSS. For a dash line color, the most natural color to use would be the base color of the dash line (the "color" in your code).

Regards
Peter Kwan

  Re: Incorrect Dash Line Color On Track Line
Posted by Robert on Apr-16-2013 05:41
Hi Peter,

Thanks for your speedy reply.

I thought dashline colors and normal colors are the same in color. The only difference is that
one is drawn in dash line and the other is drawn in solid line. That is why I was expecting
the client side color to match the dashline's base color. But from what you saying about the
dynamic colors there could be more difference between the two?

Is there a way at the moment for me to override the dashline color property on the
JavaScript Chart Model so that I could use a dashline color on the server side and normal
color on the client side?

Regards

Robert

  Re: Incorrect Dash Line Color On Track Line
Posted by Peter Kwan on Apr-17-2013 01:33
Hi Robert,

In general, for a dynamic color, there may not be a "base color". For example, for a gradient color from red to green, the "base color" cannot be undefined. For the special case of a dash line color, we can say the "base color" is the color of the dash. Unluckily, currently ChartDirector does not handle the "dash line color" as a special case, and it treats all dynamic colors as being unsupported on the browser side.

For your case, may be you can specific two colors for certain data sets - one as the server side color to plot the chart, and one as the browser side color for track cursors. The browser side color must be Javascript/HTML/CSS compatible.

I am not exactly sure which programming language you are using. It seems to be VB.NET (but C# and Java are also possible), so I will use VB.NET as an example:

'declare a Form member variable to hold the browser side colors
Dim colorMap as new New System.Collections.ArrayList()

.....


'Server side color
ds.setDataColor(c.dashLineColor(color, Chart.DashLine))
'Map the server side color to a browser side color #XXXXXX, where XXXXXX is the "base color" in hex
colorMap.Add(ds.getDataColor() & ":'#" & String.Format("{0:X6}", color) & "'")


You only need to apply the above for dynamic colors, but it will not cause any issue if you also apply them for normal colors. So if you do not bother to distinguish the two cases, you may simply apply the above to all data sets. You may also make the above into a subroutine to avoid repeatedly typing the code.

Now in the Javascript part of the code, the first line should be:

//Pass the server side colorMap to the browser side
var colorMap = {<%= String.Join(",", TryCast(colorMap.ToArray(GetType(String)), String())) %>};

To get the data set color, you may use:

var color = dataSet.getDataColor();
// if there is a colorMap entry, use the mapped color
if (colorMap[parseInt(color.substr(1), 16)])
     color = colorMap[parseInt(color.substr(1), 16)];

Hope this can help.

Regards
Peter Kwan

  Re: Incorrect Dash Line Color On Track Line
Posted by Robert on Apr-17-2013 07:13
Thanks for the code Peter!
I somehow forgot about the whole JavaScript Library section in the documentation.
I will give it a go.

Cheers

Robert