Jump to content
Software FX Community

Showing labels next to points on a Scatter chart


User (Legacy)

Recommended Posts

Posted

Hi

I'm evaluating ChartFX in VisualStudio.NET 2005 (Visual Basic.NET).

I am trying to plot an XY scatter chart with a label next to each of the

(x,y) points.

I don't know how to "attach" and then show the labels.

Below is the code I have been using.

The Chart shows the Y values next to each point. I don't want that. I want

the name/label of the point to show.

I've attached the datatable I'm using (in XML) as well as the sort of

picture I'm looking for (produced using a different charting tool).

(I've tried doing something similar to what you did in your Bubbles example

where you use the GetPointLabel event, but my event never fires!)

That's part 1.

Part 2 is that once I've got the data labels showing I want my users to be

able to drag and move the labels (and not the data points themselves).

I am aware of your Chart.AllowDrag property (and I think it is wonderful).

I want something similar for the labels. Ideally each label should have a

line joining the label to the point, and that line should move when the

label is dragged so that the line always connects the data point and it's

label.

Kind regards

Reg Bust

Private Sub XYPlotWithLabelsNextToEachPoint()

With Me.chart

.AllSeries.Gallery = ChartFX.WinForms.Gallery.Scatter

.AllSeries.PointLabels.Visible = True

End With

'DrawSeries

Call DrawSeries(0, "C:\Code\Net\I-Maps User\PointsSecurity.xml")

End Sub

Private Sub DrawSeries(ByVal s As Integer, ByVal FileName As String)

Dim ds As New DataSet

Dim dt As New DataTable

Dim dr As DataRow

Dim i As Integer

ds.ReadXml(FileName, XmlReadMode.ReadSchema)

dt = ds.Tables(0)

With Me.chart.Data

For Each dr In dt.Rows

.X(s, i) = Convert.ToSingle(dr("Dim1")) * 100

.Y(s, i) = Convert.ToSingle(dr("Dim2")) * 100

chart.Points(s, i).Text = Convert.ToString(dr("Point"))

i += 1

Next

End With

End Sub

Dr Reg Bust

imaps@iafrica.com

Tel: (021) 794-3263

Fax: 086 671 8411

Posted

> I am trying to plot an XY scatter chart with a label next to each of the 

> (x,y) points.

Use:

chart.AllSeries.PointLabels.Format = "%L";

> Part 2 is that once I´ve got the data labels showing I want my users to be

> able to drag and move the labels (and not the data points themselves). ...

What you can do is to create annotation objects for each of those labels

(instead of displaying them as point labels). Annotation objects can be

attached to a logical X/Y coordinate (such as the X/Y of each point) and you

can enable selection and movement on them. You can also create lines to

connect to the point. With this you will get exactly what you want but it

will require a little bit of work.

Are you aware of the PointLabelOrganizer property

(chart.AllSeries.LabelOrganizer) ? This feature automatically avoids

collisions of point labels. Is this was your original intention, this

solution will be ideal for you as it is much simpler to implement.

--

Francisco Padron

www.chartfx.com

Attachments.zip

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...