jhopper28 Posted February 12, 2010 Report Share Posted February 12, 2010 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 Quote Link to comment Share on other sites More sharing options...
CarlosAC Posted February 12, 2010 Report Share Posted February 12, 2010 Hi Jeff Unfortuantely, you cannot bind the column in the data source with the point labels. This is a limitation in Chart FX. As you mentioned, you have to manually iterate into your data source and set the point labels. -- Pipon Quote Link to comment Share on other sites More sharing options...
jhopper28 Posted February 12, 2010 Author Report Share Posted February 12, 2010 OK, so after the data is bound, how do I identify the Point for a given DataRow while I'm iterating? Quote Link to comment Share on other sites More sharing options...
jhopper28 Posted February 15, 2010 Author Report Share Posted February 15, 2010 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 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.