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

Message ListMessage List     Post MessagePost Message

  rendering multi color line graph
Posted by Sriram on Dec-07-2010 14:22
Attachments:
Hi,
I am new to chartdir. I created a line chart using chartdir. In the line chart i wanted to
show threshold values and i used addMark() to show threshold value. But i want to show
threshold values in the line itself by varying colors. for example in the normal cases Y points
will be plotted using blue color when y value crosses threshold it should be plotted using red
color. Is there any way to do like that?
i am uploading sample graph how I want.
Thanks in advance
Untitled.png

  Re: rendering multi color line graph
Posted by Peter Kwan on Dec-08-2010 00:37
Hi Sriram,

You may use a "Y Zone Color" as the line color. See the sample code "Y Zone Coloring" (included in ChartDirector) for an example.

Hope this can help.

Regards
Peter Kwan

  Re: rendering multi color line graph
Posted by Sriram on Dec-13-2010 17:19
Thanks Peter for your reply,
There are two yzonecolor() methods are there. one in XYchart.yzonecolor() and another
layer.yzonecolor() ,which one to use and how to use.
I tried with both of them nothing worked for me.
I am writing the code what i have done.

XYChart c;
LineLayer layer = c.addLineLayer();
layer.addDataSet(cpuusage,0x9999CC," CPU Usage");
layer.yZoneColor(30,0xFF0000,0x9999CC); or c.yZoneColor(30,0xFF0000,0x9999CC);

Please tell me how to get what i want.
If possible please specify code.

Thanks
Sriram

  Re: rendering multi color line graph
Posted by Peter Kwan on Dec-14-2010 02:16
Hi Sriram,

You can use both Layer.yZoneColor or XYChart.yZoneColor. The first one defines the y-zone on the surface of the layer, and the second one defines the y-zone on the surface of the top-most layer.

(If you have multiple layers in 3D, the y-zone position for each layer can be different due to the 3D perspective. For 2D charts, there is no difference between Layer.yZoneColor and XYChart.yZoneColor.)

After defining the yZoneColor, you must tell ChartDirector where to use it. It can be used as the line color, or as many other things your layer can contain (text labels, symbols, .....).

For example:

//create a y-zone color
int myColor = c.yZoneColor(30,0xFF0000,0x9999CC);

//use the color to draw a line
LineLayer layer = c.addLineLayer(cpuusage, myColor ," CPU Usage");

Hope this can help.

Regards
Peter Kwan

  Re: rendering multi color line graph
Posted by Sriram on Dec-20-2010 14:45
Thanks Peter,
I got what I want. But there is a problem with legend(cpu usage). it is always showing last
color as the legend though it wasn't there in the graph.
How to display legend for varying colors?

Thanks
Sriram

  Re: rendering multi color line graph
Posted by Peter Kwan on Dec-21-2010 02:30
Hi Sriram,

The legend is colored using exactly the same method the line is colored in the chart, that is, the legend icon color depends on whether it is above or below the threshold position.

The legend is usually used to associate colors with labels. If you are using a zone color so that one data set can have multiple colors, may be you can use add custom legend keys using Legend.addKey, one for each color. The code is like:

//disable automatic legend entries
layer.setLegendOrder(Chart.NoLegend);

c.getLegend().addKey(0xFF0000, "High CPU Usage");
c.getLegend().addKey(0x9999CC, "Normal CPU Usage");

Hope this can help.

Regards
Peter Kwan

  Re: rendering multi color line graph
Posted by Sriram on Dec-21-2010 14:53
Thank you very much Peter

  Re: rendering multi color line graph
Posted by Sriram on Dec-22-2010 17:35
Hi Peter,

I have one more question. I am creating a linehart where x axis holds timestamp
values(these are 2 to 5 timestamps per minute). these number of timestamps depends upon
how long a test ran( a test can ran from 1 min to 3 days). so number of timestamp values
range from 2 to  10000. as we dont know how many timestamps will be there drawing chart
by keeping chart area fixed resulting into awkward chart.
      Is there any alternative way to show the graph by default only the last 10 or 20 mins
mins of data...if user wants to see whole chart he can scroll to the left and see?
      My ultimate aim is to show the graph neatly irrespective of the number of timestamps.

Thanks

  Re: rendering multi color line graph
Posted by Peter Kwan on Dec-23-2010 02:14
Hi Sriram,

If you want to show the last 10 or 20 mins of data, you may just plot the last 10 or 20 mins of data. It does not matter how much data you have. You just need to plot the data you want to show on the chart.

For example, in a stock chart, the system may contain data for the stock price for the last 20 years. The web site may just plot the stock price for the last 180 days. To do this, just pass the last 180 days of data to the charting code.

There are also two "Zooming and Scrolling Demonstration" sample charts included in the ChartDirector distribution. May be you can use them as references. Basically there is a "user interface" that allows the user to select the period he wants to see. The charting code then just plots the data for that period. The "user interface" can consist of scrollbars, drop down list boxes (to select date range), drag to scroll, a "navigation pad", etc. You are free to use any user interface you like.

Hope this can help.

Regards
Peter Kwan

  Re: rendering multi color line graph
Posted by Sriram on Dec-23-2010 14:17
Attachments:
Thanks for u r reply peter.
One more enhancement to the graph, i have added 5 custom legends to the graph but
those are added one by one top to bottom that occupying chart space. i want legends to
added side by side like the attachment.
how can i do that?

Thanks
Sriram
finance2.png

  Re: rendering multi color line graph
Posted by Peter Kwan on Dec-24-2010 00:23
Hi Sriram,

When you add the legend box using BaseChart.addLegend, you can select whether to use vertical or horizontal layout with the third parameter. There are many sample code included in ChartDirector using horizontal legend layout, such as the "Multi-Line Chart" sample code. May be you can use them as references.

Hope this can help.

Regards
Peter Kwan