arkano Posted August 13, 2013 Report Share Posted August 13, 2013 Hello, I am using the following example in order to fill a bar chart with data: string mySelectQuery = "SELECT * from SampleFinancial"; string myConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Samples.mdb;"; System.Data.OleDb.OleDbConnection myConnection = new System.Data.OleDb.OleDbConnection(myConnectionString); System.Data.DataSet ds = new System.Data.DataSet(); System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(mySelectQuery, myConnection); adapter.Fill(ds, "Financial"); chart1.DataSourceSettings.Fields.Add(new FieldMap("Date",FieldUsage.XValue)); chart1.DataSourceSettings.Fields.Add(new FieldMap("Closed",FieldUsage.Value)); chart1.DataSource = ds.Tables[0]; I want to set a custom label to every point. For example, I want to set the word "Hello" to every point in the chart. I am trying to do this by using the following code (I should do that for every point in my chart): chart1.Series[0].PointLabels.Visible = true; chart1.Series[0].PointLabels.Format = "%L"; chart1.Points[0, 1].Text = "Hello"; How should I iterate the points of every serie to achieve this behaviour? Is there any way to achieve that using the FieldUsage? Thanks. Quote Link to comment Share on other sites More sharing options...
AndreG Posted August 13, 2013 Report Share Posted August 13, 2013 Take a look at the BubbleCharts sample that ships with the product, it does something like that. At first it sets the field usage for the field that holds the text as Label. Then it reads all the labels and sets in an array of strings. Finally it uses chart1_GetPointLabel to read from the array of strings into the Text property of the point. Quote Link to comment Share on other sites More sharing options...
arkano Posted August 13, 2013 Author Report Share Posted August 13, 2013 Hello: I'm trying to atach to the event chart1_GetPointLabel, but I can't. I wrote the following lines in the InitializeComponent method in the proyect BordersandBackgrounds in the Proyects Samples. chart1.AllSeries.PointLabels.Visible = true; chart1.GetPointLabel += new ChartFX.WinForms.PointLabelEventHandler(chart1_GetPointLabel); I put a breakpoint in the event and it never stops there, the event never executes. Do I have to do anything else so the event is fired? Quote Link to comment Share on other sites More sharing options...
AndreG Posted August 13, 2013 Report Share Posted August 13, 2013 Try this: chart1.AxisY.Notify = true; Quote Link to comment Share on other sites More sharing options...
arkano Posted August 14, 2013 Author Report Share Posted August 14, 2013 Hello: The solution works fine. I am now having some problems when the serie is in other pane, like in the proyect Panes in the Proyects Samples. The event is not being fired for this serie, it only works for the serie in the main pane but not in other pane. Is there any solution to this problem? Thanks. Quote Link to comment Share on other sites More sharing options...
AndreG Posted August 14, 2013 Report Share Posted August 14, 2013 Different pane means different Axis. Set that axis' notify property to true chart1.AxesY[index].Notify = true; Quote Link to comment Share on other sites More sharing options...
arkano Posted August 14, 2013 Author Report Share Posted August 14, 2013 I have the following code: ChartFX.WinForms.Pane pane1 = new ChartFX.WinForms.Pane(); chart1.Panes.Add(pane1); AxisY axisy = new AxisY(); chart1.AxesY.Add(axisy); chart1.Series[1].AxisY = axisy; chart1.Series[0].Pane = chart1.Panes[0]; chart1.Series[1].Pane = chart1.Panes[1]; chart1.AllSeries.PointLabels.Visible = true; chart1.GetPointLabel += new PointLabelEventHandler(chart1_GetPointLabel); for (int i = 0; i < chart1.AxesY.Count; i++) { chart1.AxesY.Notify = true; } And the event: int cant = 0; void chart1_GetPointLabel(object sender, PointLabelEventArgs e) { e.Text = "serie: " + e.Series + " " + cant; cant++; } The event is still only fired for only one serie. Is there any solution? Quote Link to comment Share on other sites More sharing options...
AndreG Posted August 14, 2013 Report Share Posted August 14, 2013 It's a timing issue. You have added a pane to the collection, but the axis associated with it will only be added to the collection of axes later (if at all, not sure). Try this: pane1.AxisY.Notify = true; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.