Click here to Skip to main content
14,773,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wish the function AddLine

LineItem myCurve = myPane1.AddCurve("", x_axis_array, Y_AxixArray, Color.Black, SymbolType.Diamond);

could have an option of:

LineItem myCurve = myPane1.AddCurve("", x_axis_array, Y_AxixArray,COLOR_ARRAY[],  SymbolType.Diamond);

Hopefully you get what I want to do.

Any answer is highly appreciated.!
Updated 27-Oct-17 0:09am

   Color currentColor = myColorArr[0];<br />
               //int startidx = 0;<br />
               for (int i = 0; i < datacount; i++)<br />
               {<br />
                   if (currentColor == myColorArr[i])<br />
                   {<br />
                       list_x.Add(list_x[i]);<br />
                       list_y.Add(list_y[i]); <br />
                   }<br />
                   else<br />
                   {<br />
                       list_x.Add(list_x[i]);<br />
                       list_y.Add(list_y[i]);<br />
<br />
                       LineItem myCurve1 = myPane1.AddCurve("", list_x.ToArray(), list_y.ToArray(), myColorArr[i-1],SymbolType.Diamond);<br />
                       myCurve1.Line.IsVisible = true; // was false for scatter plot<br />
                       myCurve1.Symbol.Fill = new Fill(myColorArr[i - 1]);<br />
                       list_x.Clear();<br />
                       list_y.Clear();<br />
                       currentColor = myColorArr[i];<br />
                       list_x.Add(list_x[i]);<br />
                       list_y.Add(list_y[i]); <br />
                   }<br />

Thanks for your help!
[no name] 29-Jun-11 0:30am
Good Call. My 5 too.
(I assume you are talking about the opensource zedgraph[^])

You could download the code and do the modification yourself; and if that works, submit the changes to the zedgraph project.

Other than that, I don't know zedgraph.

MinMeng 28-Jun-11 16:36pm
Thanks! Yes it's open source zedgraph. I'm seeking a way that doesn't have to go that far. Does anyone know the tricks to achieve the same goal using existing APIs? ( draw one curve with different colors - can specify color for each individual data point)
TRK3 28-Jun-11 18:18pm
Do you want the curve itself to change colors, or just the symbols on the dots to be different colors? If it's just the symbols, can't you draw them separately?
MinMeng 28-Jun-11 21:07pm
Just the symbols on the dots to be different color. It's a good thougt. But may only work for small amount data. In my case, it could easily have >10000 data points. each data point could be any one of 7 different colors. it will need a lot data arrays to hold all the data. (as I know,zedgraph needs all the arrays in memory, i.e. we couldn't just use one data array to process this--- correct me if I'm wrong).
MinMeng 28-Jun-11 21:35pm
Did some test. Looks ok to do. I used a same list data structure to hold the data of the same color. see sample code below:

Thanks a lot for your help answering my questions!! I will test more on big amount data to see if it still works good enough - not sure about execution speed for big amount data.

Color currentColor = myColorArr[0];
for (int i = 0; i < datacount; i++)
if (currentColor == myColorArr[i])

LineItem myCurve1 = myPane1.AddCurve("", list_x.ToArray(), list_y.ToArray(), myColorArr[i-1],SymbolType.Diamond);
myCurve1.Line.IsVisible = true; // was false for scatter plot
myCurve1.Symbol.Fill = new Fill(myColorArr[i - 1]);

currentColor = myColorArr[i];
No need to group the point with same color,see example as below

GraphPane gp=ZedGraphControl.GraphPane;
PointPairList pointXY=new PointPairList();
LineItem point=gp.AddCurve("Label",pointXY,YourColor,SymbolType.Circle);

then a circle symbol will be plotted, you can fill the circle symbol with your target color
H.Brydon 17-Jul-13 12:37pm
Question is from 2011 - why are you answering it now?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900