public ChartPrimitiveHBar AddNewHBar(double centerPoint, double height) { ChartPrimitiveHBar primitive = CreateHBar(centerPoint, height); _primitiveList.Add(primitive); return(primitive); }
public static void AddTestLines(ChartControl xyLineChart) { ChartControl factory = xyLineChart; // Add test Lines to demonstrate the control xyLineChart.Reset(); double limit = 5; double increment = .05; // Create 3 normal lines ChartPrimitiveXY[] lines = new ChartPrimitiveXY[3]; for (int lineNo = 0; lineNo < 3; ++lineNo) { ChartPrimitiveXY line = factory.CreateXY(); // Label the lines line.Label = "Test Line " + (lineNo + 1).ToString(); line.IsDashed = false; line.IsHitTest = true; line.LineThickness = 1.5; line.ShowPoints = true; line.AddPoint(0, 0); // Draw 3 sine curves for (double x = 0; x < limit + increment * .5; x += increment) { line.AddPoint(x, Math.Cos(x * Math.PI - lineNo * Math.PI / 1.5)); } line.AddPoint(limit, 0); // Add the lines to the chart xyLineChart.AddPrimitive(line); lines[lineNo] = line; } // Set the line colors to Red, Green, and Blue lines[0].FillColor = Color.FromArgb(90, 255, 0, 0); lines[1].FillColor = Color.FromArgb(90, 0, 180, 0); lines[2].FillColor = Color.FromArgb(90, 0, 0, 255); // Set the line colors to Red, Green, and Blue lines[0].LineColor = Colors.Red; lines[1].LineColor = Colors.Green; lines[2].LineColor = Colors.Blue; lines[0].LegendColor = Colors.Red; lines[1].LegendColor = Colors.Green; lines[2].LegendColor = Colors.Blue; ChartPrimitiveHBar[] bars = new ChartPrimitiveHBar[3]; // Set the line colors to Red, Green, and Blue Color[] barLineColors = new Color[] { Colors.Red, Colors.Green, Colors.Blue }; Color[] barFillColors = new Color[] { Color.FromArgb(90, 255, 0, 0), Color.FromArgb(90, 0, 180, 0), Color.FromArgb(90, 0, 0, 255) }; int colorIndex = 0; GridLineOverride gridLineOverride = new GridLineOverride(Orientation.Horizontal); gridLineOverride.Range = new Range <double>(-0.2 * (0 + 1) - 1 + 0.05, -0.2 * (2 + 1) - 1 - 0.05); for (int barNo = 0; barNo < 3; ++barNo) { ChartPrimitiveHBar bar = factory.CreateHBar(-0.2 * (barNo + 1) - 1, 0.05); gridLineOverride.AddLabel("Bar " + (barNo + 1).ToString(), -0.2 * (barNo + 1) - 1, Orientation.Horizontal); // Label the lines bar.IsDashed = false; bar.LineThickness = 1; bar.IsHitTest = true; bar.Label = "Test Bar " + (barNo + 1).ToString(); colorIndex = barNo; for (double x = 0; x < 4 + barNo; x += 0.1 * (4 + barNo)) { bar.AddSegment(x, x + 0.1 * (4 + barNo), barLineColors[colorIndex], barFillColors[colorIndex]); colorIndex = (colorIndex + 1) % 3; } // Add the lines to the chart xyLineChart.AddPrimitive(bar); bars[barNo] = bar; } xyLineChart.GridLineOverrides.Add(gridLineOverride); xyLineChart.Title = "Test Chart Title"; xyLineChart.XAxisTitle = "Test Chart X Axis"; xyLineChart.YAxisTitle = "Test Chart Y Axis"; xyLineChart.RedrawPlotLines(); }
public static void AddTestLines(ChartControl xyLineChart) { ChartControl factory = xyLineChart; // Add test Lines to demonstrate the control xyLineChart.Reset(); double limit = 5; double increment = .05; // Create 3 normal lines ChartPrimitiveXY[] lines = new ChartPrimitiveXY[3]; for(int lineNo = 0; lineNo < 3; ++lineNo) { ChartPrimitiveXY line = factory.CreateXY(); // Label the lines line.Label = "Test Line " + (lineNo + 1).ToString(); line.IsDashed = false; line.IsHitTest = true; line.LineThickness = 1.5; line.ShowPoints = true; line.AddPoint(0, 0); // Draw 3 sine curves for(double x = 0; x < limit + increment * .5; x += increment) { line.AddPoint(x, Math.Cos(x * Math.PI - lineNo * Math.PI / 1.5)); } line.AddPoint(limit, 0); // Add the lines to the chart xyLineChart.AddPrimitive(line); lines[lineNo] = line; } // Set the line colors to Red, Green, and Blue lines[0].FillColor = Color.FromArgb(90, 255, 0, 0); lines[1].FillColor = Color.FromArgb(90, 0, 180, 0); lines[2].FillColor = Color.FromArgb(90, 0, 0, 255); // Set the line colors to Red, Green, and Blue lines[0].LineColor = Colors.Red; lines[1].LineColor = Colors.Green; lines[2].LineColor = Colors.Blue; lines[0].LegendColor = Colors.Red; lines[1].LegendColor = Colors.Green; lines[2].LegendColor = Colors.Blue; ChartPrimitiveHBar[] bars = new ChartPrimitiveHBar[3]; // Set the line colors to Red, Green, and Blue Color[] barLineColors = new Color[]{ Colors.Red, Colors.Green, Colors.Blue }; Color[] barFillColors = new Color[]{ Color.FromArgb(90, 255, 0, 0), Color.FromArgb(90, 0, 180, 0), Color.FromArgb(90, 0, 0, 255) }; int colorIndex = 0; GridLineOverride gridLineOverride = new GridLineOverride(Orientation.Horizontal); gridLineOverride.Range = new Range<double>(-0.2 * (0 + 1) - 1 + 0.05, -0.2 * (2 + 1) - 1 - 0.05); for(int barNo = 0; barNo < 3; ++barNo) { ChartPrimitiveHBar bar = factory.CreateHBar(-0.2 * (barNo + 1) - 1, 0.05); gridLineOverride.AddLabel("Bar " + (barNo + 1).ToString(),-0.2 * (barNo + 1) - 1, Orientation.Horizontal); // Label the lines bar.IsDashed = false; bar.LineThickness = 1; bar.IsHitTest = true; bar.Label = "Test Bar " + (barNo + 1).ToString(); colorIndex = barNo; for(double x = 0; x < 4 + barNo; x += 0.1 * (4 + barNo)) { bar.AddSegment(x, x+ 0.1 * (4 + barNo), barLineColors[colorIndex], barFillColors[colorIndex]); colorIndex = (colorIndex + 1) % 3; } // Add the lines to the chart xyLineChart.AddPrimitive(bar); bars[barNo] = bar; } xyLineChart.GridLineOverrides.Add(gridLineOverride); xyLineChart.Title = "Test Chart Title"; xyLineChart.XAxisTitle = "Test Chart X Axis"; xyLineChart.YAxisTitle = "Test Chart Y Axis"; xyLineChart.RedrawPlotLines(); }