Results 1 to 9 of 9

Thread: Cannot read chart object (x,y) values when hovering mouse over chart using overlaid shapes

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Junior Member
    Join Date
    Feb 2018
    Posts
    6
    Rep Power
    0
    p45cal: I think I can close this thread, I added the following code to

    1.) Delete lower x-axis
    2.) Set upper axis to NOT show a time, e.g. it was showing 2/10/19 3:50 PM but with that addition, it now shows only whole days 2/10/19 for example above each tick mark
    3.) Round down date/timestamp of leftmost x-axis and round up rightmost x-axis point so that even with whole days for tick marks, no points are cut off
    4.) Always show ~15 major tick marks regardless of duration of plot (since user can plot 1 week to up to years of data)

    I only tried this on the fixed dataset, I will plug into dynamic retrieval to make sure tick mark code works -- it may need some tweaking to endpoints to be Roundup or Down + or minus the TickInterval parameter, until I see what it does I can't say for sure on that minor detail, but obviously it is very easy to implement.

    The only other thing I'd like to do is move the upper/secondary x-axis back to bottom of plot after deleting lower/primary one, not sure how to accomplish that but it's not a huge big deal.

    In Peltier's example (non-VBA), he only creates TWO pairs to plot stacked area bars/bands across plot, so I also don't think I needed to include any intermediate points to plot the area bars, as I have done, but it works so probably won't change that!

    I can post the full version if it is of use to anybody.

    Thanks again for your assistance.

    chtObj.Chart.Axes(xlCategory, xlPrimary).AxisBetweenCategories = False ' Set axis position on tick marks, thanks to p45cal @ Excelfox for figuring out!
    chtObj.Chart.Axes(xlCategory).Delete ' Delete lower x-axis

    chtObj.Chart.Axes(xlCategory, xlSecondary).TickLabels.NumberFormat = "m/d/yyyy" ' Set x-axis to show date only, no time
    ' Set first/leftmost x-value on an even day (round datetimestamp down -- could also use INT function)
    chtObj.Chart.Axes(xlCategory, xlSecondary).MinimumScale = Application.WorksheetFunction.RoundDown(chtObj.Cha rt.Axes(xlCategory, xlSecondary).MinimumScale, 0)
    ' Set second/rightmost x-value on an event day (round datetimestamp UP -- could alternately use -INT(-x) but that is harder to read)
    chtObj.Chart.Axes(xlCategory, xlSecondary).MaximumScale = Application.WorksheetFunction.RoundUp(chtObj.Chart .Axes(xlCategory, xlSecondary).MaximumScale, 0)
    ' Calculate number of days across x-axis to determine number of tick marks (plot width will vary so this must be set progamatically)
    DaysAcross = chtObj.Chart.Axes(xlCategory, xlSecondary).MaximumScale - chtObj.Chart.Axes(xlCategory, xlSecondary).MinimumScale
    If DaysAcross < 15 Then ' 1-day intervals on tick marks for < 15 day plots
    TickInterval = 1
    ElseIf DaysAcross > 15 And DaysAcross < 32 Then ' 2 days between tick marks for 15-32 day duration plots
    TickInterval = 2
    ElseIf DaysAcross > 32 And DaysAcross < 60 Then ' for 32-60 day plots set tick interval to 4 days
    TickInterval = 4
    Else
    TickInterval = Application.WorksheetFunction.RoundUp(DaysAcross / 15, 0) ' Set tick mark interval such that it provides ~15 divisons along x-axis
    End If

    chtObj.Chart.Axes(xlCategory, xlSecondary).MajorUnit = TickInterval
    Next Series







    Code:
       
       chtObj.Chart.Axes(xlCategory, xlPrimary).AxisBetweenCategories = False ' Set axis position on tick marks, thanks to p45cal @ Excelfox for figuring out!
        chtObj.Chart.Axes(xlCategory).Delete ' Delete lower x-axis
    
        chtObj.Chart.Axes(xlCategory, xlSecondary).TickLabels.NumberFormat = "m/d/yyyy" ' Set x-axis to show date only, no time
        ' Set first/leftmost x-value on an even day (round datetimestamp down -- could also use INT function)
        chtObj.Chart.Axes(xlCategory, xlSecondary).MinimumScale = Application.WorksheetFunction.RoundDown(chtObj.Chart.Axes(xlCategory, xlSecondary).MinimumScale, 0)
        ' Set second/rightmost x-value on an event day (round datetimestamp UP -- could alternately use -INT(-x) but that is harder to read)
        chtObj.Chart.Axes(xlCategory, xlSecondary).MaximumScale = Application.WorksheetFunction.RoundUp(chtObj.Chart.Axes(xlCategory, xlSecondary).MaximumScale, 0)
        ' Calculate number of days across x-axis to determine number of tick marks (plot width will vary so this must be set progamatically)
        DaysAcross = chtObj.Chart.Axes(xlCategory, xlSecondary).MaximumScale - chtObj.Chart.Axes(xlCategory, xlSecondary).MinimumScale
        If DaysAcross < 15 Then ' 1-day intervals on tick marks for < 15 day plots
          TickInterval = 1
        ElseIf DaysAcross > 15 And DaysAcross < 32 Then ' 2 days between tick marks for 15-32 day duration plots
          TickInterval = 2
        ElseIf DaysAcross > 32 And DaysAcross < 60 Then ' for 32-60 day plots set tick interval to 4 days
          TickInterval = 4
        Else
          TickInterval = Application.WorksheetFunction.RoundUp(DaysAcross / 15, 0) ' Set tick mark interval such that it provides ~15 divisons along x-axis
        End If
        
         chtObj.Chart.Axes(xlCategory, xlSecondary).MajorUnit = TickInterval
            Next Series
    Last edited by DocAElstein; 02-28-2019 at 12:17 AM. Reason: Code tags: @fseipel - - you can gat code tags using the # icon - then put your code inside those.

Similar Threads

  1. Replies: 2
    Last Post: 01-13-2014, 07:13 PM
  2. Custom Charts in Excel :: Gauge Chart (aka Dial/Speedometer Chart)
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 08-07-2013, 05:16 PM
  3. Replies: 4
    Last Post: 06-10-2013, 01:27 PM
  4. Excel Chart Showing Values on Angle: Nightingale Chart
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 0
    Last Post: 10-17-2012, 06:39 PM
  5. Replies: 1
    Last Post: 05-20-2012, 12:23 PM

Posting Permissions

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