API
Subtitle

Subtitle extends Title

맵차트 부제목(subtitle) 설정 모델.
기본적으로 주 제목(title)의 설정을 따르고, 몇가지 속성들이 추가된다.

Properties

visible: boolean (opens in a new tab) readonly

표시 여부.
options.visible 값을 그대로 return하는 것이 아니라, undefinednull 등으로 지정하는 경우 모델의 상태에 따라 truefalse로 해석될 수 있다.
설정의 경우 updateOptions({visible: value})로 지정하는 것과 동일하다.

default :undefined

Methods

bool(prop, def?, fallback?): boolean (opens in a new tab)

boolean (opens in a new tab) 타입의 옵션 값에 특화된 prop() 메서드. prop()과 달리 boolean (opens in a new tab)으로 변환해서 반환한다.

ParameterTypeDescription
propK설정 항목 이름
defboolean (opens in a new tab)기본값. 설정하지 않으면 defaults의 값을 사용한다.
fallbackboolean (opens in a new tab)

return boolean (opens in a new tab) 타입의 옵션 값.

boolAt(path, def?, fallback?): boolean (opens in a new tab)

점(dot) 표기법으로 경로를 지정해서 boolean (opens in a new tab) 타입의 옵션 값을 반환한다.

ParameterTypeDescription
pathstring (opens in a new tab)경로 문자열
defboolean (opens in a new tab)
fallbackboolean (opens in a new tab)

return 경로에 해당하는 boolean (opens in a new tab) 타입의 옵션 값 또는 false

clean(recursive?): Subtitle

_op에 명시적으로 설정되어 있지만 값이 현재 defaults와 동일한 항목들을 제거해 _op를 minimal delta 상태로 정규화한다.

[주의] 대부분의 경우 호출할 필요가 없다.

  • 효과 값(prop/num/props)은 영향 없음.
  • 직렬화(saveOptions)도 어차피 defaults와 같은 값을 필터링하므로 결과가 동일하다. 즉 외부 저장 결과는 clean 전후가 같다.

clean이 실제로 차이를 만드는 경우는 다음과 같다.

  • _op의 메모리 사용을 줄이고 싶을 때(loadOptions로 큰 source를 읽어들인 직후 등).
  • getOption()/saveOption()처럼 _op의 own value를 그대로 반환하는 API의 결과를 "사용자가 명시했는가"의 의미로 사용해야 할 때(예: 디자이너 UI의 "기본값 사용 중" 표시). 이 경우 clean 후에는 defaults와 같은 값들이 undefined로 보고된다.
ParameterTypeDescription
recursiveboolean (opens in a new tab)true로 지정하면 모든 자식 모델에 대해서도 재귀적으로 수행한다. 기본값: true

return 모델 객체 자신

clearOptions(recursive?, render?): Subtitle

명시적으로 설정된 모든 모델 설정 값들을 제거한다.

ParameterTypeDescription
recursiveboolean (opens in a new tab)true로 지정하면 모든 자식 모델에 대해서도 재귀적으로 제거한다. 기본값: false
renderboolean (opens in a new tab)true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값: true

return 모델 객체 자신

clearStyle(render?): Subtitle

명시적으로 모델에 설정된 모든 style 값들을 제거한다.

ParameterTypeDescription
render=falseboolean (opens in a new tab)true로 지정하면 옵션 변경 시 맵차트를 다시 그린다. 기본값 false

dispose(): null

객체를 해제하고 null을 반환한다.
사용 예: this._obj = this._obj.dispose();

return null

getOption(option): any (opens in a new tab)

옵션 값을 읽는다.
prop()과 달리 효과 값이 아닌 명시적으로 설정된 값만 읽는다. 설정되지 않은 옵션은 undefined를 반환한다.

ParameterTypeDescription
optionstring (opens in a new tab)설정 항목 이름

return 명시적으로 설정된 값 또는 undefined

getOptionAt(path): any (opens in a new tab)

점(dot) 표기법으로 경로를 지정해서 옵션 값을 읽는다.

ParameterTypeDescription
pathstring (opens in a new tab)경로 문자열

return 경로에 해당하는 옵션 값 또는 undefined

init(): Subtitle

특정 부모에 마운팅되지 않은 독립된 옵션 객체를 초기화한다.

initAndLoad(source): Subtitle

특정 부모에 마운팅되지 않은 독립된 옵션 객체를 초기화하고, source 객체로부터 옵션 값을 읽어서 설정한다.

ParameterType
sourceany (opens in a new tab)

loadOptions(source): Subtitle

source 객체로부터 모델 설정 값을 읽어서 적용한다.

[정책] load는 source에 명시된 값을 "사용자 의도"로 그대로 보존한다. 즉 source의 값이 현재 defaults와 같더라도 _op에 그대로 기록된다. 이는 단순한 성능 최적화가 아니라 의미상 의도된 동작이다:

  • defaults는 라이브러리 버전업 시 변경될 수 있다.
  • load 시점에 "defaults와 같다"는 이유로 키를 버리면, 이후 defaults가 바뀌었을 때 저장본이 표현하던 값이 조용히 달라진다.
  • 그대로 보존하면 사용자가 명시적으로 지정한 값이 항상 우선한다.

