Hi,
We are trying to display data for a particular DataPoint which triggered a mouse event in a label but we are not having too much luck with it as we keep getting the entire BarSeries, not the actual DataPoint, passed into the event.
Here is a recap of what we are trying to achieve:
- a Stacked BarChart has two bar series ("Events" and "NonEvents" in the example) which are populated through a binding.
- there are three categories displayed: "G1", "G2" and "G3".
- on mouse over event of "G3" bar we would like to display text "G3" on a label which is not a part of the chart.
Any ideas on this?
Best regards,
Tanja Risovic
Code:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var dataModel = new List<ViewDataModel>();
var dataModel1 = new ViewDataModel();
dataModel1.Events = 151;
dataModel1.NonEvents = 24;
dataModel1.GroupID = "1";
dataModel1.GroupLabel = "G1";
dataModel.Add(dataModel1);
var dataModel2 = new ViewDataModel();
dataModel2.Events = 4132;
dataModel2.NonEvents = 529;
dataModel2.GroupID = "2";
dataModel2.GroupLabel = "G2";
dataModel.Add(dataModel2);
var dataModel3 = new ViewDataModel();
dataModel3.Events = 1832;
dataModel3.NonEvents = 109;
dataModel3.GroupID = "3";
dataModel3.GroupLabel = "G3";
dataModel.Add(dataModel3);
BarChartPercentage.DataContext = dataModel;
}
private void BarSeries_MouseEnter(object sender, MouseEventArgs e)
{
this.label.Content = ???; //We would like to show the GroupLabel of the DataPoint which triggered the mouse event, for example "G3"
}
}
We are trying to display data for a particular DataPoint which triggered a mouse event in a label but we are not having too much luck with it as we keep getting the entire BarSeries, not the actual DataPoint, passed into the event.
Here is a recap of what we are trying to achieve:
- a Stacked BarChart has two bar series ("Events" and "NonEvents" in the example) which are populated through a binding.
- there are three categories displayed: "G1", "G2" and "G3".
- on mouse over event of "G3" bar we would like to display text "G3" on a label which is not a part of the chart.
Any ideas on this?
Best regards,
Tanja Risovic
Code:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var dataModel = new List<ViewDataModel>();
var dataModel1 = new ViewDataModel();
dataModel1.Events = 151;
dataModel1.NonEvents = 24;
dataModel1.GroupID = "1";
dataModel1.GroupLabel = "G1";
dataModel.Add(dataModel1);
var dataModel2 = new ViewDataModel();
dataModel2.Events = 4132;
dataModel2.NonEvents = 529;
dataModel2.GroupID = "2";
dataModel2.GroupLabel = "G2";
dataModel.Add(dataModel2);
var dataModel3 = new ViewDataModel();
dataModel3.Events = 1832;
dataModel3.NonEvents = 109;
dataModel3.GroupID = "3";
dataModel3.GroupLabel = "G3";
dataModel.Add(dataModel3);
BarChartPercentage.DataContext = dataModel;
}
private void BarSeries_MouseEnter(object sender, MouseEventArgs e)
{
this.label.Content = ???; //We would like to show the GroupLabel of the DataPoint which triggered the mouse event, for example "G3"
}
}