I am trying calculate the y position in pixels of a series that is using a custom axis. Using the axis.CalcYPosValue is always returning 0. Is there a way to do this with Custom axes?
Code: Select all
Axis anomaliesAxis = new Axis(false, false, mChart.Chart);
anomaliesAxis.Title.Text = "Clock";
anomaliesAxis.Inverted = true;
anomaliesAxis.SetMinMax(0, 12);
anomaliesAxis.StartPosition = 10;
anomaliesAxis.EndPosition = 100;
foreach (Series s in mChart.Series)
{
// scatter series
s.FillSampleValues();
for (int i = 0; i < 101; i++)
{
Random rnd = new Random();
if(i == 0)
{
s.XValues.Value[i] = 0;
}
else
{
s.XValues.Value[i] = rnd.NextDouble() * 1000;
}
s.YValues.Value[i] = rnd.NextDouble() * 12;
}
s.CustomVertAxis = anomaliesAxis;
mChart.Axes.Custom.Add(anomaliesAxis);
}
int boxCounter = 0;
foreach (double valueX in aChart.Series[0].XValues.Value)
{
if (boxCounter > 24)
{
break;
}
double valueY = aChart.Series[0].YValues.Value[boxCounter];
int x = rndX.Next(0, 50);
int y = rndY.Next(0, 100);
Axis axis = aChart.Series[0].CustomVertAxis;
int y1 = axis.CalcYPosValue(valueY); // --> always returns 0
boxCounter++;
}