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?
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 primary issue is the data in the image does not make sense. The image that you are showing have multiple different datapoints for the same Category. That said, if you supply a simple working sample that demonstrates just the issue that you are having problems with, we can generally identify the issue fairly quickly, and often give you a solution or at least a workaround fairly quickly. The more we need to try to customize a sample including some code that you supply, but doesn't itself fully represent your issue, means we need to try to fill in those gaps, and sometimes we just cannot reasonably do that without better input from you. If you could please either modify the sample that was sent previously so that it includes sample data and then verify that this sample does represent your issue, or create a new standalone sample that does and attach it to thread, it would greatly aid us in helping you,
Sincerely,
I have modified the sample app, cut it down to the essentials, and attached it here for you.
OK, looking through your code, I noticed a few things. First, you will want to set the chartArea.Bounds if you want your title's to show up outside of your chart. Something like:
private const int TitleSizeAllotment = 30;...chartArea.Bounds = new Rectangle(0, TitleSizeAllotment, width, height - TitleSizeAllotment * 2);
Second, line charts are X,Y plotted charts. Y being a numeric, and the X being either a string category which would be a NumericSeries, or a datetime value which would be represented as a NumericTimeSeries. You can reference the ChartType requirements here:http://help.infragistics.com/doc/WinForms/2016.1/CLR4.0/?page=Chart_Axis_Requirements_for_Composite_Charts.html
As you are creating NumericSeries, you need to have your axis correspond with the series. Even though your Labels are blank the Axis.DataType it is expecting is a String axis.axisX.DataType = AxisDataType.String;Additionally your line:axisX.OrientationType = AxisNumber.Y_Axis; // needs to be changed to X_Axis. And LineCharts only support a SetLabelAxisType of Continous, so your line:axisX.SetLabelAxisType = SetLabelAxisType.GroupBySeries; // needs to be changed to ContinousDataAlso based on your NumericSeries type, your AxisX should have a different ItemFormatString, I would recommend "<ITEM_LABEL>".
For your Y Axis, you may want to define bounds something like: axisY.RangeType = AxisRangeType.Custom; axisY.RangeMax = 20; axisY.RangeMin = -10;
I was earlier mistaken about the multiple datapoints per category. You can kind of achieve this by just using the same label for each. But I do not believe it will group the labels but will instead repeat them. You may need to add a dummy axis for labelling or just paint into the axis instead.
Lastly to pass your line appearances on to your line chart you would first want to create your chartLayers ChartTypeAppearancechartLayer.ChartTypeAppearance = new LineChartAppearance();
You can then pass in your LineAppearances like:((LineChartAppearance)chartLayer.ChartTypeAppearance).LineAppearances.Add(line);
To match them up you need to have matching Key's so for your CreateCompositeLine method, I would pass in a key and assign the same key to your Series, Series and LineAppearance, and probably your Series.Label.
Let me know if that helps,
I am in the process of implementing these changes. Several questions:
1. I will apparently need to create a unique ChartLayerAppearance object for each NumericSeries, correct?
2. Should I define a "default" ChartLayerAppearance object which contains default axes, or should I only define ChartLayerAppearance objects for each NumericSeries?
3. Do I need to have a unique set of axes for each ChartLayerAppearance and NumericSeries? Both X and Y?
4. What key strings should be specified for the axes?
5. In regard to the "key" you mentioned, I use the same string for the ChartLayerAppearance key, NumericSeries key, and NumericSeries label, correct?
Most of these seem to relate, in that it is understanding how each part relates.
The Composite chart is a series of Layers, each Layer is essentially another chart that can be placed on top of each other. So far in your scenario you are primarily just doing a LineChart, which in and of itself you would not need a composite chart to do. But depending on what else you are combining with it, you may want to keep it as composite.
As such the ChartLayer corresponds with a full LineChart which can have multiple NumericSeries, each series represented by a line. So no not a new ChartLayerAppearance per NumericSeries, just one per Layer. The Layer will be defined as a LineChartLayer hence: chartLayer.ChartTypeAppearance = new LineChartAppearance();
Each Series equates to a LineAppearance object, and you can add multiple LineAppearances to one LineChartAppearance.((LineChartAppearance)chartLayer.ChartTypeAppearance).LineAppearances.Add(line);For #3, Axes are assigned on the ChartLayer, and multiple ChartLayers can and often do, but are not required to re-use the same axis. That said, again as the axes are assigned on the Layer, and the Layer is effectively a LineChart, and a LineChart can have multiple NumericSeries. You can add all your NumericSeries to the same Layer and use the same Axes. You could if you wanted to add a new layer for each series, and each layer can have it's own Axes, but that is highly unnecessary, and likely would not get the outcome that you want.
For your scenario I don't think you need to use the keys for the Axes.
You want to use the key's to link your NumericSeries to the LineAppearance's. The NumericSeries Label is just that, it is the Label that will be rendered to the screen. But the Key's are used for aligning the Appearances to the Series.
Things are looking a lot better - we are almost there.
The lines now display correctly with the correct colors and thicknesses. My only remaining issue is how I can compress the vertical space between the bottom of the chart and the bottom title line.
I have attached an undated version of the sample project, and an image of the resulting graph.
I have moved the code into our actual app, and in playing with it I have run across another issue (see the attached graphic)
I want the top and bottom cyan lines to be dotted or dashed, but regardless which LineDrawStyle I use, the lines always appear as solid. Why?
Another question: How can I add vertical lines to a composite chart?