Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/chartOptions/chartOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { buildBarChartSeries, buildColumnChartSeries } from './Utility/seriesDat
import { Translations } from "../conversion/translations";

export const commonChartOptions = (view: View, locale: string, options?: IChartOptions): Options => {
const showTitle: boolean = options?.showTitle ?? true;
const showTitles: boolean = options?.showTitles ?? true;

const sourceText = Translations.source[locale];
let creditsText = `${sourceText}: ${view.sources.map(s => s[locale]).join(', ')}`;
Expand Down Expand Up @@ -56,7 +56,7 @@ export const commonChartOptions = (view: View, locale: string, options?: IChartO
descriptionFormatter: getScreenReaderFormatterCallbackFunction(view, locale)
}
},
title: { text: showTitle ? view.header[locale] : undefined },
title: { text: showTitles ? view.header[locale] : undefined },
subtitle: { text: view.subheaderValues.map(sv => sv[locale]).join(' | ') },
credits: creditsConfig,
tooltip: {
Expand Down
20 changes: 10 additions & 10 deletions src/core/tables/htmlTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: false,
showTitles: false,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: false,
showSources: false,
showLastUpdated: false
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: false,
showSources: false,
showLastUpdated: false
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down Expand Up @@ -267,7 +267,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('Html table render tests', () => {
document.body.appendChild(div);

const settings: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down
2 changes: 1 addition & 1 deletion src/core/tables/htmlTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function renderHtmlTable(view: View, locale: string, options: IChartOptio
// Table content
const table = generateTable(view, locale);

if (options.showTitle) {
if (options.showTitles) {

const caption = document.createElement('caption');
caption.textContent = view.header[locale];
Expand Down
2 changes: 1 addition & 1 deletion src/core/types/chartOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
export interface IChartOptions {
accessibilityMode?: boolean;
showTitle?: boolean;
showTitles?: boolean;
fontFamily?: string;
showLastUpdated?: boolean;
showUnits: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/react/components/chart/chart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Rendering test', () => {
<Chart
pxGraphData={GROUP_VERTICAL_BAR_CHART_CHART_FIXTURE}
locale={'fi'}
showTitle={false}
showTitles={false}

/>);
expect(asFragment()).toMatchSnapshot();
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('Rendering test', () => {
<Chart
pxGraphData={TABLE_WITH_ROW_AND_COLUMN_VARIABLES_CHART_FIXTURE}
locale={'fi'}
showTitle={true}
showTitles={true}
/>);
expect(asFragment()).toMatchSnapshot();
});
Expand Down
8 changes: 4 additions & 4 deletions src/react/components/chart/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export interface IChartProps {
showContextMenu?: boolean;
menuItemDefinitions?: (IFunctionalMenuItem | ILinkMenuItem)[];
menuIconInheritColor?: boolean;
showTitle?: boolean;
showTitles?: boolean;
showTableUnits?: boolean;
showTableSources?: boolean;
footnote?: string;
Expand All @@ -87,7 +87,7 @@ const ReactChart: React.FC<IChartProps> = ({
selectedVariableCodes = null,
showContextMenu = true,
menuIconInheritColor = false,
showTitle,
showTitles,
showTableUnits,
showTableSources,
fontFamily,
Expand Down Expand Up @@ -123,13 +123,13 @@ const ReactChart: React.FC<IChartProps> = ({
}, [variableSelections, pxGraphData]);

const options: IChartOptions = useMemo(() => ({
showTitle: showTitle ?? true,
showTitles: showTitles ?? true,
showUnits: !!showTableUnits,
showSources: showTableSources ?? true,
showLastUpdated: showLastUpdated,
accessibilityMode: accessibilityMode,
fontFamily: fontFamily,
}), [showTitle, showTableUnits, showTableSources, showLastUpdated, accessibilityMode, fontFamily]);
}), [showTitles, showTableUnits, showTableSources, showLastUpdated, accessibilityMode, fontFamily]);

// Force rerender on window resize events, so that scaling and scrollboxes work correctly. Feel free to refactor to a more performant or better solution
let renderTimeOut: NodeJS.Timeout;
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/chart/tableView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jest.mock('uuid', () => ({
describe('TableView render tests', () => {
it('Should render correctly', () => {
const options: IChartOptions = {
showTitle: true,
showTitles: true,
showUnits: true,
showSources: true,
showLastUpdated: false
Expand Down
Loading