Skip to content

Commit ec19035

Browse files
committed
Title case browser names in chart legends on stats page
This addresses this feedback #1162 (comment) It uses the existing BROWSER_ID_TO_LABEL variable that we use on the feature detail page.
1 parent 70c1f47 commit ec19035

10 files changed

+16
-11
lines changed
527 Bytes
Loading
196 Bytes
Loading
558 Bytes
Loading
686 Bytes
Loading
232 Bytes
Loading
738 Bytes
Loading

frontend/src/static/js/components/test/webstatus-stats-global-feature-count-chart-panel.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,28 @@ describe('WebstatusStatsGlobalFeatureCountChartPanel', () => {
140140

141141
const expectedMap = new Map([
142142
[
143-
'chrome',
143+
'Chrome',
144144
[
145145
{timestamp: '2024-01-01', count: 10},
146146
{timestamp: '2024-01-02', count: 12},
147147
],
148148
],
149149
[
150-
'edge',
150+
'Edge',
151151
[
152152
{timestamp: '2024-01-01', count: 8},
153153
{timestamp: '2024-01-02', count: 11},
154154
],
155155
],
156156
[
157-
'firefox',
157+
'Firefox',
158158
[
159159
{timestamp: '2024-01-01', count: 9},
160160
{timestamp: '2024-01-02', count: 10},
161161
],
162162
],
163163
[
164-
'safari',
164+
'Safari',
165165
[
166166
{timestamp: '2024-01-01', count: 7},
167167
{timestamp: '2024-01-02', count: 13},

frontend/src/static/js/components/test/webstatus-stats-missing-one-impl-chart-panel.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ describe('WebstatusStatsMissingOneImplChartPanel', () => {
112112
});
113113

114114
const expectedMap = new Map([
115-
['chromium', [{timestamp: '2024-01-01', count: 10}]],
116-
['firefox', [{timestamp: '2024-01-01', count: 9}]],
117-
['safari', [{timestamp: '2024-01-01', count: 7}]],
115+
['Chromium', [{timestamp: '2024-01-01', count: 10}]],
116+
['Firefox', [{timestamp: '2024-01-01', count: 9}]],
117+
['Safari', [{timestamp: '2024-01-01', count: 7}]],
118118
]);
119119
expect(browserToDataMap).to.deep.equal(expectedMap);
120120
});

frontend/src/static/js/components/webstatus-stats-global-feature-count-chart-panel.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
ALL_BROWSERS,
2828
BrowsersParameter,
2929
BROWSER_ID_TO_COLOR,
30+
BROWSER_ID_TO_LABEL,
3031
} from '../api/client.js';
3132
import {customElement, state} from 'lit/decorators.js';
3233

@@ -73,9 +74,12 @@ export class WebstatusStatsGlobalFeatureCountChartPanel extends WebstatusLineCha
7374
if (typeof apiClient !== 'object') return;
7475

7576
const browserMetricData: Array<
76-
LineChartMetricData<BrowserReleaseFeatureMetric>
77+
LineChartMetricData<BrowserReleaseFeatureMetric> & {
78+
browser: BrowsersParameter;
79+
}
7780
> = ALL_BROWSERS.map(browser => ({
78-
label: browser,
81+
label: BROWSER_ID_TO_LABEL[browser],
82+
browser: browser,
7983
data: [],
8084
getTimestamp: (dataPoint: BrowserReleaseFeatureMetric) =>
8185
new Date(dataPoint.timestamp),
@@ -93,7 +97,7 @@ export class WebstatusStatsGlobalFeatureCountChartPanel extends WebstatusLineCha
9397
const allMetricData = [...browserMetricData, maxMetricData];
9498
const browserPromises = ALL_BROWSERS.map(async browser => {
9599
const browserData = browserMetricData.find(
96-
data => data.label === browser,
100+
data => data.browser === browser,
97101
);
98102
if (!browserData) return;
99103

frontend/src/static/js/components/webstatus-stats-missing-one-impl-chart-panel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
type APIClient,
2626
BrowsersParameter,
2727
BROWSER_ID_TO_COLOR,
28+
BROWSER_ID_TO_LABEL,
2829
} from '../api/client.js';
2930
import {customElement, state} from 'lit/decorators.js';
3031

@@ -85,7 +86,7 @@ export class WebstatusStatsMissingOneImplChartPanel extends WebstatusLineChartPa
8586
browser: BrowsersParameter;
8687
}
8788
> = this.supportedBrowsers.map(browser => ({
88-
label: browser === 'chrome' ? 'chromium' : browser, // Special case for Chrome
89+
label: browser === 'chrome' ? 'Chromium' : BROWSER_ID_TO_LABEL[browser], // Special case for Chrome
8990
browser: browser,
9091
data: [],
9192
getTimestamp: (dataPoint: BrowserReleaseFeatureMetric) =>

0 commit comments

Comments
 (0)