mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-14 18:12:10 +00:00
* replaced YTNode's data arg as RawNode * updated documentation * removed unused import ---- Note that there are still many nodes that need to be updated, hence the WIP status.
73 lines
1.7 KiB
TypeScript
73 lines
1.7 KiB
TypeScript
import { YTNode } from '../../helpers.js';
|
|
import type { RawNode } from '../../index.js';
|
|
|
|
class DataModelSection extends YTNode {
|
|
static type = 'DataModelSection';
|
|
|
|
title: string;
|
|
subtitle: string;
|
|
metric_value: string;
|
|
|
|
comparison_indicator: {
|
|
trend: string;
|
|
};
|
|
|
|
series_configuration: {
|
|
line_series: {
|
|
lines_data: {
|
|
x: number[];
|
|
y: number[];
|
|
style: {
|
|
line_width: number;
|
|
line_color: number;
|
|
}
|
|
}
|
|
domain_axis: {
|
|
tick_values: number[];
|
|
custom_formatter: {
|
|
labels: string[];
|
|
}
|
|
}
|
|
measure_axis: {
|
|
tick_values: number[];
|
|
custom_formatter: {
|
|
labels: string[];
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
constructor(data: RawNode) {
|
|
super();
|
|
|
|
this.title = data.title;
|
|
this.subtitle = data.subtitle;
|
|
this.metric_value = data.metricValue;
|
|
this.comparison_indicator = data.comparisonIndicator;
|
|
|
|
const line_series = data.seriesConfiguration.lineSeries;
|
|
|
|
this.series_configuration = {
|
|
line_series: {
|
|
lines_data: {
|
|
x: line_series.linesData[0].x,
|
|
y: line_series.linesData[0].y,
|
|
style: {
|
|
line_width: line_series.linesData[0].style.lineWidth,
|
|
line_color: line_series.linesData[0].style.lineColor
|
|
}
|
|
},
|
|
domain_axis: {
|
|
tick_values: line_series.domainAxis.tickValues,
|
|
custom_formatter: line_series.domainAxis.customFormatter
|
|
},
|
|
measure_axis: {
|
|
tick_values: line_series.measureAxis.tickValues,
|
|
custom_formatter: line_series.measureAxis.customFormatter
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
export default DataModelSection; |