<commit_before>import extend                 from 'extend';
import {
    action,
    computed,
    observable }              from 'mobx';
import { ChartBarrierStore }  from './chart_barrier_store';
import { ChartMarkerStore }   from './chart_marker_store';
import {
    barriersObjectToArray,
    isBarrierSupported }      from './Helpers/barriers';
import BaseStore              from '../../base_store';
import { WS }                 from '../../../Services';
import { isEmptyObject }      from '../../../../_common/utility';

export default class SmartChartStore extends BaseStore {
    @observable symbol;
    @observable barriers = observable.object({});
    @observable markers  = observable.object({});

    @observable is_title_enabled = true;
    @observable is_contract_mode = false;

    @observable chart_type = 'mountain';
    @observable granularity = 0;

    @action.bound
    updateChartType(chart_type) {
        this.chart_type = chart_type;
    }

    @action.bound
    updateGranularity(granularity) {
        this.granularity = granularity;
    }

    @action.bound
    setContractMode(is_contract_mode) {
        this.is_contract_mode = is_contract_mode;
        this.is_title_enabled = !is_contract_mode;
    }

    @action.bound
    onUnmount = () => {
        this.symbol = null;
        this.removeBarriers();
        this.removeMarkers();
    };

    // ---------- Barriers ----------
    @action.bound
    createBarriers = (contract_type, high_barrier, low_barrier, onChartBarrierChange, config) => {
        if (isEmptyObject(this.barriers.main)) {
            let main_barrier = {};
            if (isBarrierSupported(contract_type)) {
                main_barrier = new ChartBarrierStore(high_barrier, low_barrier, onChartBarrierChange, config);<commit_msg>change chart_type when user picks tick interval and current chart_type is invalid<commit_after>import extend                 from 'extend';
import {
    action,
    computed,
    observable }              from 'mobx';
import { ChartBarrierStore }  from './chart_barrier_store';
import { ChartMarkerStore }   from './chart_marker_store';
import {
    barriersObjectToArray,
    isBarrierSupported }      from './Helpers/barriers';
import BaseStore              from '../../base_store';
import { WS }                 from '../../../Services';
import { isEmptyObject }      from '../../../../_common/utility';

const tick_chart_types = [
    'mountain',
    'line',
    'colored_line',
    'spline',
    'baseline',
];

export default class SmartChartStore extends BaseStore {
    @observable symbol;
    @observable barriers = observable.object({});
    @observable markers  = observable.object({});

    @observable is_title_enabled = true;
    @observable is_contract_mode = false;

    @observable chart_type = 'mountain';
    @observable granularity = 0;

    @action.bound
    updateChartType(chart_type) {
        this.chart_type = chart_type;
    }

    @action.bound
    updateGranularity(granularity) {
        this.granularity = granularity;
        if (granularity === 0 && !tick_chart_types.includes(this.chart_type)) {
            this.chart_type = 'mountain';
        }
    }

    @action.bound
    setContractMode(is_contract_mode) {
        this.is_contract_mode = is_contract_mode;
        this.is_title_enabled = !is_contract_mode;
    }

    @action.bound
    onUnmount = () => {
        this.symbol = null;
        this.removeBarriers();
        this.removeMarkers();
    };

    // ---------- Barriers ----------
    @action.bound
    createBarriers = (contract_type, high_barrier, low_barrier, onChartBarrierChange, config) => {
        if (isEmptyObject(this.barriers.main)) {
            let main_barrier = {};
            if (isBarrierSupported(contract_type)) {
                main_barrier = new ChartBarrierStore(high_barrier, low_barrier, onChartBarrierChange, config);
{'fraction_non_alphanumeric': 0.12258562966778264, 'fraction_numerical': 0.0007725985063095545, 'mean_word_length': 2.5085817524841914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '679149', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1114, 'n_words': 225}