|
VerticalLineAnnotation vertical = new VerticalLineAnnotation()
{
X1 = 6,
ShowAxisLabel = true,
Text = "Custom Label",
};
vertical.LabelStyle.BackgroundColor = Color.Cyan;
vertical.LabelStyle.TextColor = Color.Red;
vertical.LabelStyle.TextSize = 12; |
|
ChartGradientColor gradientColor = new ChartGradientColor()
{
StartPoint = new PointF(0,0.5f),
EndPoint = new PointF(1,0.5f)
};
ChartGradientStop stop1 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 0 };
ChartGradientStop stop2 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 0.1f };
ChartGradientStop stop3 = new ChartGradientStop() { Color = Color.Argb(80,133, 147, 48), Offset = 0.1f };
ChartGradientStop stop4 = new ChartGradientStop() { Color = Color.Rgb(133, 147, 48), Offset = 0.5f };
ChartGradientStop stop5 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 0.5f };
ChartGradientStop stop6 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 1};
gradientColor.GradientStops.Add(stop1);
gradientColor.GradientStops.Add(stop2);
gradientColor.GradientStops.Add(stop3);
gradientColor.GradientStops.Add(stop4);
gradientColor.GradientStops.Add(stop5);
gradientColor.GradientStops.Add(stop6);
ChartGradientColorCollection gradientColors = new ChartGradientColorCollection()
{
gradientColor
};
series.ColorModel.ColorPalette = ChartColorPalette.Custom;
series.ColorModel.CustomGradientColors = gradientColors;
ChartGradientColor secondGradient = new ChartGradientColor()
{
StartPoint = new PointF(0, 0.5f),
EndPoint = new PointF(1, 0.5f)
};
ChartGradientStop secondstop1 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 0 };
ChartGradientStop secondstop2 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 0.1f };
ChartGradientStop secondstop3 = new ChartGradientStop() { Color = Color.Argb(80, 82, 160, 40), Offset = 0.1f };
ChartGradientStop secondstop4 = new ChartGradientStop() { Color = Color.Rgb(82, 160, 40), Offset = 0.5f };
ChartGradientStop secondstop5 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 0.5f };
ChartGradientStop secondstop6 = new ChartGradientStop() { Color = Color.WhiteSmoke, Offset = 1 };
secondGradient.GradientStops.Add(secondstop1);
secondGradient.GradientStops.Add(secondstop2);
secondGradient.GradientStops.Add(secondstop3);
secondGradient.GradientStops.Add(secondstop4);
secondGradient.GradientStops.Add(secondstop5);
secondGradient.GradientStops.Add(secondstop6);
ChartGradientColorCollection secondGradientColors = new ChartGradientColorCollection()
{
secondGradient
};
series1.ColorModel.ColorPalette = ChartColorPalette.Custom;
series1.ColorModel.CustomGradientColors = secondGradientColors;
var index = 2;
EllipseAnnotation ellipse1 = new EllipseAnnotation()
{
X1 = index,
Y1 = Data[index].YValue,
Width = 10,
Height = 10,
FillColor = Color.White,
StrokeColor = Color.Rgb(133, 147, 48)
};
LineAnnotation line1 = new LineAnnotation()
{
X1 = index,
Y1 = Data[index].YValue,
X2 = index,
Y2 = Data[index].YValue + 3,
StrokeColor = Color.Rgb(133, 147, 48),
StrokeWidth = 2,
};
TextAnnotation text1 = new TextAnnotation()
{
X1 = index,
Y1 = line1.Y2,
Text = Data[index].YValue + "%",
};
text1.LabelStyle.TextColor = Color.White;
text1.LabelStyle.BackgroundColor = Color.Rgb(133, 147, 48);
chart.Annotations.Add(line1);
chart.Annotations.Add(ellipse1);
chart.Annotations.Add(text1);
EllipseAnnotation ellipse2 = new EllipseAnnotation()
{
X1 = index,
Y1 = Data1[index].YValue,
Width = 10,
Height = 10,
FillColor = Color.White,
StrokeColor = Color.Rgb(82, 160, 40)
};
LineAnnotation line2 = new LineAnnotation()
{
X1 = index,
Y1 = Data1[index].YValue,
X2 = index,
Y2 = Data1[index].YValue + 3,
StrokeColor = Color.Rgb(82, 160, 40),
StrokeWidth = 2,
};
TextAnnotation text2 = new TextAnnotation()
{
X1 = index,
Y1 = line2.Y2,
Text = Data1[index].YValue + "%",
};
text2.LabelStyle.TextColor = Color.White;
text2.LabelStyle.BackgroundColor = Color.Rgb(82, 160, 40);
chart.Annotations.Add(line2);
chart.Annotations.Add(ellipse2);
chart.Annotations.Add(text2); |