Jump to content
Software FX Community

Custom point label using database


Recommended Posts


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?



Link to comment
Share on other sites

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.

Link to comment
Share on other sites


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?

Link to comment
Share on other sites


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?


Link to comment
Share on other sites

I have the following code:

  ChartFX.WinForms.Pane pane1 = new ChartFX.WinForms.Pane();


            AxisY axisy = new 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;



 The event is still only fired for only one serie. Is there any solution?


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...