직렬화(saveOptions)는 어차피 defaults와 같은 값을 필터링하므로, 외부에 저장되는 결과의 크기와 내용에는 영향이 없다. 추가 비용은 _op에 약간의 메모리뿐이다. (메모리 정리나 getOption()의 "사용자 명시 여부" 의미가 필요한 특수 케이스에 한해서만 clean()을 명시적으로 호출한다.)

ParameterType
sourceany (opens in a new tab)

num(prop, def?): number (opens in a new tab)

숫자 타입의 옵션 값에 특화된 prop() 메서드. prop()과 달리 숫자로 변환해서 반환한다.

ParameterTypeDescription
propK설정 항목 이름
defnumber (opens in a new tab)기본값. 설정하지 않으면 defaults의 값을 사용한다.

return 숫자 타입의 옵션 값.

numAt(path, def?): number (opens in a new tab)

점(dot) 표기법으로 경로를 지정해서 숫자 타입의 옵션 값을 반환한다.

ParameterTypeDescription
pathstring (opens in a new tab)경로 문자열
defnumber (opens in a new tab)

return 경로에 해당하는 숫자 타입의 옵션 값 또는 NaN

prop(prop, def?): SubtitleOptions[K]

옵션의 효과 값(effective value)을 반환한다.
명시적으로 설정된 값이 있으면 그 값을, 없으면 클래스의 defaults에 정의된 기본값을 반환한다.
옵션 값을 읽을 때는 options.prop 직접 접근 대신 이 메서드를 사용한다.

ParameterTypeDescription
propK설정 항목 이름
defany (opens in a new tab)기본값. 설정하지 않으면 defaults의 값을 사용한다.

propAt(path, def?): any (opens in a new tab)

점(dot) 표기법으로 경로를 지정해서 옵션의 효과 값(effective value)을 반환한다.

ParameterTypeDescription
pathstring (opens in a new tab)경로 문자열
defany (opens in a new tab)

return 경로에 해당하는 옵션 값 또는 undefined

propIs(prop, value): boolean (opens in a new tab)

옵션 값이 특정 값과 일치하는지 여부를 반환한다.

ParameterTypeDescription
propkeyof (opens in a new tab) SubtitleOptions설정 항목 이름
valueany (opens in a new tab)비교할 값

return 일치 여부

propIsNot(prop, value): boolean (opens in a new tab)

옵션 값이 특정 값과 일치하지 않는지 여부를 반환한다.

ParameterTypeDescription
propkeyof (opens in a new tab) SubtitleOptions설정 항목 이름
valueany (opens in a new tab)비교할 값

return 불일치 여부

props(props): Pick<SubtitleOptions, K>

지정한 옵션들의 효과 값(effective value)을 묶어서 반환한다.
여러 옵션을 destructuring으로 한꺼번에 읽을 때 사용한다.

const { color, radius } = this.props('color', 'radius');
ParameterTypeDescription
propsArray (opens in a new tab)<K>설정 항목 이름들

removeAt(path, render?): any (opens in a new tab)

명시적으로 설정된 하위 모델의 설정 값을 제거해서 모델의 기본 값이 적용되도록 한다.
path 매개변수는 하위 모델의 속성 이름을 점(.)으로 구분해서 지정한다. 예를 들어, "axis.x"는 axis 모델의 x 속성을 의미한다.
render와 force 매개변수는 toggleOption과 동일하다.

ParameterType
pathstring (opens in a new tab)
renderboolean (opens in a new tab)

removeOption(prop, render?): Subtitle

명시적으로 설정된 모델 설정 값을 제거해서 모델의 기본 값이 적용되도록 한다.
prop이 자식 모델 이름인 경우에는 해당 자식의 clearOptions(true)를 호출한다.

ParameterTypeDescription
propkeyof (opens in a new tab) SubtitleOptions설정 항목 이름
renderboolean (opens in a new tab)true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값 true

return 모델 객체 자신

saveOption(prop): SubtitleOptions[K] | Record<string (opens in a new tab), any (opens in a new tab)>

옵션 값을 읽는다.
prop()과 달리 효과 값이 아닌 명시적으로 설정된 값만 읽는다. 설정되지 않은 옵션은 undefined를 반환한다.

ParameterTypeDescription
propK설정 항목 이름

return 명시적으로 설정된 값 또는 undefined

saveOptions(props?, recursive?, includeDefs?): Partial<SubtitleOptions>

모델의 설정 값을 json 객체로 직렬화한다.

