Results 1 to 9 of 9

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Feb 2018
    Posts
    6
    Rep Power
    0
    p45cal: Thank you for the offer. I have done some further research on this, you are correct, stacked bar chart would work. I found a reference to doing this https://peltiertech.com/excel-charts...izontal-bands/, though I will need to convert it to an automated process (VBA) as that link is a manual process. These charts are part of a dashboard; a second sheet defines what to plot, duration, etc, so charts are destroyed and re-created each time a button is pressed, so they are all dynamic. It plots them sequentially, one above the next, using VBA.

    I still like the idea of just drawing rectangles over the chart area, my working code for that is below. But on further research there appears to be no way to make tooltips/screen tips showing coordinates appear when mouse is hovered over these transparent shapes that I have drawn onto the plot with .AddShape method. The shapes themselves appear at 1, 2, and 3 sigma -- my math for calculating their Top, left, width and height was good.

    I will post an answer to my own question using the technique you advise OR post a second inquiry if I can't figure it out.

    I have also been experimenting with creating a 'plot.ly' plot that allows pan and zoom from within Excel (just creating an HTML file and launching the browser), that is working well for my larger time series, I have not tried same technique inside a webviewer window, but that would also be interesting to see if anybody's done it.

    Code to plot horizontal bands on a chart designated chtobj:

    (plots -sigma to +sigma, requires sigma, avg_value variables be set)

    CH_PA_Inside_Width = chtObj.Chart.PlotArea.InsideWidth
    CH_PA_Inside_Height = chtObj.Chart.PlotArea.InsideHeight
    CH_PA_Inside_Left = chtObj.Chart.PlotArea.InsideLeft
    CH_PA_Inside_Top = chtObj.Chart.PlotArea.InsideTop

    With chtObj.Chart

    Max_Y = chtObj.Chart.Axes(xlValue).MaximumScale
    Min_Y = chtObj.Chart.Axes(xlValue).MinimumScale

    top_coord = (Max_Y - (avg_value + sigma)) / (Max_Y - Min_Y) * CH_PA_Inside_Height ' Map ordinate/engineering unit coordinate height to Plot Area height by ratioing the two

    Height = (2 * sigma) / (Max_Y - Min_Y) * CH_PA_Inside_Height ' Map ordinate/engineering unit coordinate height to Plot Area height by ratioing the two

    Set shp = .Shapes.AddShape(1, CH_PA_Inside_Left, CH_PA_Inside_Top + top_coord, CH_PA_Inside_Width, Height)
    shp.Fill.Transparency = 0.5 ' Fractional transparency; 0.5 = 50%
    shp.Line.Visible = msoFalse
    shp.Fill.ForeColor.RGB = vbGreen

    End with











    Code:
        CH_PA_Inside_Width = chtObj.Chart.PlotArea.InsideWidth
        CH_PA_Inside_Height = chtObj.Chart.PlotArea.InsideHeight
        CH_PA_Inside_Left = chtObj.Chart.PlotArea.InsideLeft
        CH_PA_Inside_Top = chtObj.Chart.PlotArea.InsideTop
    
    With chtObj.Chart
    
         Max_Y = chtObj.Chart.Axes(xlValue).MaximumScale 
         Min_Y = chtObj.Chart.Axes(xlValue).MinimumScale 
    
         top_coord = (Max_Y - (avg_value + sigma)) / (Max_Y - Min_Y) * CH_PA_Inside_Height ' Map ordinate/engineering unit coordinate height to Plot Area height by ratioing the two
     
         Height = (2 * sigma) / (Max_Y - Min_Y) * CH_PA_Inside_Height ' Map ordinate/engineering unit coordinate height to Plot Area height by ratioing the two
         
         Set shp = .Shapes.AddShape(1, CH_PA_Inside_Left, CH_PA_Inside_Top + top_coord, CH_PA_Inside_Width, Height)
         shp.Fill.Transparency = 0.5  ' Fractional transparency; 0.5 = 50%
         shp.Line.Visible = msoFalse
         shp.Fill.ForeColor.RGB = vbGreen
    
    End with
    Last edited by DocAElstein; 02-25-2019 at 12:53 PM. Reason: Code tags: @fseipel - welcome to excelfox - 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
  •