Skip to main content

Class: HistoricalViewer

HistoricalViewer class is responsible for visualizing review analyses data over a specific period of time (day, week, or month). It aggregates the data, converts it to the format required by ChartJS, and provides the necessary options for rendering the chart.

Example

const analysisModel = new AnalysisModel(jsonData);
const historicalViewer = new HistoricalViewer(analysisModel, 'month');
const { options, data } = historicalViewer.getOptionsAndData();
// Render the chart using ChartJS with provided options and data

Constructors​

constructor​

• new HistoricalViewer(analysisModel, timeOption)

Constructs a HistoricalViewer instance.

Parameters​

NameTypeDescription
analysisModelAnalysisModelAn instance of AnalysisModel containing review analyses data.
timeOptionTimeOptionThe period of time for aggregating data ('day', 'week', or 'month').

Defined in​

components/HistoricalViewer.tsx:59

Properties​

analysisModel​

• analysisModel: AnalysisModel

Defined in​

components/HistoricalViewer.tsx:50


timeOption​

• timeOption: TimeOption

Defined in​

components/HistoricalViewer.tsx:51

Methods​

aggregateData​

▸ aggregateData(): ChartData

Aggregates the review analyses data based on the timeOption.

Returns​

ChartData

An object containing labels and positive/negative review counts.

Defined in​

components/HistoricalViewer.tsx:102


convertToChartJSData​

▸ convertToChartJSData(chartData): ChartJSData

Converts aggregated ChartData to the format required by ChartJS.

Parameters​

NameTypeDescription
chartDataChartDataThe aggregated data to be converted.

Returns​

ChartJSData

The formatted data for rendering a ChartJS chart.

Defined in​

components/HistoricalViewer.tsx:171


getDateKey​

▸ getDateKey(dateString): string

Generates a unique date key based on the timeOption. This can be 'day', 'week', or 'month'.

Parameters​

NameTypeDescription
dateStringstringThe date string to generate a key for.

Returns​

string

A unique date key for the specified dateString.

Defined in​

components/HistoricalViewer.tsx:140


getOptionsAndData​

▸ getOptionsAndData(): Object

Returns the options and data needed for rendering a ChartJS chart.

Returns​

Object

An object containing chart options and data formatted for ChartJS.

NameType
dataChartJSData
optionsany

Defined in​

components/HistoricalViewer.tsx:69