• <menu id="w2i4a"></menu>
  • logo 【TeeChart Pro ActiveX教程】2018

    文檔首頁(yè)>>【TeeChart Pro ActiveX教程】2018>>【TeeChart Pro ActiveX教程】(六):使用系列(下)

    【TeeChart Pro ActiveX教程】(六):使用系列(下)


    下載TeeChart Pro ActiveX最新版本

    將數(shù)據(jù)添加到系列

    大多數(shù)系列類型(ODBC數(shù)據(jù)源教程8和函數(shù)教程7除外)使用Add和ADDXY方法添加數(shù)據(jù)。 有一些例外,請(qǐng)參閱下表,了解它們?nèi)绾螀^(qū)別的示例:

    Series Type Add Series points Delete Series points
         

    Basic

       

    Gantt

    GanttSeries.AddGantt
    GanttSeries.AddGanttColor

    Series.Delete
    Series.DeleteRange

    Shape

    ShapeSeries.X0,
    ShapeSeries.Y0,
    ShapeSeries.X1,
    ShapeSeries.Y1

    TChart.RemoveSeries
    (Each Shape is a unique Series)

    Bubble

    BubbleSeries.AddBubble

    Series.Delete
    Series.DeleteRange

    Line

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Bar

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    HorizBar

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Area

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Point

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Pie

    Series.Add
    Series.AddNull
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Fast Line

    FastLineSeries.AddRealTime
    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    HorizLine

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    HorizArea

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    3D

       

    Surface

    SurfaceSeries.AddXYZ
    SurfaceSeries.AddArrayXYZ
    SurfaceSeries.AddArrayGrid

    Series.Delete
    Series.DeleteRange

    Contour

    ContourSeries.AddXYZ
    ContourSeries.AddArrayXYZ
    ContourSeries.AddArrayGrid

    Series.Delete
    Series.DeleteRange

    Waterfall

    Waterfall.AddXYZ
    Waterfall.AddArrayXYZ
    Waterfall.AddArrayGrid

    Series.Delete
    Series.DeleteRange

    Color Grid

    ColorGrid.AddXYZ
    ColorGrid.AddArrayXYZ
    ColorGrid.AddArrayGrid

    Series.Delete
    Series.DeleteRange

    Vector 3D

    Vector3D.AddVector
    Vector3D.AddXYZ
    Vector3D.AddArrayXYZ
    Vector3D.AddArrayGrid

    Series.Delete
    Series.DeleteRange

    Tower

    Tower.AddXYZ
    Tower.AddArrayXYZ
    Tower.AddArrayGrid

    Series.Delete
    Series.DeleteRange

    Point3D

    Point3DSeries.AddXYZ

    Series.Delete
    Series.DeleteRange

    Triangle Surf.

    TriSurface.AddXYZ
    TriSurface.AddArrayXYZ
    TriSurface.AddArrayGrid

    Series.Delete
    Series.DeleteRange

    Other

       

    Bar 3D

    Bar3D.AddBar
    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Image Bar

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Wind Rose

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Clock

    None

    None

    Line Point

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Bar Join

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Calender

    Calendar.Date

    None

    Big Candle

     

     

    ImagePoint

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    DeltaPoint

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Extended

       

    Polar

    PolarSeries.AddPolar

    Series.Delete
    Series.DeleteRange

    Radar

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Arrow

    ArrowSeries.AddArrow

    Series.Delete
    Series.DeleteRange

    Bezier

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Donut

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Smith

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Pyramid

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Map

    Map.Shapes.Add

    Series.Delete
    Series.DeleteRange

    Gauge

    Gauge.Value

    None

    Financial

       

    Candle

    CandleSeries.AddCandle

    Series.Delete
    Series.DeleteRange

    Volume

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    Point & Figure

    PointFigure.AddOHLC

    Series.Delete
    Series.DeleteRange

    Stats

       

    Error

    ErrorSeries.AddErrorBar

    Series.Delete
    Series.DeleteRange

    Error Bar

    ErrorBarSeries.AddErrorBar

    Series.Delete
    Series.DeleteRange

    High-Low

    HighLow.AddHighLow

    Series.Delete
    Series.DeleteRange

    Histogram

    Series.Add
    Series.AddXY
    Series.AddNull
    Series.AddNullXY
    Series.AddArray

    Series.Delete
    Series.DeleteRange

    BoxPlot

    BoxPlot.Median
    BoxPlot.Quartile1
    BoxPlot.Quartile3
    BoxPlot.InnerFence1
    BoxPlot.InnerFence3
    BoxPlot.OuterFence1
    BoxPlot.OuterFence3

    TChart.RemoveSeries
    (Each BoxPlot is a unique Series)

    Horizontal BoxPlot

    BoxPlot.Median
    BoxPlot.Quartile1
    BoxPlot.Quartile3
    BoxPlot.InnerFence1
    BoxPlot.InnerFence3
    BoxPlot.OuterFence1
    BoxPlot.OuterFence3

    TChart.RemoveSeries
    (Each BoxPlot is a unique Series)

    Funnel

    Funnel.AddSegment

    Series.Delete
    Series.DeleteRange

    請(qǐng)注意,不使用Add或AddXY方法的Series,可以在系列中訪問(wèn)其特定于系列的數(shù)據(jù)添加方法。“as [SeriesType]”屬性(例如,Series.asCandle.AddCandle中的AddCandle; Series.asGantt.AddGantt中的AddGantt))。

    顏色

    添加點(diǎn)時(shí),可以手動(dòng)為點(diǎn)添加顏色

    例如:

    TChart1.Series(0).Add 46, "My first value", vbYellow

    或者使用TeeChart常量clTeeColor,告訴TeeChart分配顏色。 TeeChart將為每個(gè)新系列選擇最多16種獨(dú)特且尚未使用的顏色中的一種。

    例如:

    TChart1.Series(0).Add 46, "My first value", clTeeColor

    可以為Point添加“非顏色”,以便為ValueList中的值保留空間,而不會(huì)在Chart上顯示。

    例如:

    TChart1.Series(0).Add 46, "My hidden value", clNone

    從系列中刪除數(shù)據(jù)點(diǎn)

    使用Series.Delete從Series中刪除一個(gè)點(diǎn)。

    例如:

    TChart.Series(0).Delete(7) ; (8th point - Points index start at zero)

    可以從系列中刪除點(diǎn)范圍:

    Private Sub Command1_Click()
    TChart1.Series(0).DeleteRange 5, 5 '(Deletes points 5, 6, 7, 8, & 9 from the Series)
    End Sub

    Private Sub Form_Load()
    With TChart1
        .AddSeries scLine
        .Series(0).FillSampleValues 20
    End With
    End Sub

    向系列添加空點(diǎn)
    有關(guān)支持AddNull方法的系列類型列表,請(qǐng)參閱向系列添加數(shù)據(jù)表。 顧名思義,AddNull將為系列添加一個(gè)Null點(diǎn),允許您為該點(diǎn)定義一個(gè)標(biāo)簽,但在該點(diǎn)處系列中斷。 在Line Series的情況下,中斷前的最后一個(gè)點(diǎn)不會(huì)連接到中斷后的第一個(gè)點(diǎn)。 請(qǐng)參見(jiàn)Series.AddNull和Series.AddNullXY。

    例如:

    TChart1.Series(0).AddNull "my null value"

    在圖表上混合系列類型
    TeeChart Pro提供了一個(gè)空的Chart Canvas作為數(shù)據(jù)系列的背景。 這意味著沒(méi)有預(yù)定義圖表類型。 您可以將所需的圖表類型定義為要顯示的系列類型的混合。 由于某些系列類型的特殊性質(zhì),在Chart上將Series類型與另一個(gè)類型混合是不切實(shí)際的。 當(dāng)您到達(dá)添加新系列時(shí),TeeChart會(huì)通過(guò)在圖表庫(kù)中顯示不合適的系列類型來(lái)幫助您。 您可以在一個(gè)圖表中放置的系列數(shù)量沒(méi)有實(shí)際限制。

    添加新系列
    使用圖表編輯器(參見(jiàn)教程1)或按代碼添加系列。

    例如:

    TChart1.AddSeries(scLine)  ' Adds a Line Series

    (*注意:Microsoft在Internet Explorer中實(shí)現(xiàn)的VBScript不支持TeeChart Enum常量(scLine,scBar等)。您必須使用等價(jià)整數(shù)(0,1等)來(lái)添加新的Series類型。請(qǐng)參閱ESeriesClass 完整列表。此規(guī)則適用于使用VBscript的所有TeeChart ENum常量。

    例如:

    TChart1.AddSeries(0)  ' Adds a Line Series (vbscript)

    系列被添加到可由Index,TChart1.Series(index)訪問(wèn)的SeriesList,從第一個(gè)系列的0開(kāi)始。 TeeChart Pro為系列(Series1,Series2等)添加默認(rèn)名稱。 您可以使用Series.Title屬性修改名稱。
    選擇系列的軸
    添加到圖表中的系列將自動(dòng)將左軸和下軸作為參考軸。 您可以通過(guò)選擇相關(guān)系列的“系列常規(guī)”頁(yè)面來(lái)更改圖表編輯器中的參考軸。 有4個(gè)軸可供選擇,Top,Left,Bottom和Right。 通過(guò)代碼,更改軸將如下所示:

    With TChart1.Series(0)
     .HorizontalAxis = aTopAxis
     .VerticalAxis = aRightAxis
    End With

    每個(gè)軸可以關(guān)聯(lián)1個(gè)以上的系列。 TeeChart將決定適合與Axis匹配的系列的最佳比例,但您可以自己更改Axis音階(參見(jiàn)Axis Tutorial)??梢蕴砑痈郊虞S,它們將復(fù)制與前4軸相對(duì)應(yīng)的刻度(參見(jiàn)教程部分附加軸)。


    連接系列
    您可以使用Series作為另一個(gè)Series的數(shù)據(jù)源。通過(guò)設(shè)置第二系列的數(shù)據(jù)源,可以使用圖表編輯器完成此操作。轉(zhuǎn)到“系列”選項(xiàng)卡“數(shù)據(jù)源”頁(yè)面。選擇“Function”作為數(shù)據(jù)源類型。將出現(xiàn)兩個(gè)列表框,可用系列和選定系列。選擇要用作本系列數(shù)據(jù)源的系列,然后在上面名為Function:的Combobox中,選擇Copy作為功能類型。請(qǐng)注意,以這種方式,任何Series都可以定義為任何其他Series的函數(shù),F(xiàn)unction Type可以是Function組合框中可用的任何列表。要通過(guò)代碼執(zhí)行相同操作,請(qǐng)參閱下文:

    With TChart1.Series(1)
      .DataSource = "Series1"  '  Series1 es Series(0)
      .SetFunction tfCopy
    End With

    更改系列訂單
    使用圖表編輯器可以非常輕松地更改系列順序。 轉(zhuǎn)到編輯器的首頁(yè),突出顯示要移動(dòng)的系列。 使用右側(cè)的箭頭按鈕以系列順序向上或向下移動(dòng)系列。 系列訂單將決定圖表中系列相對(duì)于其他系列的相對(duì)顯示位置。 將系列設(shè)置為“Active=False”將從圖表中隱藏系列,但保持其數(shù)據(jù)內(nèi)容不變。

    要通過(guò)代碼更改系列順序,請(qǐng)使用TChart.ExchangeSeries。

    TChart1.ExchangeSeries 0, 1  ' Change Series(0) with Series(1) in the index order

    *注意。 交換Series后,系列的索引將被更改。 因此,如果代碼重新運(yùn)行,上面的代碼行將永久地交換2系列'0'和'1',因?yàn)?變?yōu)?,1變?yōu)?。

    系列價(jià)值表
    TeeChart系列通過(guò)ValueList接口將其值存儲(chǔ)在可訪問(wèn)和可修改的Valuelist中。 有關(guān)下面概述的技術(shù)的工作示例,請(qǐng)參閱示例文件夾下面標(biāo)題為“Interactive”的Visual Basic示例代碼。

    訪問(wèn)系列值
    您可以訪問(wèn)列表中的任何值:

    msgbox TChart1.Series(0).XValues.Value(3)
    'Displays value of 4th point (index starts at 0) in Series0

    以這種方式訪問(wèn)的值可用于設(shè)置Series數(shù)據(jù)的陷阱:

    With TChart1.Series(0)
       For t = 0 To .Count - 1
         If .YValues.Value(t) > 900 Then
           MsgBox "Value: " & .XValues.Value(t) & ", " _
                  & .YValues.Value(t) & " exceeds limit"
         End If
       Next t
    End With

    可以通過(guò)一些Series方法和幾個(gè)Chart事件使用的PointIndex值獲得相同的值。

    Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    If SeriesIndex = 0 Then
      MsgBox "ValueIndex is: " & ValueIndex
      MsgBox "Point's Y value is: " & TChart1.Series(SeriesIndex).YValues.Value(ValueIndex)
    End If
    TChart1.StopMouse  'Use Stopmouse to prevent Zoom event activating
    End Sub

    使用值的示例
    此代碼根據(jù)用戶的鼠標(biāo)單擊修改BarSeries Bar的值。 請(qǐng)參閱TeeChart的Interactive Visual Basic演示。

    'Use the OnClickSeries or OnclickBackground event to determine where the user has clicked.
    Private Sub TChart1_OnClickBackground(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    If CInt(TChart1.Axis.Bottom.CalcPosPoint(X)) > -1 Then
      Select Case Button
      Case 1
        UpdatePoint CInt(TChart1.Axis.Bottom.CalcPosPoint(X)), CInt(TChart1.Axis.Left.CalcPosPoint(Y))
      End Select
    End If
    End Sub
    
    Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
      UpdatePoint ValueIndex, CInt(TChart1.Axis.Left.CalcPosPoint(Y))
    End Sub

    在這兩種情況下,請(qǐng)調(diào)用UpdatePoint Sub例程來(lái)修改Bar的值:

    Private Sub UpdatePoint(Bar, Y As Double)
      If Bar < TChart1.Series(0).Count Then
        TChart1.Series(0).YValues.Value(Bar) = Int(Y)
      End If
    End Sub

    系列活動(dòng)
    上一節(jié)介紹了Series事件的一些用法。 本節(jié)介紹了一些其他用途。

    OnClickSeries
    您可以使用OnClickSeries事件來(lái)獲取有關(guān)Series的幾乎所有信息(請(qǐng)參閱“訪問(wèn)系列值”一節(jié))。

    'These examples apply to a Series with Datetime data
    'eg These test values may be used for the following event examples
    Private Sub Command1_Click()
     TChart1.AddSeries scLine
     With TChart1.Series(0)
      .XValues.DateTime = True
      .asLine.Pointer.Visible = True
      .Marks.Visible = True
      'Here with European dateformat
      .AddXY DateValue("1/1/1999") + TimeValue("11:59:00"), 45, "", clTeeColor
      .AddXY DateValue("1/1/1999") + TimeValue("21:59:00"), 23, "", clTeeColor
      .AddXY DateValue("2/1/1999") + TimeValue("11:59:00"), 43, "", clTeeColor
      .AddXY DateValue("2/1/1999") + TimeValue("21:59:00"), 12, "", clTeeColor
      .AddXY DateValue("3/1/1999") + TimeValue("10:59:00"), 12, "", clTeeColor
      .AddXY DateValue("3/1/1999") + TimeValue("21:59:00"), 11, "", clTeeColor
      .AddXY DateValue("4/1/1999") + TimeValue("11:59:00"), 34, "", clTeeColor
      .AddXY DateValue("4/1/1999") + TimeValue("21:59:00"), 15, "", clTeeColor
      .AddXY DateValue("4/1/1999") + TimeValue("23:59:00"), 28, "", clTeeColor
      .AddXY DateValue("5/1/1999") + TimeValue("09:59:00"), 32, "", clTeeColor
      .AddXY DateValue("5/1/1999") + TimeValue("21:59:00"), 32, "", clTeeColor
     End With
     TChart1.Axis.Bottom.SetMinMax TChart1.Series(0).XValues.First, _
                                   TChart1.Series(0).XValues.Last + (2 / 12)
    End Sub

    您可以使用此事件顯示Series'Clicked'值

    Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
      'The below will show the Value of the nearest Point, not the exact Axis value at the clicked X and Y.
      MsgBox ("Date is:" & Format(TChart1.Series(SeriesIndex).XValues.Value(ValueIndex), "dd/mm/yyyy hh:mm:ss") _
                & " Value is:" & TChart1.Series(SeriesIndex).YValues.Value(ValueIndex))
      TChart1.StopMouse
    End Sub

    或者:

    Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
      'The below will show the exact Axis values at the X,Y clicked.
      MsgBox ("Date is:" & Format(TChart1.Series(SeriesIndex).XScreenToValue(X), "dd/mm/yyyy hh:mm:ss") _
                 & " Value is:" & TChart1.Series(SeriesIndex).YScreenToValue(Y))
      TChart1.StopMouse
    End Sub

    OnGetSeriesPointerStyle
    對(duì)于那些使用TChart指針的系列,您可以使用OnGetSeriesPointer事件訪問(wèn)和修改指針:

    'Drawing an Uptriangle if the Point is higher than the last, DownTriangle if lower, etc.
    Private Sub TChart1_OnGetSeriesPointerStyle(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, AStyle As TeeChart.EPointerStyle)
     If ValueIndex > 0 Then
       If TChart1.Series(SeriesIndex).YValues.Value(ValueIndex) > TChart1.Series(SeriesIndex).YValues.Value(ValueIndex - 1) Then
         AStyle = psTriangle
       ElseIf TChart1.Series(SeriesIndex).YValues.Value(ValueIndex) < TChart1.Series(SeriesIndex).YValues.Value(ValueIndex - 1) Then
         AStyle = psDownTriangle
       Else
         AStyle = psDiamond
       End If
     Else
       AStyle = psDiamond
     End If
    End Sub

    OnGetSeriesMark
    使用OnGetSeriesMark事件在運(yùn)行時(shí)修改標(biāo)記內(nèi)容:

    此代碼根據(jù)相對(duì)于最后一個(gè)箭頭長(zhǎng)度的值更改Marktext也會(huì)更改。 TeeChart支持在重疊的情況下拖動(dòng)標(biāo)記,請(qǐng)參閱VB示例文件夾中的VB“移動(dòng)標(biāo)記”示例。

    Private Sub TChart1_OnGetSeriesMark(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, MarkText As String)
     If ValueIndex > 0 Then
       If TChart1.Series(SeriesIndex).YValues.Value(ValueIndex) > TChart1.Series(SeriesIndex).YValues.Value(ValueIndex - 1) Then
         MarkText = MarkText & " (Up)"
       ElseIf TChart1.Series(SeriesIndex).YValues.Value(ValueIndex) < TChart1.Series(SeriesIndex).YValues.Value(ValueIndex - 1) Then
         TChart1.Series(SeriesIndex).Marks.ArrowLength = 5
         MarkText = MarkText & Chr$(13) & "(Down)"
       Else
         TChart1.Series(SeriesIndex).Marks.ArrowLength = 25
         MarkText = MarkText & Chr$(13) & "(No change)"
       End If
     End If
    End Sub

    OnMouseEnterSeries和OnMouseLeaveSeries
    系列活動(dòng)的一個(gè)例子如下:

    Private Sub Form_Load()
    With TChart1
        .Aspect.View3D = False
        .AddSeries scBar
        .Series(0).FillSampleValues 10
        .Series(0).Marks.Visible = False
    End With
    End Sub
    
    
    Private Sub TChart1_OnMouseEnterSeries(ByVal SeriesIndex As Long)
    Dim clicked As Long
      clicked = TChart1.Series(SeriesIndex).GetMousePoint
    
      ' Show Series name and point index and value
      Label1.Caption = "Series: " + TChart1.Series(SeriesIndex).Name + _
                     "  point:" + Str(clicked) + _
                     "  value:" + Str(TChart1.Series(SeriesIndex).YValues.Value(clicked))
    End Sub
    
    Private Sub TChart1_OnMouseLeaveSeries(ByVal SeriesIndex As Long)
      Label1.Caption = ""
    End Sub

     

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();