Showing posts with label DataVisualization. Show all posts
Showing posts with label DataVisualization. Show all posts

Wednesday, June 6, 2012

Stacked100ColumnSeries at run time

If you want to add SeriesDefenition of a Stacked100ColumnSeries its bit tricky. You can do it by writing code like the one I have written.

  private void GetSeries(IEnumerable enumrable, Stacked100ColumnSeries series)
        {
            var k = enumrable as ObservableCollection;
            var parsedData = CustIncomeGraph.ParseDataForStackGraph(k);
            //var series = new ObservableCollection();
            int i = 0;
            series.SeriesDefinitions.Clear();
            CustIncomeGraph.GetDistinctTraderName(k).ForEach(s =>
                {
                    SeriesDefinition def = new SeriesDefinition();
                    def.Title = s;
                    def.IndependentValuePath = "TimeFrame";
                    var binding1 = new Binding("TradersIncome");
                    binding1.Converter = new IncomeGraphConverter();
                    binding1.ConverterParameter = s;
                    def.DependentValueBinding = binding1;
                    def.ItemsSource = parsedData;
                    series.SeriesDefinitions.Add(def);
                    i++;
                });

            //return series;
        }

where CustIncomeGraph is an entity it could be any class as per your requirement.


 public class IncomeGraphConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return 0;
            var param = System.Convert.ToString(parameter);
            var val = value as Dictionary;
            return val.ContainsKey(param) ? val[param] : 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

This works for me. Comments and questions will be highly appreciated.

Regards
Vinod

Sunday, June 3, 2012

Pivot Viewer using Silverlight

You can create your own pivotViewer with all the customization. What you need is to generate CXML from your data and pass it to pivotcontrol. It will generate a wonderful chart for you. Once you are done with this thing you will face some issue while deploying on server. Becoz normally IIS doesn't allow CXML request so you need to allow .cxml in MIME type of IIS. If you have any question regarding pivotViewer control write to me.

Regards
Vinod