Я создаю простой график со средней линией (только образец), у меня есть код в HorizontalLineAnnotation (красная линия) и TextAnnotation, но проблема в том, что TextAnnotation не работает правильно.
Вот мой код в HorizontalLineAnnotation и TextAnnotation.
Код: Выделить всё
private void annptaion()
{
//insert line
HorizontalLineAnnotation hl = new HorizontalLineAnnotation();
hl.AllowMoving = false;
hl.IsInfinitive = true;
//hl.LineColor = System.Drawing.Color.Red;
hl.AnchorY = Convert.ToDouble(2);//row line
hl.AxisX = chart1.ChartAreas[0].AxisX;
hl.AxisY = chart1.ChartAreas[0].AxisY;
hl.ClipToChartArea = chart1.ChartAreas[0].Name; hl.LineColor = Color.Red; hl.LineWidth = 1;//make line
hl.IsSizeAlwaysRelative = false;
chart1.Annotations.Add(hl);
//insert text
TextAnnotation ta = new TextAnnotation();
ta.AxisX = chart1.ChartAreas[0].AxisX;
ta.AxisY = chart1.ChartAreas[0].AxisY;
ta.IsSizeAlwaysRelative = false;
ta.AnchorAlignment = ContentAlignment.BottomLeft;
ta.Text = "average (sample)";
ta.ClipToChartArea = chart1.ChartAreas[0].Name; ta.ForeColor = Color.Red;
chart1.Annotations.Add(ta);
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... ph-c-sharp
Мобильная версия