none
Using CalloutLineAnchorCapStyle to display arrows on chart RRS feed

  • Question

  • I'm trying to put code in my program that makes a line on my chart appear with arrows on the ends. I thought I figured it out but the two things I'm trying aren't working. Here's the piece of my code with the two things I tried:

    First:

    Dim x6 As Double = x2 * 3 / 4

    Chart1.Series.Add("Series7")

    With Chart1.Series("Series7")

        .ChartType = DataVisualization.Charting.SeriesChartType.Line

        .Points.Add()

        .Points.Add()

        .Points.Item(0).XValue = x6

        .Points.Item(0).YValues = {y2}

        .Points.Item(1).XValue = .Points.Item(0).XValue

        .Points.Item(1).YValues = {0}

        'this is what I tried for adding the arrows

        .SmartLabelStyle.CalloutLineAnchorCapStyle = Drawing2D.LineCap.ArrowAnchor

        .BorderWidth = 1

        .Color = Color.Black

    End With

    Second:

    Dim x6 As Double = x2 * 3 / 4

    Chart1.Series.Add("Series7")

    With Chart1.Series("Series7")

        .ChartType = DataVisualization.Charting.SeriesChartType.Line

        .Points.Add()

        .Points.Add()

        .Points.Item(0).XValue = x6

        .Points.Item(0).YValues = {y2}

        .Points.Item(1).XValue = .Points.Item(0).XValue

        .Points.Item(1).YValues = {0}

        'this is what I tried for adding the arrows

        .SmartLabelStyle.CalloutLineAnchorCapStyle = DataVisualization.Charting.LineAnchorCapStyle.Arrow

        .BorderWidth = 1

        .Color = Color.Black

    End With

    Neither option changes the line. It's still just a straight black line with no end caps. Can anyone tell me why this isn't working?

    Thank you!

    Tuesday, July 11, 2017 6:58 PM

Answers

  • It won't allow me to post pictures or links yet. I'll try to describe it better.

    The code already creates the line on the chart. So I think the answer to "Use the chart series line and get arrow points?" is yes.

    Currently my chart has a solid line on it (a chart series line) which is also created by the posted code. I just want to change the display of that solid line to a line with arrows on the ends.

    I'll look up smart label again. I'm fairly new, so there's a good chance I'm just not using it right.

    I see. Hmmm. Not sure there is an easy way to put arrows on the series line. You can use markerstyle but not like arrows that align to the series line. This code makes a triangle at each point in the series:

     Chart1.Series(chartindex).MarkerStyle = DataVisualization.Charting.MarkerStyle.Triangle
                Chart1.Series(chartindex).MarkerSize = 6
                Chart1.Series(chartindex).Color = Color.Red

    You can add a line annotation with arrows on each end. However you would have to draw each series line with an annotation to do it like that.

    Look through annotations in that sample project and etc see if something can be used. If you have to you can also just draw on the chart what you want with gdi+ plus but its complicated. There are several coordinate systems on the chart etc.

    • Marked as answer by kabgei Tuesday, July 11, 2017 9:05 PM
    Tuesday, July 11, 2017 8:40 PM

All replies

  • Please show us a picture of exactly what you want to draw. If you cant post a picture yet try to find something and post a link.

    Do you mean draw a line anywhere on the chart? Use the chart series line and get arrow points? Add annotations with line pointers? What exactly.

    You should get these docs and look up smart label I don't think it does what you want. This is a Visual Studio project you open and run in Visual Studio. Its the best chart docs there is.

    https://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61

    Tuesday, July 11, 2017 8:02 PM
  • It won't allow me to post pictures or links yet. I'll try to describe it better.

    The code already creates the line on the chart. So I think the answer to "Use the chart series line and get arrow points?" is yes.

    Currently my chart has a solid line on it (a chart series line) which is also created by the posted code. I just want to change the display of that solid line to a line with arrows on the ends.

    I'll look up smart label again. I'm fairly new, so there's a good chance I'm just not using it right.

    Tuesday, July 11, 2017 8:20 PM
  • It won't allow me to post pictures or links yet. I'll try to describe it better.

    The code already creates the line on the chart. So I think the answer to "Use the chart series line and get arrow points?" is yes.

    Currently my chart has a solid line on it (a chart series line) which is also created by the posted code. I just want to change the display of that solid line to a line with arrows on the ends.

    I'll look up smart label again. I'm fairly new, so there's a good chance I'm just not using it right.

    I see. Hmmm. Not sure there is an easy way to put arrows on the series line. You can use markerstyle but not like arrows that align to the series line. This code makes a triangle at each point in the series:

     Chart1.Series(chartindex).MarkerStyle = DataVisualization.Charting.MarkerStyle.Triangle
                Chart1.Series(chartindex).MarkerSize = 6
                Chart1.Series(chartindex).Color = Color.Red

    You can add a line annotation with arrows on each end. However you would have to draw each series line with an annotation to do it like that.

    Look through annotations in that sample project and etc see if something can be used. If you have to you can also just draw on the chart what you want with gdi+ plus but its complicated. There are several coordinate systems on the chart etc.

    • Marked as answer by kabgei Tuesday, July 11, 2017 9:05 PM
    Tuesday, July 11, 2017 8:40 PM
  • Thank you. That sounds like the direction I need to go in.
    • Edited by kabgei Tuesday, July 11, 2017 9:27 PM
    Tuesday, July 11, 2017 8:41 PM