Visifire Forums: Pie and Bar Charts with Prism and MVVM Sample(Binding) - Visifire Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Pie and Bar Charts with Prism and MVVM Sample(Binding) Pie and Bar Charts with Prism and MVVM Sample(Binding)

#1 User is offline   Raya Sum Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 08-January 10

Posted 08 January 2010 - 07:32 PM

Hi,

I want to know if we have a sample to show visifire silverlight pie and bar chart to implement them in our Prism + MVVM applications. Do they support all the binding so as to avoid the code behind. I would appreciate if you can give us a sample on this. We are actually planning to purchase this but want to do evaluation if they support Prism with MVVM design pattern. Please let me know if you can help me on this. I was trying to implement but not sure where to set the ItemsSource, and Fields for X and Y axes.
I am struck here..
<vc:Chart Watermark="True" Width="500" Height="300" Theme="Theme1" LightingEnabled="False" View3D="True" BorderBrush="Gray" Bevel="False" BorderThickness="0.5">
<vc:Chart.Titles>
<vc:Title FontSize="16" Padding="10" Text="{Binding lblGraphTitle_AnnualEnergyCosts, Source={StaticResource WorkbenchLocalizedResources}}"/>
</vc:Chart.Titles>
<vc:Chart.AxesX>
<vc:Axis DataContext="{Binding lblGraphBaseline, Source={StaticResource WorkbenchLocalizedResources}}"/>
</vc:Chart.AxesX>
<vc:Chart.AxesY>
<vc:Axis DataContext ="{Binding Statistics.AnnualEnergyCost}"/>
</vc:Chart.AxesY>
<vc:Chart.Series>
<vc:DataSeries RenderAs="Pie" ColorSet="CandleLight" Legend="Legend1" LightingEnabled="True" LabelLineColor="Black" LabelFontFamily="Verdana" LabelText="#AxisXLabel, #YValue" ShowInLegend="False"
Bevel="True" LabelLineThickness="0.5" DataPoints="{Binding LightingWorkbenchController.SelectedUpgradeCategoryAsList}" >
<!--<vc:DataSeries.DataPoints>
<vc:DataPointCollection IndependentValueBinding="{Binding lblGraphBaseline, Source={StaticResource WorkbenchLocalizedResources}}"
DependentValueBinding="{Binding Statistics.AnnualEnergyCost}"
DataPointStyle="{StaticResource BaselineChartColumn}"></vc:DataPointCollection>-->
<!--<vc:DataPoint AxisXLabel="1280 X 800" YValue="15.27" />
<vc:DataPoint AxisXLabel="1024 X 768" YValue="43.58" />
<vc:DataPoint AxisXLabel="1280 X 1024" YValue="13.31" />
<vc:DataPoint AxisXLabel="800 X 600" YValue="6.55" />
<vc:DataPoint AxisXLabel="1440 X 900" YValue="5.96" />
<vc:DataPoint AxisXLabel="Other" YValue="15.47" />
</vc:DataSeries.DataPoints>-->
</vc:DataSeries>
</vc:Chart.Series>
</vc:Chart>

Any help would be greatly appreciated.
Thanks,
SumRaya
0

#2 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,447
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 09 January 2010 - 07:14 AM

Hi Raya,

Currently Visifire doesn't support DataBinding. It is in our high priority list.
Regards,
Vivek
Team Visifire
0

#3 User is offline   SilverlightBlue Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 42
  • Joined: 28-October 09

Posted 09 January 2010 - 12:11 PM

Hi Raya,

As all properties provided by Visifire are Dependency property so whenever a property is updated chart will be automatically updated. So, currently you can create your own class and bind the data values like below.

        public class MyChart: DependencyObject
        {
            public MyChart(Panel parentPanelOfChart, Double height, Double width)
            {
                chart.Height = height;
                chart.Width = width;
                AddChartToParent(parentPanelOfChart);
            }

            public static readonly DependencyProperty ItemsSource = DependencyProperty.Register
            ("ItemsSource",
            typeof(Object),
            typeof(MyChart),
            new PropertyMetadata(OnItemsSourcePropertyChanged));

            private static void OnItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                MyChart mychart = d as MyChart;

                // Update the chart just updating the no of DataPoints
                mychart.AddOrUpdateDataPoints((List<Double>)e.NewValue);
                
                // Update(Animate) the chart just updating YValue to actual value
                mychart.chart.Dispatcher.BeginInvoke(new Action<List<Double>>(mychart.BindData), new Object[] { (List<Double>)e.NewValue });
            }

            public void BindData(List<Double> values)
            {
                int i=0;
                foreach (Double value in values)
                {
                    chart.Series[0].DataPoints[i++].YValue = value;
                }
            }

            public void AddOrUpdateDataPoints(List<Double> values)
            {
                chart.Series.Clear();

                DataSeries ds = new DataSeries();

                foreach (Double value in values)
                {
                    /* Setting YValue as 0 inorder to animate the chart
                    just updating YValue to actual value later in binding function */
                    DataPoint dp = new DataPoint() { YValue = 0 };
                    ds.DataPoints.Add(dp);
                }

                chart.Series.Add(ds);
            }


            public void AddChartToParent(Panel parent)
            {
                parent.Children.Add(chart);
            }

            Chart chart = new Chart();
        }


:rolleyes: John
0

#4 User is offline   vivek Icon

  • Advanced Member
  • PipPipPip
  • Group: Team Visifire
  • Posts: 2,447
  • Joined: 19-March 08
  • Gender:Male
  • Location:Bangalore

Posted 24 February 2010 - 08:01 AM

Hi Raya,

Visifire now supports DataBinding. Please check the blog post here for more info.
Regards,
Vivek
Team Visifire
0

#5 User is offline   sweeppickerr Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 28-July 10

Posted 30 July 2010 - 12:16 AM

Finally, Visifire supports DataBinding. It solved my problem! :)
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users