Hi i have list<class> which contains data for each product by yearly basis, i want show this list data in a bar chart by each product by year.
please check attachment to get better idea about my requirement.
Thanks
Hi Ramesh,
1. The NumericDataPoint constructor accepts a double as the value. If the type of the property is decimal cast it to double:
if (propertyInfo.PropertyType == typeof(decimal) || propertyInfo.PropertyType == typeof(decimal?))
Series.Points.Add(new NumericDataPoint(decimal.ToDouble((decimal)propertyInfo.GetValue(item)), item.ProductName, false));
2. No, there is no automatic way to size the legend. You will need to calculate the legend size based on the the number of items you have.
3. Yes, the bounds property is the correct way to set the location and size of the legend when you are using CompositeChart. The Legend.Location property has effect only when you aren’t using CompositeChart.
Let me know if you have any additional questions.
Hi Dimitar,
Thanks for you reply with clarification.
i am managed to solve some of the things by referring your code but few points still facing problem to solve.
1. below code is throwing error , in my case it's <Data> class property year data types are decimal.
Series.Points.Add(new NumericDataPoint((int)propertyInfo.GetValue(item), item.ProductName, false));
i tried to convert decimal , it's throwing error. Can NumericDataPoint accept decimal datatype/ or i need to convert to double
Series.Points.Add(new NumericDataPoint((decimal)propertyInfo.GetValue(item), item.ProductName, false));
public decimal? Year1 { get; set; } public decimal? Year2 { get; set; }
2. As i mentioned earlier, if there are more products then products are overlapping the legand box, is it possible to set automatic so that based on products legand box will increase automatically , display all the products left to write then come to next line if more products.
3. Legand location is not working. i tried to set left position
this.ultraChart2.Legend.Location = LegendLocation.Left;
this problem i am facing in case of composite chart type.
it's displaying in left position if i am setting Legend.Bounds position manually , is it the correct method to set the legand position to left.
1. You need to set the RangeMin and RangeMax of the axis item to the desired values. You also need to set the RangeType property to Custom.
2. By setting the RangeMax to a higher value the title and the stack bar won’t overlap.
3. This can be configured from the Extent property of the Y axis item.
4. You can simply iterate the list and then add the points directly to the series. Databinding it like that works only with data tables.
5. These are the major and minor grid lines. Each axis item has a MajorGridLines and MinorGridLines properties which in turn have a Visible property, which can be set to false in order to hide the lines.
6. The chart shows the data you provide them. Unless you restructure your data to have properties for five years, instead of a property for each year, this isn’t possible.
I have attached a sample where modified, cleaned up and refactored your code in order to demonstrate these suggestions.
Hi Find the attached code.
Hi Team,
still i am waiting for your reply on this. i spent lots of time and somehow managed to generate chart but few minor things i am not able to find the solution.
also seems i have written some unnecessary code which is not required, if possible please have a look on code and try to remove unnecessary code.
please find the attachment and provide me the solution for below points as soon as possible. its really very urgent
1. how do set yaxis minimum and maximum value manually.
2. if stacked bar size is more then it's overlapping charttop text.
3. how to remove space from left..before y axis i can see some space.
4. if i set datasource as list<t> to the numeric series it's not working , refer the below code.
DataTable table
NumericSeries Series = new NumericSeries(); Series.Data.DataSource = table;// i want to set list<t> instead of datatable Series.Data.LabelColumn = "ProductName"; Series.Data.ValueColumn = ValueColumn;
5. how to clear chart backgroud lines.
6. how to show 5 years one label like 2016-2020 for 5 years.