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
Page 1 of 1
Pie and Bar Charts with Prism and MVVM Sample(Binding) Pie and Bar Charts with Prism and MVVM Sample(Binding)
#3
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.
John
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();
}
Page 1 of 1


Sign In
Register
Help

MultiQuote