mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-22 22:18:14 +00:00
* tests: improve coverage * refactor: clean up nodes * chore: lint * feat(parser): ignore `BrandVideoShelf` Seems to be used for ads. * feat(parser): ignore `BrandVideoSingleton` too
71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import { YTNode } from '../../helpers.js';
|
|
import type { RawNode } from '../../index.js';
|
|
|
|
export default 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
|
|
}
|
|
}
|
|
};
|
|
}
|
|
} |