Hi,
When I use one numeric column in a line chart, the chart displays a horizontal line over the chart. When I try to do the same in a stacked line chart, nothing happens.
Apparently when I add another numeric column to the DataSource with the same values as the first numeric column, I get the result I want. But I don't want to do this because of two reasons:It means I should 'hack' my code with a fake column and more importantly, the description on the X-axis does not make sense anymore (a label on each side of the chart instead of one in the center).
In the documentation I found "Note that it is recommended that the data set contains two or more numeric columns so that each line can have two or more points.". So it says recommended, but not mandatory.
Can someone help me to get horizintal lines with one numeric data column in a stacked line chart? Thanks in advance.
I am using version 10.3.20103.1000.
Hello TorX,
I`ll try to explain why it is not possible to have stacked line chart using only one numeric data column. Let`s take a look at the table in our online documentation. Each row in the table (IBM, MSN, MCI ….) represent a line in your chart. Each numeric column (Monday, Tuesday… ) represent point for relevant line. So if we want to draw just one line (for example IBM series) we need one row in the table and two numeric columns (for example Monday and Tuesday – the line will be between these two points).
In our scenario we need to have stacked lines, so we need to add by one row in the table for each line in the chart. If we want to have more complicated lines (with more points), we need to have additional numeric columns (for example Wednesday, Thursday …)
If we are using the property myColumnLayer.SwapRowsAndColumns = true; we only swap the rows with columns. It means that each line will be represent by column and each point for relevant line will be represent by row in the table.
In both scenarios we need to have two or more rows and two or more columns to be able to draw stacked line chart.
Please let me know if you have any questions.
Regards
StockName
Monday
Tuesday
Wednesday
Thursday
Friday
IBM
111
96
85
125
65
MSN
75
23
15
100
MCI
55
63
84
95
80
ATT
12
40
60
50
VER
69
110
98
123
Thanks for the reply, but I don't really see the explanation of why it's not possible. I already understand how the stacked line chart works, and how I should feed the data. For example, I have this in my datasource:
When I feed this to a normal line chart, I get 4 horizontal lines. But when I feed this to a stacked line chart, nothing happens. I would expect to get 4 horizontal lines with a y-value of: 5, 15, 30 and 50 (the cumulative scores).
Maybe if you can explain why I do get horizintal lines in a normal linechart, and not in a stacked line chart, I might understand.
On a sidenote, my employer later told me he wanted the stacked lines filled with a color underneath, so I went on to use a stacked area chart instead. However, the same problem occurs there too.
Hello TorX
TorX said: On a sidenote, my employer later told me he wanted the stacked lines filled with a color underneath, so I went on to use a stacked area chart instead. However, the same problem occurs there too.
DataTable dt = new DataTable(); dt.Columns.Add("Item", typeof(string)); dt.Columns.Add("Values", typeof(decimal)); dt.Rows.Add("Category 1", 10); dt.Rows.Add("Category 2", 20); dt.Rows.Add("Category 3", 30); dt.Rows.Add("Category 4", 20); dt.Rows.Add("Category 5", 15); ultraChart1.DataSource = dt;
DataTable dt = new DataTable();
dt.Columns.Add("Item", typeof(string));
dt.Columns.Add("Values", typeof(decimal));
dt.Rows.Add("Category 1", 10);
dt.Rows.Add("Category 2", 20);
dt.Rows.Add("Category 3", 30);
dt.Rows.Add("Category 4", 20);
dt.Rows.Add("Category 5", 15);
ultraChart1.DataSource = dt;
and the result will be :
Please take a look at the attached sample for more details. Please let me know if you have any questions.
Nice workaround, thanks! However... the chart I'm working on has a variable number of points on the x-axis. The user can decide how much he wants to see. So if he chooses 5 points, the stacked line/area chart works as expected. But if he chooses 1, the mentioned problem occurs. I was thinking that maybe I could switch chart types depending on the amount of points being 1 or more. I don't think that's a good solution, but I've tried it out with your sample project and attached it as example (I changed the references to an older version though).Still, I'm wondering why the line chart does work for 1 numeric column, but not for the stacked line/area chart. Could you or a colleague verify if this is a bug or something? And if so, will it be fixed?
TorX said: Still, I'm wondering why the line chart does work for 1 numeric column, but not for the stacked line/area chart. Could you or a colleague verify if this is a bug or something? And if so, will it be fixed?
Still, I'm wondering why the line chart does work for 1 numeric column, but not for the stacked line/area chart. Could you or a colleague verify if this is a bug or something? And if so, will it be fixed?
Right, I don't know why I am being ignored here. It's a shame (imho) that no one cares to answer the above mentioned question...
Seriously? 4 months and still no response???
Could you please take a look at the following link to our documentation:
http://help.infragistics.com/NetAdvantage/WinForms/2011.2/CLR2.0/?page=Chart_Working_with_2D_Line_Chart_Data.html
and especially at "it is important that you are supplying the appropriate amount and type of data that the chart requires" and "Note that it is recommended that the data set contains two or more numeric columns" and "emphasizes the amount of change over a period of time or compares multiple items" - a period of time means that you have a starting point in time and an ending point so basically this means that you would have to create two columns at least.
Please feel free to let me know if I misunderstood you or if you have any other questions.
I created the following case for you: 'CAS-88750-XGQYJX' and I will update you on that matter through it.
Hi Boris,
No that doesn't work. When I set Data.SwapRowsAndColumns = true on chart 2, I get a chart with 1 (filled) line at an angle. When I also transpose the DataSource, the original problem occurs again (no lines visible). When I add a row (to the transposed DataSource) with the same values as the first row, the correct chart appears. However, that is the same workaround as adding another column when Data.SwapRowsAndColumns = false, as seen in my sample project.
It's not a question of "how can I get horizontal lines on a stacked line chart with one column", because I already use the workaround suggested by Georgi. It's "why does the line chart behave differently from the stacked line chart with the same datasource"? They really should behave the same.
Thanks again for your time.
Could you please try to set: Data.SwapRowsAndColumns = true; and see if it helps.
Please do not hesitate to contact us if you need any additional assistance.
I have contacted our engineering staff about your enquiry and will provide you an answer soon.
Thank you for using our controls and components.
Hello Boris,
Have you been able to investigate my example?