0

I'm using ZedGraph to plot data. ZedGraph is awesome for ploting many curve with good performance, but takes some time to figure out the tricks. I make many research on the net but i didn't find any solution on textlabels y axis I have a Y2axis type linear where i plot my curve, and i haveYaxis type= text where i want to show textlabel but i want that textlabel[index] is aligned with y2[index] value. To better understand, I read data from a database in this format: ----Col1------ Col2 --------Col3

----A ----------122.3 -------05:22:00

----B---------- 150.3 -------06:33:22

I try to edit the scale.majorStep, scale.min, or ScaleFormatEvent but I can not to align textlabel Yaxis with data Y2axis, beacuse y2 axis point are variable. here is the code

chart2.GraphPane.CurveList["curve1"].AddPoint((XDate)(Col3[i]), Col2[i]);
myPane02m.Y2Axis.Type = ZedGraph.AxisType.Linear;
myPane02m.YAxis.Type = ZedGraph.AxisType.Text
myPane02m.YAxis.Scale.TextLabels = Col1;
myPane02m.YAxis.Scale.Min = minY;
myPane02m.YAxis.Scale.Max = maxY;
myPane02m.Y2Axis.Scale.Min = minY;
myPane02m.Y2Axis.Scale.Max = maxY;
myPane02m.YAxis.Scale.MajorStep = Offset;
myPane02m.YAxis.Scale.MinorStep = Offset;
myPane02m.Y2Axis.Scale.MajorStep = Offset;
myPane02m.Y2Axis.Scale.MinorStep = Offset;
public string MyCustomFormatter(GraphPane pane, Axis axis, double val, int index)
{
if (index < numberPoint)
{

            string label =  getCol1().ElementAt(index).ToString();
            //MessageBox.Show(label);
            return label;
            //}
        }
        else
        {
            return "";
        }
    }

`

`

i want that the textlabel(Column1) is at y Axis and Col2 at y2 axis

It would be awsome if someone found a solution for my problem thanks

Redha Ben
  • 13
  • 7

1 Answers1

0

there's one solutioon:

Is to use Textobj and to put X=0

 double label1Y = Curve.Points[i].Y; //LineItem
    TextObj txtObj1 = new TextObj(Column1.ToString() + "   " + label1Y.ToString("0.0"), 0, label1Y, ZedGraph.CoordType.XChartFractionYScale, ZedGraph.AlignH.Right, ZedGraph.AlignV.Center);

                        txtObj1.FontSpec.Border.IsVisible = false;
                        txtObj1.FontSpec.Fill.IsVisible = false;
                        txtObj1.FontSpec.Size = 5f;
                        txtObj1.FontSpec.IsAntiAlias = true;
                        txtObj1.FontSpec.Angle = 0;
                        // MessageBox.Show(txtObj1.FontSpec.StringAlignment.ToString());
                        txtObj1.IsVisible = true;
                        //txtObj1.Location.
                        txtObj1.ZOrder = ZOrder.A_InFront;

                        //txtObj1.IsInFrontOfData(true);
                        chart2.GraphPane.GraphObjList.Add(txtObj1);
Redha Ben
  • 13
  • 7