ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Ãþ¦ü²¾°Ê«ü¤Þ½uªº®ÄªG

¥»©«³Ì«á¥Ñ ®ß®ß¤l ©ó 2015-12-24 13:12 ½s¿è

¦^´_ 10# stillfish00
«D±`·PÁÂS¤j¸Ñ´b¡A«Ü©êºp¤§«e§Ñ°OªþÀɤF¡A³o¬O²Ä¤G­Óªþ¥ó Index_2.zip (91.7 KB)

1. ¦p ¹Ï¤@¡Aµo²{¦pªG±Nvline«ü¦V®y¼Ð2015/5/16¡A¥k¤è¤é´Á«oÅã¥Ü2015/5/19¡AµLªkºë·Çªº¹ï¤W®y¼Ð¡C
   
    ¥t¥~¡A Index_3.zip (92.06 KB) ³o¬O¥ÎS¤j´£¨Ñªº­×§ï¹L«áªºµ{¦¡½Xªºªþ¥ó¡A·|¥X²{«¬ºA¤£²Å¦Xªºerror¡Ö¡Õ

2.­ì¨Ó Chart.MouseMove ¨Æ¥ó·|¦Û°Ê¶Ç¤J­È¡A·PÁÂS¤j¨ü±Ð¤F ~
    ¥t¥~¬d¤F¤@¨Çª«¥óÃþ§O¼Ò²Õªº¨Ï¥Î¤èªk¡Ahttps://msdn.microsoft.com/zh-tw/library/office/ff192938.aspx
    ÁÙ¬O¤£¤Ó²z¸Ñ¡A¥i¥H½Ð¤j¤jÁ|¤@­Ó²³æªº¨Ò¤l»¡©ú¤@¤U¶Ü > <

3.ÁÙ¦³¤@­ÓÃB¥~ªº°ÝÃD¡A¤U­±³o¤@¬qµ{¦¡½X¡A¬°¤°»ò¦b­pºâ x ªº pt ®É­n¦A­¼¤W 75 ©O ?  ³o­Ó¼Æ¦r¬O«ç»ò¨Óªº ?
  1. pt_x = 75 * x / ActiveWindow.Zoom
½Æ»s¥N½X
¦A³Â·Ð¤j¤j¤F¡A«D±`·PÁ : )

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2015-12-24 15:11 ½s¿è

¦^´_ 11# ®ß®ß¤l
1.  indx = Application.Match(targetX, arValue, 1)
     ³o¥y arValue §ï¦¨ arValues , µ§»~¡C

3. §Ú¤]¬O¤Wºô¬dªº¡A§A¦b¬d Chart ªº InsideLeft ©Î InsideWidth ³o¨ÇÄݩʮɳ£·|§i¶D§A¥¦¬O¥H"ÂI"¬°³æ¦ì¡A¤@­ÓÂI©w¸q¬O1/72­^¦T (¤]¦³¤H©w¸q¬°1/72.27­^¦T)¡C

¦Ó¶Ç¤J°Ñ¼Æªº  x , y ³æ¦ì¬O pixel(¹³¯À)¡F®Ú¾Úwindows¤ºÅã¥Ü¾¹ DPI(dot per inch) ³]©w¥i¨M©w¨C­^¦T¦h¤Ö¹³¯À¡A¤@¯ë¹w³]¬° normal size 100% (=96 DPI)¡Aªí¥Ü¨C­^¦T 96 ¹³¯À¡C

©Ò¥H­n§â x ¹³¯ÀÂনÂI­n­¼¥H 72/96=0.75
ÁÙ­n¦Ò¼{ zoom , ©Ò¥HÅܦ¨  0.75*x/(ActiveWindow.zoom/100) = 75*x/ActiveWindow.zoom
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 11# ®ß®ß¤l
­×§ï myVLine.Left ±q¸Ó¸ê®ÆÂIªº left Äݩʨú±o¡A¦p¤U
§A»¡ªºµLªkºë·Çªº¹ï¤W®y¼Ð¡A¨º¬O§A¸ê®Æ¤Ó±K¶°¡A¹Ïªí¥»¨­¤é´Á®y¼Ð¶b´N·|³o¼Ë(¨C­Ó¤ë¤Ñ¼Æ¬O¤£¦Pªº¡A¥¦«o¦P¶¡¹j)
  1. Private Sub myChartClass_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
  2.     Dim pt_x As Double, interval As Double, indx As Long
  3.     Dim arValues, targetX, diffX
  4.     Dim isAxisBetween As Boolean, xOffset
  5.    
  6.     pt_x = 75 * x / ActiveWindow.Zoom
  7.    
  8.     With myChartClass
  9.         If .SeriesCollection.Count = 0 Then Exit Sub
  10.         isAxisBetween = .Axes(xlCategory).AxisBetweenCategories '®y¼Ð¶b¦ì¸m ¨è«×¶¡:True ¨è«×¤W:False
  11.         arValues = .SeriesCollection(1).XValues '¤é´Á¸ê®Æ
  12.         diffX = .Axes(xlCategory).MaximumScale - .Axes(xlCategory).MinimumScale
  13.         xOffset = IIf(isAxisBetween, 0.5 * .PlotArea.InsideWidth / (diffX + 1), 0)
  14.         
  15.         If pt_x < .PlotArea.InsideLeft + xOffset Then
  16.             indx = 1
  17.         Else
  18.             targetX = .Axes(xlCategory).MinimumScale + diffX * (pt_x - .PlotArea.InsideLeft - xOffset) / (.PlotArea.InsideWidth - 2 * xOffset)
  19.             indx = Application.Match(targetX, arValues, 1)
  20.             If indx < UBound(arValues) Then If Abs(targetX - arValues(indx + 1)) < Abs(targetX - arValues(indx)) Then indx = indx + 1  '­×¥¿³Ìªñ¸ê®ÆÂI
  21.         End If
  22.             
  23.         myVLine.Left = .SeriesCollection(1).Points(indx).Left
  24.         myTarget.Cells(1).Value = arValues(indx)
  25.         For i = 1 To .SeriesCollection.Count
  26.             With .SeriesCollection(i)
  27.                 .ApplyDataLabels Type:=xlDataLabelsShowNone
  28.                 .Points(indx).ApplyDataLabels Type:=xlDataLabelsShowValue
  29.                 .Points(indx).DataLabel.Format.Fill.ForeColor.RGB = RGB(255, 255, 0)
  30.                 arValues = .Values
  31.                 If i < myTarget.Cells.Count Then myTarget.Cells(i + 1).Value = arValues(indx)
  32.             End With
  33.         Next
  34.     End With
  35. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

        ÀR«ä¦Û¦b : ¯à·F¤£·F¡A¤£¦p­W·F¹ê·F¡C
ªð¦^¦Cªí ¤W¤@¥DÃD