Skip to content

Commit

Permalink
feat(screenshots): + 1 custom chart
Browse files Browse the repository at this point in the history
AgeGroupsTimeline:
+twoMonthsNewCasesTooltip
  • Loading branch information
jalezi committed Apr 28, 2021
1 parent b2a23da commit c969592
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions screenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ const path = require('path');
CHART_BASE_URL = 'https://covid-19.sledilnik.org/embed.html#/chart/';
CARD_BASE_URL = 'https://covid-19.sledilnik.org/';

const elementHandleClick = async elementHandle => await elementHandle.click();
const elementHandleClick = async elementHandle => {
await elementHandle.click();
};
const castToNumber = index => +index;

const testFunc = async elementHandle => {
elementHandle.click();
const loopAndShowTooltip = async (series, index, options) => {
const selectorsArray = await Promise.all(
series.map(async item => await item.$$(options.selector))
);
const filtered = selectorsArray.filter(
item => item.length === options.length
);

filtered.length > 0 && (await elementHandleClick(filtered[0][index]));
return filtered[0][index];
};

CHART = {
Expand Down Expand Up @@ -46,7 +56,7 @@ CHART = {
],
sharePCRTooltip: [
['metrics', 3, elementHandleClick],
['highchartsSeries', castToNumber, elementHandleClick],
['highchartsSeriesRect', castToNumber, elementHandleClick],
],
},
},
Expand Down Expand Up @@ -108,6 +118,22 @@ CHART = {
},
AgeGroupsTimeline: {
name: 'AgeGroupsTimeline',
customChart: {
twoMonthsNewCasesTooltip: [
[
'highchartsSeries',
castToNumber,
loopAndShowTooltip,
{
loop: true,
length: 60,
selector: 'rect',
exit: true,
func: elementHandleClick,
},
],
],
},
},
};

Expand Down Expand Up @@ -162,9 +188,18 @@ OPTIONS = {
'.highcharts-root > g.highcharts-series-group > .highcharts-series-0 > rect'
),
metrics: await element.$$('.metrics-selectors > .metric-selector'),
highchartsSeries: await element.$$(
highchartsSeriesRect: await element.$$(
'.highcharts-root > g.highcharts-series-group > .highcharts-series > rect'
),
highchartsSeriesGroup: await element.$$(
'.highcharts-root > g.highcharts-series-group'
),
highchartsSeries: await element.$$(
'.highcharts-root > g.highcharts-series-group g.highcharts-series'
),
highchartsSeriesColumn: await element.$$(
'.highcharts-root > g.highcharts-series-group .highcharts-column-series'
),
}),
},
MULTICARD: {
Expand Down

0 comments on commit c969592

Please sign in to comment.