Silverlight Chart Question
I haven't enough rep points to post an image yet but given a Silverlight 4 chart example using ColumnSeries, how can I make each of the sub columns within a single column that are currently stacked up on top of each other sit side by side?
e.g Column NVQ2 shows value columns for 5 different locations, Column NVQ3 shows value columns for 5 different locations
I need the locations to sit side by side and not be stacked on top of each other.
Code for the graph:
foreach (ER_Location theLocation in UserSelections.TheDataSet.ER_Locations)
{
ER_Year myYear = (ER_Year)SeriesSelection.SelectedItem;
ColumnSeries newSeries = new ColumnSeries();
newSeries.ItemsSource = UserSelections.GetDataRowsByYearAndLocation(theLocation.Location_ID, (int)myYear.Year);
newSeries.IndependentValueBinding = new System.Windows.Data.Binding("Variable_ID");
newSeries.DependentValueBinding = new System.Windows.Data.Binding("Value");
newSeries.Title = theLocation.Name;
newSeries.IsSelectionEnabled = true;
开发者_如何转开发MainChart.Series.Add(newSeries);
}
Update:
This is how the chart is rendering at present:
My guess is your code has the following using
statement:-
using System.Windows.Controls.DataVisualization.Charting.Compatible
There are actually two different types with the name ColumnSeries
. One is in the above namespace and it derives from StackedColumnSeries
.
However the original non-stacked ColumnSeries
exists in the main Charting namespace. This type will place each column side-by-side. Hence I suspect all you need to do is eliminate the extra .Compatible
from your using
:-
using System.Windows.Controls.DataVisualization.Charting;
You will have to create a class with the color property.
Example,
public class MyColor
{
public Brush ChartColor { get; set; }
}
then create a list of your favorite colors like
List<MyColor> colorList = new List<MyColor>
{
new MyColor
{ ChartColor = new SolidColorBrush(Colors.Blue)},
new MyColor
{ ChartColor = new SolidColorBrush(Colors.Green) },
...
...
}
From Xaml, bind the background color of the datapoint to ChartColor
精彩评论