Skip to main content

ChartScreen

ChartScreen is a complete module that provides professional data visualization with support for all features required for advanced analysis. It includes:

  • Instrument search: Displays instruments from IPFDataProvider and supports searching and selecting trading instruments.
  • Aggregation selection and creation: Enables flexible handling of timeframes and aggregation types.
  • Indicator management: Add, configure, and remove technical indicators.
  • Drawings support: Use drawing tools, annotations, and graphical objects directly on the chart.
  • Chart settings UI: Adjust chart appearance and behavior through a user-friendly interface.

Use ChartScreen to integrate an advanced, interactive chart into your application.

Basic concepts

  • ChartScreen.ViewController: The main interface for managing the chart screen.
  • State: Stores the current UI state, including header, toolbar, and drawing mode.
  • Toolbar items: Access and customize the default toolbar items.

API reference

Properties

  • state: State: Current chart screen state, including header, toolbar, and drawing mode visibility.
  • defaultToolBarItems: [ChartToolBar.Item]: Default toolbar items provided by the chart screen.

Methods

  • changeInstrument(_ instrument: Instrument): Change the instrument displayed on the chart.
  • updateSettings(_ settings: Chart.Settings, completion: (() -> Void)?): Update chart settings with an optional completion handler.
  • updateSettings(_ settings: Chart.Settings): Update chart settings without a completion handler.
  • setupLogoVisibility(_ visible: Bool): Show or hide the chart logo.
  • setupHeaderVisibility(_ visible: Bool): Show or hide the header.
  • setupToolbarVisibility(_ visible: Bool): Show or hide the toolbar.
  • enableDrawingMode(_ isEnable: Bool): Turn drawing mode on or off.
  • updateAggregationPickerShowing(_ shouldShow: Bool): Show or hide the aggregation picker.
  • updateStudiesPickerShowing(_ shouldShow: Bool): Show or hide the studies picker.

Use the ChartScreen.ViewController protocol to control the chart screen. Update chart settings, switch instruments, and manage UI elements such as the header, toolbar, and drawing tools in your code.

This guide explains how to use and customize the chart screen view controller when integrating it into your app.

Example: Creating and using a ChartScreen

import DXChart
import UIKit
let chartVC = ChartScreen.makeScreen(
dataProvider: someDataProvider,
delegate: someDelegate,
logoImage: UIImage(named: "logo"),
shouldShowLogo: true,
shouldShowToolbar: true
)
// Change instrument
chartVC.changeInstrument(newInstrument)
// Update chart settings
var settings = DXChartApp.settingsManager.settings
settings.selectedTheme = .dark
chartVC.updateSettings(settings)
// Hide the logo
chartVC.setupLogoVisibility(false)

Tips

  • Use protocol methods to control chart screen behavior and UI components.
  • Combine default and custom toolbar items to configure the toolbar.
  • Embed the chart screen, present it modally, or push it onto a navigation stack.

For more advanced customization, see the documentation for (Customizing ChartToolBar)[Chart%20for%20iOS/Configuration/Customization/Customizing%20ChartToolBar] and related protocols.