• 定制概述
  • 通过数据流定制
  • 在客户端进行定制
  • 也可以看看

    定制概述


    定制是一个相当模糊的概念,所以写几篇文章对它进行说明。

    通过数据流定制

    他们最关心的是数据相关的东西。定制的配置可以通过datafeed响应来实现。响应配置实例:

    1. {
    2. supports_search: true,
    3. supports_group_request: false,
    4. supports_marks: true,
    5. exchanges: [
    6. {value: "", name: "All Exchanges", desc: ""},
    7. {value: "XETRA", name: "XETRA", desc: "XETRA"},
    8. {value: "NSE", name: "NSE", desc: "NSE"}
    9. ],
    10. symbolsTypes: [
    11. {name: "All types", value: ""},
    12. {name: "Stock", value: "stock"},
    13. {name: "Index", value: "index"}
    14. ],
    15. supportedResolutions: [ "1", "15", "30", "60", "D", "2D", "3D", "W", "3W", "M", '6M' ]
    16. };

    在JS API可以找到更详细的说明。

    在客户端进行定制

    允许您最大化的定制UI/UX。这些定制通过定义图表控件中的构造函数的参数完成。

    图表控件构造函数调用的示例:

    1. var widget = new TradingView.widget({
    2. fullscreen: true,
    3. symbol: 'AA',
    4. interval: 'D',
    5. toolbar_bg: '#f4f7f9',
    6. allow_symbol_change: true,
    7. container_id: "tv_chart_container",
    8. datafeed: new Datafeeds.UDFCompatibleDatafeed("http://demo_feed.tradingview.com"),
    9. library_path: "charting_library/",
    10. locale: "en",
    11. drawings_access: { type: 'black', tools: [ { name: "Regression Trend" } ] },
    12. disabled_features: ["use_localstorage_for_settings", "volume_force_overlay"],
    13. enabled_features: ["move_logo_to_main_pane"],
    14. overrides: {
    15. "mainSeriesProperties.style": 0,
    16. "symbolWatermarkProperties.color" : "#944",
    17. "volumePaneSize": "tiny"
    18. },
    19. studies_overrides: {
    20. "bollinger bands.median.color": "#33FF88",
    21. "bollinger bands.upper.linewidth": 7
    22. },
    23. debug: true,
    24. time_frames: [
    25. { text: "50y", resolution: "6M" },
    26. { text: "1d", resolution: "5" },
    27. ],
    28. charts_storage_url: 'http://saveload.tradingview.com',
    29. client_id: 'tradingview.com',
    30. user_id: 'public_user',
    31. favorites: {
    32. intervals: ["1D", "3D", "3W", "W", "M"],
    33. chartTypes: ["Area", "Line"]
    34. }
    35. });

    详情参考:Widget构造器

    也可以看看

    • Widget方法
    • 定制的使用案例