ParameterTypeDescription
propsRecord<string (opens in a new tab), any (opens in a new tab)> | Array (opens in a new tab)<keyof (opens in a new tab) SubtitleOptions>저장할 속성 필터.
  • (keyof OP)[] 배열: 해당 키들만 저장.
  • 객체 ({ [K in keyof OP]?: any }): 객체에 정의된 키들만 저장. 자식 모델 키의 값으로 객체를 지정하면 해당 자식의 saveOptions(childFilter, true, includeDefs) 호출 시 필터로 전달된다.
  • 생략 또는 빈 배열: 모든 속성 저장. | | recursive | boolean (opens in a new tab) | 자식 모델까지 재귀 저장 여부. | | includeDefs | boolean (opens in a new tab) | 기본값과 동일한 값도 저장 여부. |

saveTo(target, props?, recursive?, includeDefs?): Partial<SubtitleOptions>

모델의 설정 값을 target 객체에 복사해서 저장한다.

ParameterType
targetPartial<SubtitleOptions>
propsArray (opens in a new tab)<keyof (opens in a new tab) SubtitleOptions> | Record<string (opens in a new tab), any (opens in a new tab)>
recursiveboolean (opens in a new tab)
includeDefsboolean (opens in a new tab)

setStyle(prop, value, render?): Subtitle

모델 css style 값을 변경한다.
value에 undefinednull, ''을 지정하면 기존에 설정됐던 스타일 항목이 제거된다.

ParameterTypeDescription
propstring (opens in a new tab)css 스타일 항목 이름.
valueany (opens in a new tab)적용할 스타일 값.
render=trueboolean (opens in a new tab)true로 지정하면 옵션 변경 시 맵차트를 다시 그린다. 기본값 true

setStyles(props, clear?, render?): Subtitle

여러 항목의 모델 css style 값들을 json 객체로 지정해서 동시에 변경한다.
value에 undefinednull, ''을 지정하면 기존에 설정됐던 스타일 항목이 제거된다.

ParameterTypeDescription
propsobject (opens in a new tab)스타일 항목들과 값들이 설정된 json 객체
clear=falseboolean (opens in a new tab)true로 지정하면 기존 스타일 값을 모두 제거한다. 기본값 false
render=trueboolean (opens in a new tab)true로 지정하면 옵션 변경 시 맵차트를 다시 그린다. 기본값 true

toggleAt(path, render?): any (opens in a new tab)

boolean (opens in a new tab) 타입의 모델 설정 값을 반대 값으로 변경한다.
path 매개변수는 하위 모델의 속성 이름을 점(.)으로 구분해서 지정한다. 예를 들어, "axis.x"는 axis 모델의 x 속성을 의미한다.
render와 force 매개변수는 toggleOption과 동일하다.

ParameterType
pathstring (opens in a new tab)
renderboolean (opens in a new tab)

toggleOption(prop, render?): Subtitle

boolean (opens in a new tab) 타입의 모델 설정 값을 반대 값으로 변경한다.
prop이 자식 모델 이름인 경우에는 아무것도 하지 않고 무시된다.

ParameterTypeDescription
propkeyof (opens in a new tab) SubtitleOptions설정 항목 이름
renderboolean (opens in a new tab)true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값 true

return 모델 객체 자신

updateAt(path, value, render?, force?): any (opens in a new tab)

하위 모델의 설정 값을 변경한다.
path 매개변수는 하위 모델의 속성 이름을 점(.)으로 구분해서 지정한다. 예를 들어, "axis.x"는 axis 모델의 x 속성을 의미한다.
render와 force 매개변수는 updateOption과 동일하다.

ParameterType
pathstring (opens in a new tab)
valueany (opens in a new tab)
renderboolean (opens in a new tab)
forceboolean (opens in a new tab)

updateOption(prop, value, render?, force?): Subtitle

하나의 속성 값을 설정한다.
여러 속성들을 한꺼번에 변경할 때는 updateOptions를 사용한다. 기본적으로 이전 값과 다른 경우에만 적용된다. 특히, 속성값이 객체인 경우 객체 속성만 바뀐 경우 적용되지 않는다. 바꾸고 싶다면 force 매개변수를 true로 지정해서 호출한다.
또, prop 매개변수가 하위 모델 이름인 경우 하위 모델의 updateOptions를 호출한 것과 동일하다.

ParameterTypeDescription
propK설정 항목 이름
valueSubtitleOptions[K]설정 값
renderboolean (opens in a new tab)true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값: true
forceboolean (opens in a new tab)지정한 값이 이전 값과 동일한 경우에도 적용한다. 기본값: false

return 모델 객체 자신

updateOptions(source?, render?): Subtitle

모델 설정 값들을 변경한다.
source에 자식 모델 이름의 키가 포함되면 해당 값은 자식 모델의 updateOptions에 위임된다.

ParameterTypeDescription
sourcePartial<SubtitleOptions>설정 옵션들이 포함된 json 객체
renderboolean (opens in a new tab)true로 지정하면 옵션 변경 시 컨트롤을 다시 그린다. 기본값 true

return 모델 객체 자신