PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 Chart object and custom data point labels - Can set, but not displayed...-VBForums
Results 1 to 7 of 7

Thread: Chart object and custom data point labels - Can set, but not displayed...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Wiltshire, England
    Posts
    211

    Question Chart object and custom data point labels - Can set, but not displayed...

    Hi,

    I have set some custom datapoint labels, but they are not showing or if they do when setting IsValueShownAsLabel=true then they display the Y axis values.
    Code:
            With embChartTabPage12
                .DataSource = dtPCA_Loading
                .ChartAreas(0).AxisX.Title = "Comp1"
                .ChartAreas(0).AxisX.Interval = Math.Round(((.ChartAreas(0).AxisX.Maximum - .ChartAreas(0).AxisX.Minimum) / 10), 2)
                .ChartAreas(0).AxisX.LabelStyle.Format = "#.##"
                .ChartAreas(0).AxisX.Crossing = 0
                .ChartAreas(0).AxisY.Title = "Comp2"
                .ChartAreas(0).AxisY.LabelStyle.Angle = -90
                .ChartAreas(0).AxisY.Crossing = 0
    
                .Series(0).Name = "Data"
                .Series(0).XValueMember = "Comp1"
                .Series(0).YValueMembers = "Comp2"
                .Series(0).ChartType = SeriesChartType.Point
                .Series(0).MarkerSize = 9
                intSource_Col_Count = 8
                        Dim point As System.Windows.Forms.DataVisualization.Charting.DataPoint
                For Each point In .Series(0).Points
                    point.IsValueShownAsLabel = True
                    point.Label = wksCDautoexperiment.Cells(22, intSource_Col_Count).value & strUnits
                    intSource_Col_Count = intSource_Col_Count + 8
                Next
                .Series(0).IsValueShownAsLabel = True
    I don't know where I should put the IsValueShownAsLabel line and whether I should set it at the point or series level.

    Thanks

    Kristian

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,242

    Re: Chart object and custom data point labels - Can set, but not displayed...

    when setting IsValueShownAsLabel=true then they display the Y axis values
    Well, yeah. That's what that setting does! It is customary for the x-axis to represent the regularly spaced variable and the y-axis to represent 'result' values. If you want a customised label for each point you must first set a placeholder for it, so eg.

    vb.net Code:
    1. Dim c As Integer = 8
    2. ' set placeholder for custom label
    3.         Chart1.Series(0).Label = "#LABEL" ' this is the keyword for a custom string
    4.  
    5.         For Each p As DataVisualization.Charting.DataPoint In Chart1.Series(0).Points
    6.             p.Label = "C Value = " & c.ToString
    7.             c += 8
    8.         Next
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Wiltshire, England
    Posts
    211

    Re: Chart object and custom data point labels - Can set, but not displayed...

    Hi dunfiddlin,

    I've changed my code to this but now just get datapoints with a "#LABEL" label.
    [CODE]
    intSource_Col_Count = 8
    Dim point As System.Windows.Forms.DataVisualization.Charting.DataPoint
    .Series(0).Label = "#LABEL"
    For Each point In .Series(0).Points
    point.Label = wksCDautoexperiment.Cells(22, intSource_Col_Count).value & strUnits
    intSource_Col_Count = intSource_Col_Count + 8
    Next
    [CODE]


    Do I need to set IsValueShownAsLabel to true or false or just leave them be?

    I did find a MS page with all the keyword, but no details on how to use them.

    Thanks

    Kristian

  4. #4
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,253

    Re: Chart object and custom data point labels - Can set, but not displayed...

    Hey Kris,

    Stick with your latest code (note the change in red and lose the .Series(0).Label = "#LABEL") and try:
    Code:
    With embChartTabPage12
        .DataSource = dtPCA_Loading
        .ChartAreas(0).AxisX.Title = "Comp1"
        .ChartAreas(0).AxisX.Interval = Math.Round(((.ChartAreas(0).AxisX.Maximum - .ChartAreas(0).AxisX.Minimum) / 10), 2)
        .ChartAreas(0).AxisX.LabelStyle.Format = "#.##"
        .ChartAreas(0).AxisX.Crossing = 0
        .ChartAreas(0).AxisY.Title = "Comp2"
        .ChartAreas(0).AxisY.LabelStyle.Angle = -90
        .ChartAreas(0).AxisY.Crossing = 0
    
        .Series(0).Name = "Data"
        .Series(0).XValueMember = "Comp1"
        .Series(0).YValueMembers = "Comp2"
        .Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Point
        .Series(0).MarkerSize = 9
    
        .DataBind()
    
    
        intSource_Col_Count = 8
        Dim point As System.Windows.Forms.DataVisualization.Charting.DataPoint
        For Each point In .Series(0).Points
            point.Label = wksCDautoexperiment.Cells(22, intSource_Col_Count).value & strUnits
            intSource_Col_Count = intSource_Col_Count + 8
        Next
    
    
    End With

  5. #5
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,242

    Re: Chart object and custom data point labels - Can set, but not displayed...

    I've changed my code to this but now just get datapoints with a "#LABEL" label.
    That's what shows up at Design Time. Did you actually run the program?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Wiltshire, England
    Posts
    211

    Re: Chart object and custom data point labels - Can set, but not displayed...

    Hi Inferrd,

    Thanks for your help - that sorted it.

    dunnfiddlin - I must have done something wrong as "#Label" showed up against every data point on the chart.


    Kristian

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Wiltshire, England
    Posts
    211

    Re: Chart object and custom data point labels - Can set, but not displayed...

    Hi Inferrd,

    Another thank-you as ended up re-reading this post (without realising it was mine) as forgot about the "Databind" method again when trying to change charttype for a particular datapoint.

    Kristian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width