Jump to content
Software FX Community

How to bind a descriptive text data field to the point label values in a scatter chart?


jhopper28
 Share

Recommended Posts

I've got a scatter chart bound to a DataTable with 3 columns: a cost value (X axis), a numeric count value (Y axis), and a descriptive text value for each point. I want to keep the default X and Y axis labels (currency for X, numeric for Y), but display the description field as each point's label in the scatter chart. I've tried many combinations of using PointLabels, DataSourceSettings and FieldMap properties, but I can't figure out an obvious way to do this. Is there a way to bind that 3rd field to just the point labels, or do I need to iterate over all the points and assign the text value manually to each point's label? I would appreciate any sample code for either method.

Thanks,

Jeff



Here is my code attempt (the numeric values are laid out as desired with this code

Link to comment
Share on other sites

I expected to be able to enumerate (For Each) the points on the chart and set their properties, but nothing in the ChartFX API seems to implement IEnumerable. After some trial-and-error, here's what I got working by looping through the data-bound points by index and doing reverse look-ups in my data source:

For nPointIndex = 0 To MyChart.Data.Points - 1

Dim point As ChartFX.WinForms.PointAttributes = MyChart.Points(nPointIndex)

Dim cost As Double = MyChart.Data.X(nPointIndex)

Dim itemCount As Integer = CInt(MyChart.Data.Y(nPointIndex))

Dim foundRowIndex = dataView.Find(New Object() {cost, itemCount})

Dim row As DataRowView

If foundRowIndex >= 0 Then

row = dataView(foundRowIndex)

point.Text = row("description").ToString()

End If

Next

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.

Guest
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.

 Share

×
×
  • Create New...