I have a requirement to create line chart graphs that involve data from several sources, and I need to identify the sources in the x-axis legend (see the attached image for an example)
How would I achieve this effect with your graphing tools?
Hi Richard,
The easiest way to accomplish this is probably to combine the data sources together and plot one line. An alternative approach could be to set up each source as a separate series, and plot them each at a different location.
Please try this out and let me know if you need any further explanation.
To clarify, I am populating the grid with a NumberSeries object.
How can I use a NumberSeries object to achieve this effect?
If you use a Composite Chart, you can eliminate the space between the bottom of the chart and the TitleBottom string. The composite chart settings allow you to control the sizing and position of all the chart elements. I recommend using the chart wizard rather than doing this in code. I've taken a screenshot of the relevant settings and attached it here.
Note that MeasureType is set to Percentage, Width is set to 100%, and Height is set to 90%
Please try this out and let me know whether it works for your needs.
I will have to do this in code because for this particular app, I need to create 1-n charts in a form depending on the data presented.
I have downloaded sample code for a composite chart, and will go from there.
Mike,
I have implemented the composite chart, and as you indicated, I have more control over the titles and sizing. However, I cannot get the lines to display in the chart. I followed a composite line chart sample (done in VS 2010), and that project works. I also added a chart to my project and used the code from that. But I can't get it working in my logic - see the image below.
As I mentioned, I need to do this in code because for this app requires a variable number of charts to be displayed depending on the data. My code is also pasted below.
Several other questions:
1. I set the height of the chart to 400, but the chart display is not respecting that value.
2. What properties should I use to set the margins for the top and bottom titles?
3. How do I set the LineAppearance for lines in a composite chart
int height = 600; int width = 400; for (int index = 0; index < list.Count; index++) { List<ViewLabTestData> listEntry = list[index]; string title = ""; if (listEntry[0].LabTest.Contains("Impedance")) { labTest = "Impedance"; title = labTest; } else if (listEntry[0].LabTest.Contains("Insertion Loss")) { labTest = "Insertion Loss"; title = string.Format("{0} @ {1} {2}", labTest, listEntry[0].MarkerFrequency.ToString("#0.####"), Enums.GetStringFromValue<Enums.FrequencyBandwidthUoM>(listEntry[0].MarkerValue_UoM)); } int left = (index % 2 == 0) ? 0 : width + _chartSpacing; int top = (index / 2) * (height + _chartSpacing); ChartLayerAppearance chartLayer = null; UltraChart chart = InfragisticsChartHelper.CreateCompositeChart(out chartLayer, title, 12, width, height, left, top); chart.TitleBottom.Text = "Orders"; pnlGraphs.Controls.Add(chart); NumericSeries borderTop = InfragisticsChartHelper.CreateCompositeLine(chart, chartLayer, LineDrawStyle.Solid, 1, System.Drawing.Color.White); NumericSeries borderBottom = InfragisticsChartHelper.CreateCompositeLine(chart, chartLayer, LineDrawStyle.Solid, 1, System.Drawing.Color.White); NumericSeries min = InfragisticsChartHelper.CreateCompositeLine(chart, chartLayer, LineDrawStyle.Solid, 3, System.Drawing.Color.Red); NumericSeries max = InfragisticsChartHelper.CreateCompositeLine(chart, chartLayer, LineDrawStyle.Solid, 3, System.Drawing.Color.Red); NumericSeries value = InfragisticsChartHelper.CreateCompositeLine(chart, chartLayer, LineDrawStyle.Solid, 2, System.Drawing.Color.Black); NumericSeries control = InfragisticsChartHelper.CreateCompositeLine(chart, chartLayer, LineDrawStyle.Solid, 1, System.Drawing.Color.Black); List<string> orderNoList = listEntry.Select(o => o.OrderNumber).Distinct().OrderByDescending(o => o).ToList(); while (orderNoList.Count > 4) orderNoList.RemoveAt(4); int count = 0; double average = 0; foreach (ViewLabTestData entry in listEntry) { if (orderNoList.Contains(entry.OrderNumber)) { min.Points.Add(new NumericDataPoint((double)entry.MarkerValue_Min, "", false)); max.Points.Add(new NumericDataPoint((double)entry.MarkerValue_Max, "", false)); borderTop.Points.Add(new NumericDataPoint((double)entry.MarkerValue_Max + 0.5, "", false)); borderBottom.Points.Add(new NumericDataPoint((double)entry.MarkerValue_Min - 0.5, "", false)); value.Points.Add(new NumericDataPoint((double)entry.MarkerValue_TestValue, "", false)); average += (double)entry.MarkerValue_TestValue; count++; } } if (count > 0) { average /= count; for (int avgPoint = 0; avgPoint < count; avgPoint++) control.Points.Add(new NumericDataPoint(average, "", false)); } } if (list.Count > 0) { pnlGraphs.Width = (list.Count <= 1) ? width : (width * 2) + _chartSpacing; pnlGraphs.Height = (((list.Count / 2) + 1) * height) + ((list.Count / 2) * _chartSpacing); this.Size = new Size(pnlGraphs.Width + (_chartSpacing * 3), pnlGraphs.Height + (_chartSpacing * 4)); this.Left = (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - this.Size.Width) / 2; this.Top = (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - this.Size.Height) / 2; } else { ScreenHelper.DisplayWarning("There was no data to be graphed"); this.Close(); } public static UltraChart CreateCompositeChart( out ChartLayerAppearance chartLayer, string title, float fontSize, int width = 400, int height = 300, int left = 0, int top = 0, bool xAxis = false) { UltraChart chart = null; chartLayer = null; try { chart = SetChartDefaults(ChartType.Composite, title); chart.TitleTop.Font = new Font(FontFamily.GenericSansSerif, fontSize, FontStyle.Regular); chart.TitleBottom.Font = new Font(FontFamily.GenericMonospace, fontSize - 4, FontStyle.Regular); //chart.TitleBottom.Margins.Top = 0; chart.TitleLeft.Visible = false; chart.TitleRight.Visible = false; chart.Location = new Point(left, top); chart.Size = new Size(width, height); ChartArea chartArea = new ChartArea(); chartArea.Key = "chartArea"; chartArea.GridPE = new PaintElement(); chartArea.PE = new PaintElement(); chart.CompositeChart.ChartAreas.Add(chartArea); AxisItem axisY = new AxisItem(); axisY.OrientationType = AxisNumber.Y_Axis; axisY.DataType = AxisDataType.Numeric; axisY.Key = "axisY"; axisY.Labels.FontColor = System.Drawing.Color.Empty; axisY.Labels.HorizontalAlign = StringAlignment.Near; axisY.Labels.ItemFormatString = "<DATA_VALUE:#,###.##>"; axisY.Labels.Orientation = TextOrientation.Horizontal; axisY.Labels.SeriesLabels.FontColor = System.Drawing.Color.Empty; axisY.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Center; axisY.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; axisY.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; axisY.Labels.SeriesLabels.Visible = true; axisY.Labels.VerticalAlign = StringAlignment.Center; axisY.Labels.Visible = true; axisY.MajorGridLines.AlphaLevel = ((byte)(255)); axisY.MajorGridLines.Color = System.Drawing.Color.Gainsboro; axisY.MajorGridLines.DrawStyle = LineDrawStyle.Dot; axisY.MajorGridLines.Visible = true; axisY.MinorGridLines.AlphaLevel = ((byte)(255)); axisY.MinorGridLines.Color = System.Drawing.Color.LightGray; axisY.MinorGridLines.DrawStyle = LineDrawStyle.Dot; axisY.MinorGridLines.Visible = false; axisY.SetLabelAxisType = SetLabelAxisType.GroupBySeries; chartArea.Axes.Add(axisY); AxisItem axisX = new AxisItem(); if (xAxis) { axisX.DataType = AxisDataType.String; axisX.Labels.ItemFormatString = "<ITEM_LABEL>"; axisX.OrientationType = AxisNumber.X_Axis; axisX.SetLabelAxisType = SetLabelAxisType.ContinuousData; chartArea.Axes.Add(axisY); } else chart.Axis.X.Labels.Visible = false; chartLayer = new ChartLayerAppearance(); chartLayer.ChartType = ChartType.LineChart; chartLayer.Key = "chartLayer"; chartLayer.ChartArea = chartArea; chartLayer.ChartAreaKey = "chartArea"; chartLayer.AxisY = axisY; chartLayer.AxisYKey = "axisY"; if (xAxis) { chartLayer.AxisX = axisX; chartLayer.AxisXKey = "axisX"; } chart.CompositeChart.ChartLayers.Add(chartLayer); } catch (Exception ex) { } return chart; } public static NumericSeries CreateCompositeLine( UltraChart chart, ChartLayerAppearance chartLayer, LineDrawStyle drawStyle, int thickness, System.Drawing.Color color) { NumericSeries series = null; try { series = new NumericSeries(); series.PEs.Add(new PaintElement(color)); chart.CompositeChart.Series.Add(series); chartLayer.Series.Add(series); LineAppearance line = new LineAppearance(); line.LineStyle.DrawStyle = drawStyle; line.Thickness = thickness; // How to add line appearance object? } catch (Exception ex) { } return series; } private static UltraChart SetChartDefaults(ChartType chartType, string title) { UltraChart chart = null; try { chart = new UltraChart(); chart.ChartType = chartType; chart.Name = title; chart.TitleTop.Text = title; chart.TitleTop.Orientation = TextOrientation.Horizontal; chart.TitleTop.HorizontalAlign = StringAlignment.Center; chart.TitleBottom.Orientation = TextOrientation.Horizontal; chart.TitleBottom.HorizontalAlign = StringAlignment.Center; PaintElement paintElement = new Infragistics.UltraChart.Resources.Appearance.PaintElement(); GradientEffect gradientEffect = new Infragistics.UltraChart.Resources.Appearance.GradientEffect(); chart.Axis.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(248)))), ((int)(((byte)(220))))); chart.Axis.X.Labels.Font = new Font("Verdana", 7F); chart.Axis.X.Labels.FontColor = System.Drawing.Color.DimGray; chart.Axis.X.Labels.HorizontalAlign = StringAlignment.Near; chart.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL>"; chart.Axis.X.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.X.Labels.Orientation = TextOrientation.VerticalLeftFacing; chart.Axis.X.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.X.Labels.SeriesLabels.FontColor = System.Drawing.Color.DimGray; chart.Axis.X.Labels.SeriesLabels.FormatString = ""; chart.Axis.X.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; chart.Axis.X.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.X.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing; chart.Axis.X.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.X.Labels.SeriesLabels.Visible = true; chart.Axis.X.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.X.Labels.Visible = true; chart.Axis.X.LineThickness = 1; chart.Axis.X.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.X.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.X.MajorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.X.MajorGridLines.Visible = true; chart.Axis.X.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.X.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.X.MinorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.X.MinorGridLines.Visible = false; chart.Axis.X.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.X.Visible = true; chart.Axis.X2.Labels.Font = new Font("Verdana", 7F); chart.Axis.X2.Labels.FontColor = System.Drawing.Color.Gray; chart.Axis.X2.Labels.HorizontalAlign = StringAlignment.Far; chart.Axis.X2.Labels.ItemFormatString = "<ITEM_LABEL>"; chart.Axis.X2.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.X2.Labels.Orientation = TextOrientation.VerticalLeftFacing; chart.Axis.X2.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.X2.Labels.SeriesLabels.FontColor = System.Drawing.Color.Gray; chart.Axis.X2.Labels.SeriesLabels.FormatString = ""; chart.Axis.X2.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Far; chart.Axis.X2.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.X2.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing; chart.Axis.X2.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.X2.Labels.SeriesLabels.Visible = true; chart.Axis.X2.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.X2.Labels.Visible = false; chart.Axis.X2.LineThickness = 1; chart.Axis.X2.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.X2.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.X2.MajorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.X2.MajorGridLines.Visible = true; chart.Axis.X2.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.X2.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.X2.MinorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.X2.MinorGridLines.Visible = false; chart.Axis.X2.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.X2.Visible = false; chart.Axis.Y.Labels.Font = new Font("Verdana", 7F); chart.Axis.Y.Labels.FontColor = System.Drawing.Color.DimGray; chart.Axis.Y.Labels.HorizontalAlign = StringAlignment.Far; chart.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:00.##>"; chart.Axis.Y.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Y.Labels.Orientation = TextOrientation.Horizontal; chart.Axis.Y.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.Y.Labels.SeriesLabels.FontColor = System.Drawing.Color.DimGray; chart.Axis.Y.Labels.SeriesLabels.FormatString = ""; chart.Axis.Y.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Far; chart.Axis.Y.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Y.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; chart.Axis.Y.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.Y.Labels.SeriesLabels.Visible = true; chart.Axis.Y.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.Y.Labels.Visible = true; chart.Axis.Y.LineThickness = 1; chart.Axis.Y.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Y.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.Y.MajorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Y.MajorGridLines.Visible = true; chart.Axis.Y.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Y.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.Y.MinorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Y.MinorGridLines.Visible = false; chart.Axis.Y.TickmarkInterval = 10D; chart.Axis.Y.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.Y.Visible = true; chart.Axis.Y2.Labels.Font = new Font("Verdana", 7F); chart.Axis.Y2.Labels.FontColor = System.Drawing.Color.Gray; chart.Axis.Y2.Labels.HorizontalAlign = StringAlignment.Near; chart.Axis.Y2.Labels.ItemFormatString = "<DATA_VALUE:00.##>"; chart.Axis.Y2.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Y2.Labels.Orientation = TextOrientation.Horizontal; chart.Axis.Y2.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.Y2.Labels.SeriesLabels.FontColor = System.Drawing.Color.Gray; chart.Axis.Y2.Labels.SeriesLabels.FormatString = ""; chart.Axis.Y2.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; chart.Axis.Y2.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Y2.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; chart.Axis.Y2.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.Y2.Labels.SeriesLabels.Visible = true; chart.Axis.Y2.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.Y2.Labels.Visible = false; chart.Axis.Y2.LineThickness = 1; chart.Axis.Y2.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Y2.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.Y2.MajorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Y2.MajorGridLines.Visible = true; chart.Axis.Y2.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Y2.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.Y2.MinorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Y2.MinorGridLines.Visible = false; chart.Axis.Y2.TickmarkInterval = 10D; chart.Axis.Y2.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.Y2.Visible = false; chart.Axis.Z.Labels.Font = new Font("Verdana", 7F); chart.Axis.Z.Labels.FontColor = System.Drawing.Color.DimGray; chart.Axis.Z.Labels.HorizontalAlign = StringAlignment.Near; chart.Axis.Z.Labels.ItemFormatString = ""; chart.Axis.Z.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Z.Labels.Orientation = TextOrientation.Horizontal; chart.Axis.Z.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.Z.Labels.SeriesLabels.FontColor = System.Drawing.Color.DimGray; chart.Axis.Z.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; chart.Axis.Z.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Z.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; chart.Axis.Z.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.Z.Labels.SeriesLabels.Visible = true; chart.Axis.Z.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.Z.Labels.Visible = true; chart.Axis.Z.LineThickness = 1; chart.Axis.Z.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Z.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.Z.MajorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Z.MajorGridLines.Visible = true; chart.Axis.Z.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Z.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.Z.MinorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Z.MinorGridLines.Visible = false; chart.Axis.Z.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.Z.Visible = false; chart.Axis.Z2.Labels.Font = new Font("Verdana", 7F); chart.Axis.Z2.Labels.FontColor = System.Drawing.Color.Gray; chart.Axis.Z2.Labels.HorizontalAlign = StringAlignment.Near; chart.Axis.Z2.Labels.ItemFormatString = ""; chart.Axis.Z2.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Z2.Labels.Orientation = TextOrientation.Horizontal; chart.Axis.Z2.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.Z2.Labels.SeriesLabels.FontColor = System.Drawing.Color.Gray; chart.Axis.Z2.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; chart.Axis.Z2.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Z2.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; chart.Axis.Z2.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.Z2.Labels.SeriesLabels.Visible = true; chart.Axis.Z2.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.Z2.Labels.Visible = false; chart.Axis.Z2.LineThickness = 1; chart.Axis.Z2.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Z2.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.Z2.MajorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Z2.MajorGridLines.Visible = true; chart.Axis.Z2.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Z2.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.Z2.MinorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.Z2.MinorGridLines.Visible = false; chart.Axis.Z2.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.Z2.Visible = false; chart.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; chart.ColorModel.AlphaLevel = ((byte)(150)); chart.ColorModel.ColorBegin = System.Drawing.Color.Pink; chart.ColorModel.ColorEnd = System.Drawing.Color.DarkRed; chart.ColorModel.ModelStyle = ColorModels.CustomLinear; } catch { } return chart; }
Thanks for sending your source. I am currently working with it in a sample application and I intend to use it to answer your above questions in the context of your code.
Please let me know if you have any questions for me while I am working on this.
Yes, I had a few other questions:
1. The TitleTop and TitleBottom text areas are appearing "inside" the chart. What properties should I use to move the TitleTop slightly above the chart and TitleBottom slightly below it?
2. For the LineChart you can set the line type and thickness by using a LineAppearence object. How do I do this for lines in a composite chart?
3. In this particular chart, the data consists of results from several sources (i.e., several orders), and I need to identify the range of results corresponding to each order by having a legend string below the chart (i.e., the TitleBottom) which is formatted to show the breaks between the orders. You can see an example of what I mean in the original image I sent to you - for example: " 1234 | 5678 | 9012 "
I am doing this by defining the TitleBottom orientation as "Near", using a monospace font, computing the relative size of each range, assembling a string, and pre-pending a header string of spaces which corresponds to the distance between the left edge of the chart area and the vertical axis. Is this the only way, or is there a better way to do this?
I need answers to my issues VERY soon
I am currently working with the sample code to get it running in my environment. If you have a runnable sample project that you can send, it would allow me to get to a resolution much more quickly.
Do you have a specific deadline? Please let me know and I will do my best to help you meet it.
You currently have standard support, which guarantees a 3-day response time. If you need daily responses, please let me know and I will have a sales representative reach out to you to upgrade.
The code I sent you is part of a large internal app and an extensive database, so it wouldn't work to send it to you.
I was hoping that we could get this issue resolved by today.
I've made some more progress on the sample and I will need some more information from you. Please provide the InfragisticsChartHelper, ScreenHelper, and Enums classes. I'm also not sure how pnlGraphs is used, but I might be able to work around this.
To answer your questions:
1) I recommend using the Bounds on the ChartArea to move the chart's location or Height so that it does not clip the label. You might also be able to set the the Extent property on the titles, but I think Bounds will be easier to work with. You can set the MeasureType property on the ChartArea's Bounds to Percentage to make this even easier.
2) In a composite chart, appearances handled by layers. This is a ChartLayerAppearance object, and it has a ChartTypeAppearance property that you can set to your existing LineChartAppearance object.
3) You can avoid prepending spaces to your title by setting TitleBottom's Margins.Left property instead.
Please let me know if you have any further questions.
I will try you suggestions and let you know how things are working.
The additional app elements are below...
1. For the missing enums value just substitute a string
2. For the ScreenHelper method, substitute a MessageBox display.
3. You have virtually all of the chart helper class, but I have added all of the code below.
4. The pnlGraphs element is just a panel on the form in which the chart(s) will be placed.
5. For the NumberSeries objects just strip out the code that sets and works with the List controls, and create some dummy values
using System; using System.Drawing; using Infragistics.Win.UltraWinChart; using Infragistics.UltraChart.Core.Layers; using Infragistics.UltraChart.Shared.Styles; using Infragistics.UltraChart.Resources.Appearance; using MCPEntities; namespace MCPScreens { public sealed class InfragisticsChartHelper { #region Methods public static UltraChart CreateCompositeChart( out ChartLayerAppearance chartLayer, string title, float fontSize, int width = 400, int height = 300, int left = 0, int top = 0, bool xAxis = false) { UltraChart chart = null; chartLayer = null; try { chart = SetChartDefaults(ChartType.Composite, title); chart.TitleTop.Font = new Font(FontFamily.GenericSansSerif, fontSize, FontStyle.Regular); chart.TitleTop.HorizontalAlign = StringAlignment.Center; chart.TitleBottom.Font = new Font(FontFamily.GenericMonospace, fontSize - 4, FontStyle.Regular); chart.TitleBottom.HorizontalAlign = StringAlignment.Near; chart.TitleLeft.Visible = false; chart.TitleRight.Visible = false; chart.Location = new Point(left, top); chart.Size = new Size(width, height); ChartArea chartArea = new ChartArea(); chartArea.Key = "chartArea"; chartArea.GridPE = new PaintElement(); chartArea.PE = new PaintElement(); chart.CompositeChart.ChartAreas.Add(chartArea); AxisItem axisX = new AxisItem(); axisX.OrientationType = AxisNumber.Y_Axis; axisX.DataType = AxisDataType.Numeric; axisX.Key = "axisX"; axisX.Labels.FontColor = System.Drawing.Color.Empty; axisX.Labels.HorizontalAlign = StringAlignment.Near; axisX.Labels.ItemFormatString = "<DATA_VALUE:#,###.##>"; axisX.Labels.Orientation = TextOrientation.Horizontal; axisX.Labels.SeriesLabels.FontColor = System.Drawing.Color.Empty; axisX.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Center; axisX.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; axisX.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; axisX.Labels.SeriesLabels.Visible = true; axisX.Labels.VerticalAlign = StringAlignment.Center; axisX.Labels.Visible = true; axisX.MajorGridLines.AlphaLevel = ((byte)(255)); axisX.MajorGridLines.Color = System.Drawing.Color.Gainsboro; axisX.MajorGridLines.DrawStyle = LineDrawStyle.Dot; axisX.MajorGridLines.Visible = false; axisX.MinorGridLines.AlphaLevel = ((byte)(255)); axisX.MinorGridLines.Color = System.Drawing.Color.LightGray; axisX.MinorGridLines.DrawStyle = LineDrawStyle.Dot; axisX.MinorGridLines.Visible = false; axisX.SetLabelAxisType = SetLabelAxisType.GroupBySeries; chart.Axis.X.Labels.Visible = xAxis; chartArea.Axes.Add(axisX); AxisItem axisY = new AxisItem(); axisY.OrientationType = AxisNumber.Y_Axis; axisY.DataType = AxisDataType.Numeric; axisY.Key = "axisY"; axisY.Labels.FontColor = System.Drawing.Color.Empty; axisY.Labels.HorizontalAlign = StringAlignment.Near; axisY.Labels.ItemFormatString = "<DATA_VALUE:#,###.##>"; axisY.Labels.Orientation = TextOrientation.Horizontal; axisY.Labels.SeriesLabels.FontColor = System.Drawing.Color.Empty; axisY.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Center; axisY.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; axisY.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; axisY.Labels.SeriesLabels.Visible = true; axisY.Labels.VerticalAlign = StringAlignment.Center; axisY.Labels.Visible = true; axisY.MajorGridLines.AlphaLevel = ((byte)(255)); axisY.MajorGridLines.Color = System.Drawing.Color.Gainsboro; axisY.MajorGridLines.DrawStyle = LineDrawStyle.Dot; axisY.MajorGridLines.Visible = true; axisY.MinorGridLines.AlphaLevel = ((byte)(255)); axisY.MinorGridLines.Color = System.Drawing.Color.LightGray; axisY.MinorGridLines.DrawStyle = LineDrawStyle.Dot; axisY.MinorGridLines.Visible = false; axisY.SetLabelAxisType = SetLabelAxisType.GroupBySeries; chartArea.Axes.Add(axisY); chartLayer = new ChartLayerAppearance(); chartLayer.ChartType = ChartType.LineChart; chartLayer.Key = "chartLayer"; chartLayer.ChartArea = chartArea; chartLayer.ChartAreaKey = "chartArea"; chartLayer.AxisX = axisX; chartLayer.AxisXKey = "axisX"; chartLayer.AxisY = axisY; chartLayer.AxisYKey = "axisY"; chart.CompositeChart.ChartLayers.Add(chartLayer); } catch (Exception ex) { } return chart; } public static NumericSeries CreateCompositeLine( UltraChart chart, ChartLayerAppearance chartLayer, LineDrawStyle drawStyle, int thickness, System.Drawing.Color color) { NumericSeries series = null; try { series = new NumericSeries(); series.PEs.Add(new PaintElement(color)); series.Label = "Test"; chart.CompositeChart.Series.Add(series); chartLayer.Series.Add(series); LineAppearance line = new LineAppearance(); line.LineStyle.DrawStyle = drawStyle; line.Thickness = thickness; // How to add line appearance object? } catch (Exception ex) { } return series; } private static UltraChart SetChartDefaults(ChartType chartType, string title) { UltraChart chart = null; try { chart = new UltraChart(); chart.ChartType = chartType; chart.Name = title; chart.TitleTop.Text = title; chart.TitleTop.Orientation = TextOrientation.Horizontal; chart.TitleTop.HorizontalAlign = StringAlignment.Center; chart.TitleBottom.Orientation = TextOrientation.Horizontal; chart.TitleBottom.HorizontalAlign = StringAlignment.Center; PaintElement paintElement = new Infragistics.UltraChart.Resources.Appearance.PaintElement(); GradientEffect gradientEffect = new Infragistics.UltraChart.Resources.Appearance.GradientEffect(); chart.Axis.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(248)))), ((int)(((byte)(220))))); chart.Axis.X.Labels.Font = new Font("Verdana", 7F); chart.Axis.X.Labels.FontColor = System.Drawing.Color.DimGray; chart.Axis.X.Labels.HorizontalAlign = StringAlignment.Near; chart.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL>"; chart.Axis.X.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.X.Labels.Orientation = TextOrientation.VerticalLeftFacing; chart.Axis.X.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.X.Labels.SeriesLabels.FontColor = System.Drawing.Color.DimGray; chart.Axis.X.Labels.SeriesLabels.FormatString = ""; chart.Axis.X.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; chart.Axis.X.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.X.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing; chart.Axis.X.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.X.Labels.SeriesLabels.Visible = true; chart.Axis.X.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.X.Labels.Visible = true; chart.Axis.X.LineThickness = 1; chart.Axis.X.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.X.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.X.MajorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.X.MajorGridLines.Visible = true; chart.Axis.X.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.X.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.X.MinorGridLines.DrawStyle = LineDrawStyle.Dot; chart.Axis.X.MinorGridLines.Visible = false; chart.Axis.X.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.X.Visible = true; //chart.Axis.X2.Labels.Font = new Font("Verdana", 7F); //chart.Axis.X2.Labels.FontColor = System.Drawing.Color.Gray; //chart.Axis.X2.Labels.HorizontalAlign = StringAlignment.Far; //chart.Axis.X2.Labels.ItemFormatString = "<ITEM_LABEL>"; //chart.Axis.X2.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.X2.Labels.Orientation = TextOrientation.VerticalLeftFacing; //chart.Axis.X2.Labels.SeriesLabels.Font = new Font("Verdana", 7F); //chart.Axis.X2.Labels.SeriesLabels.FontColor = System.Drawing.Color.Gray; //chart.Axis.X2.Labels.SeriesLabels.FormatString = ""; //chart.Axis.X2.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Far; //chart.Axis.X2.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.X2.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing; //chart.Axis.X2.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; //chart.Axis.X2.Labels.SeriesLabels.Visible = true; //chart.Axis.X2.Labels.VerticalAlign = StringAlignment.Center; //chart.Axis.X2.Labels.Visible = false; //chart.Axis.X2.LineThickness = 1; //chart.Axis.X2.MajorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.X2.MajorGridLines.Color = System.Drawing.Color.Gainsboro; //chart.Axis.X2.MajorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.X2.MajorGridLines.Visible = true; //chart.Axis.X2.MinorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.X2.MinorGridLines.Color = System.Drawing.Color.LightGray; //chart.Axis.X2.MinorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.X2.MinorGridLines.Visible = false; //chart.Axis.X2.TickmarkStyle = AxisTickStyle.Smart; //chart.Axis.X2.Visible = false; chart.Axis.Y.Labels.Font = new Font("Verdana", 7F); chart.Axis.Y.Labels.FontColor = System.Drawing.Color.DimGray; chart.Axis.Y.Labels.HorizontalAlign = StringAlignment.Far; chart.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:#,###.##>"; chart.Axis.Y.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Y.Labels.Orientation = TextOrientation.Horizontal; chart.Axis.Y.Labels.SeriesLabels.Font = new Font("Verdana", 7F); chart.Axis.Y.Labels.SeriesLabels.FontColor = System.Drawing.Color.DimGray; chart.Axis.Y.Labels.SeriesLabels.FormatString = ""; chart.Axis.Y.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Far; chart.Axis.Y.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; chart.Axis.Y.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; chart.Axis.Y.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; chart.Axis.Y.Labels.SeriesLabels.Visible = true; chart.Axis.Y.Labels.VerticalAlign = StringAlignment.Center; chart.Axis.Y.Labels.Visible = true; chart.Axis.Y.LineThickness = 1; chart.Axis.Y.MajorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Y.MajorGridLines.Color = System.Drawing.Color.Gainsboro; chart.Axis.Y.MajorGridLines.DrawStyle = LineDrawStyle.Solid; chart.Axis.Y.MajorGridLines.Visible = false; chart.Axis.Y.MinorGridLines.AlphaLevel = ((byte)(255)); chart.Axis.Y.MinorGridLines.Color = System.Drawing.Color.LightGray; chart.Axis.Y.MinorGridLines.DrawStyle = LineDrawStyle.Solid; chart.Axis.Y.MinorGridLines.Visible = false; chart.Axis.Y.TickmarkInterval = 10D; chart.Axis.Y.TickmarkStyle = AxisTickStyle.Smart; chart.Axis.Y.Visible = true; //chart.Axis.Y2.Labels.Font = new Font("Verdana", 7F); //chart.Axis.Y2.Labels.FontColor = System.Drawing.Color.Gray; //chart.Axis.Y2.Labels.HorizontalAlign = StringAlignment.Near; //chart.Axis.Y2.Labels.ItemFormatString = "<DATA_VALUE:#,###.##>"; //chart.Axis.Y2.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.Y2.Labels.Orientation = TextOrientation.Horizontal; //chart.Axis.Y2.Labels.SeriesLabels.Font = new Font("Verdana", 7F); //chart.Axis.Y2.Labels.SeriesLabels.FontColor = System.Drawing.Color.Gray; //chart.Axis.Y2.Labels.SeriesLabels.FormatString = ""; //chart.Axis.Y2.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; //chart.Axis.Y2.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.Y2.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; //chart.Axis.Y2.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; //chart.Axis.Y2.Labels.SeriesLabels.Visible = true; //chart.Axis.Y2.Labels.VerticalAlign = StringAlignment.Center; //chart.Axis.Y2.Labels.Visible = false; //chart.Axis.Y2.LineThickness = 1; //chart.Axis.Y2.MajorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.Y2.MajorGridLines.Color = System.Drawing.Color.Gainsboro; //chart.Axis.Y2.MajorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.Y2.MajorGridLines.Visible = true; //chart.Axis.Y2.MinorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.Y2.MinorGridLines.Color = System.Drawing.Color.LightGray; //chart.Axis.Y2.MinorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.Y2.MinorGridLines.Visible = false; //chart.Axis.Y2.TickmarkInterval = 10D; //chart.Axis.Y2.TickmarkStyle = AxisTickStyle.Smart; //chart.Axis.Y2.Visible = false; //chart.Axis.Z.Labels.Font = new Font("Verdana", 7F); //chart.Axis.Z.Labels.FontColor = System.Drawing.Color.DimGray; //chart.Axis.Z.Labels.HorizontalAlign = StringAlignment.Near; //chart.Axis.Z.Labels.ItemFormatString = ""; //chart.Axis.Z.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.Z.Labels.Orientation = TextOrientation.Horizontal; //chart.Axis.Z.Labels.SeriesLabels.Font = new Font("Verdana", 7F); //chart.Axis.Z.Labels.SeriesLabels.FontColor = System.Drawing.Color.DimGray; //chart.Axis.Z.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; //chart.Axis.Z.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.Z.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; //chart.Axis.Z.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; //chart.Axis.Z.Labels.SeriesLabels.Visible = true; //chart.Axis.Z.Labels.VerticalAlign = StringAlignment.Center; //chart.Axis.Z.Labels.Visible = true; //chart.Axis.Z.LineThickness = 1; //chart.Axis.Z.MajorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.Z.MajorGridLines.Color = System.Drawing.Color.Gainsboro; //chart.Axis.Z.MajorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.Z.MajorGridLines.Visible = true; //chart.Axis.Z.MinorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.Z.MinorGridLines.Color = System.Drawing.Color.LightGray; //chart.Axis.Z.MinorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.Z.MinorGridLines.Visible = false; //chart.Axis.Z.TickmarkStyle = AxisTickStyle.Smart; //chart.Axis.Z.Visible = false; //chart.Axis.Z2.Labels.Font = new Font("Verdana", 7F); //chart.Axis.Z2.Labels.FontColor = System.Drawing.Color.Gray; //chart.Axis.Z2.Labels.HorizontalAlign = StringAlignment.Near; //chart.Axis.Z2.Labels.ItemFormatString = ""; //chart.Axis.Z2.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.Z2.Labels.Orientation = TextOrientation.Horizontal; //chart.Axis.Z2.Labels.SeriesLabels.Font = new Font("Verdana", 7F); //chart.Axis.Z2.Labels.SeriesLabels.FontColor = System.Drawing.Color.Gray; //chart.Axis.Z2.Labels.SeriesLabels.HorizontalAlign = StringAlignment.Near; //chart.Axis.Z2.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; //chart.Axis.Z2.Labels.SeriesLabels.Orientation = TextOrientation.Horizontal; //chart.Axis.Z2.Labels.SeriesLabels.VerticalAlign = StringAlignment.Center; //chart.Axis.Z2.Labels.SeriesLabels.Visible = true; //chart.Axis.Z2.Labels.VerticalAlign = StringAlignment.Center; //chart.Axis.Z2.Labels.Visible = false; //chart.Axis.Z2.LineThickness = 1; //chart.Axis.Z2.MajorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.Z2.MajorGridLines.Color = System.Drawing.Color.Gainsboro; //chart.Axis.Z2.MajorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.Z2.MajorGridLines.Visible = true; //chart.Axis.Z2.MinorGridLines.AlphaLevel = ((byte)(255)); //chart.Axis.Z2.MinorGridLines.Color = System.Drawing.Color.LightGray; //chart.Axis.Z2.MinorGridLines.DrawStyle = LineDrawStyle.Dot; //chart.Axis.Z2.MinorGridLines.Visible = false; //chart.Axis.Z2.TickmarkStyle = AxisTickStyle.Smart; //chart.Axis.Z2.Visible = false; chart.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; chart.ColorModel.AlphaLevel = ((byte)(150)); chart.ColorModel.ColorBegin = System.Drawing.Color.Pink; chart.ColorModel.ColorEnd = System.Drawing.Color.DarkRed; chart.ColorModel.ModelStyle = ColorModels.CustomLinear; } catch { } return chart; } #endregion } }