diff --git a/assets/js/web-components/prpl-chart-line.js b/assets/js/web-components/prpl-chart-line.js
index 5319da0c2..e85a89fae 100644
--- a/assets/js/web-components/prpl-chart-line.js
+++ b/assets/js/web-components/prpl-chart-line.js
@@ -55,13 +55,22 @@ customElements.define(
class="chart-line-checkboxes"
style="
display: flex;
- gap: 1em;
+ flex-wrap: wrap;
+ align-items: flex-start;
+ gap: 0.5em 1em;
margin-bottom: 1em;
- justify-content: space-between;
font-size: 0.85rem;"
- >${ this.getCheckboxesFiltersLabel() }${ Object.keys( this.options.dataArgs )
+ >${ this.getCheckboxesFiltersLabel() }
${ Object.keys( this.options.dataArgs )
.map( ( key ) => this.getCheckboxHTML( key ) )
- .join( '' ) }
`;
+ .join( '' ) }`;
/**
* Get the HTML for a single checkbox.
@@ -72,7 +81,7 @@ customElements.define(
*/
getCheckboxHTML = ( key ) =>
``;
+ /**
+ * Get the line style of a data series.
+ *
+ * @param {string} key - The key of the data.
+ *
+ * @return {string} The line style: solid, dotted or dashed.
+ */
+ getLineStyle = ( key ) =>
+ [ 'dotted', 'dashed' ].includes(
+ this.options.dataArgs[ key ]?.lineStyle
+ )
+ ? this.options.dataArgs[ key ].lineStyle
+ : 'solid';
+
+ /**
+ * Get the SVG stroke attributes for a line style.
+ *
+ * Dots are zero-length dashes with round caps, so each one is a circle.
+ * A thin dotted line reads lighter than a solid one, so dots are 1.5
+ * line-widths wide and sit close together. Dashes are three
+ * line-widths long.
+ *
+ * @param {string} key - The key of the data.
+ * @param {number} strokeWidth - The width of the line.
+ *
+ * @return {string} The stroke attributes, including stroke-width.
+ */
+ getStrokeStyleAttributes = ( key, strokeWidth ) => {
+ switch ( this.getLineStyle( key ) ) {
+ case 'dotted': {
+ const dotWidth = strokeWidth * 1.5;
+ return `stroke-width="${ dotWidth }" stroke-dasharray="0 ${
+ dotWidth * 1.75
+ }" stroke-linecap="round" stroke-linejoin="round"`;
+ }
+ case 'dashed':
+ return `stroke-width="${ strokeWidth }" stroke-dasharray="${
+ strokeWidth * 3
+ } ${ strokeWidth * 2 }" stroke-linejoin="round"`;
+ default:
+ return `stroke-width="${ strokeWidth }"`;
+ }
+ };
+
+ /**
+ * Get the line sample shown under a legend label.
+ *
+ * @param {string} key - The key of the data.
+ *
+ * @return {string} The line sample SVG.
+ */
+ getLegendLineHTML = ( key ) =>
+ ``;
+
/**
* Get the filters label.
*
@@ -162,9 +237,10 @@ customElements.define(
return ` point.join( ',' ) )
.join( ' ' ) }" />`;
};
@@ -390,16 +466,20 @@ customElements.define(
( checkbox ) => {
checkbox.addEventListener( 'change', ( e ) => {
const el = e.target;
- const parentEl = el.parentElement;
- const checkboxColorEl = parentEl.querySelector(
+ const labelEl = el.closest( 'label' );
+ const checkboxColorEl = labelEl.querySelector(
'.prpl-chart-line-checkbox-color'
);
+ const legendLineEl = labelEl.querySelector(
+ '.prpl-chart-line-legend-line'
+ );
if ( el.checked ) {
this.options.showCharts.push(
el.getAttribute( 'name' )
);
checkboxColorEl.style.backgroundColor =
- parentEl.dataset.color;
+ labelEl.dataset.color;
+ legendLineEl.style.opacity = 1;
} else {
this.options.showCharts =
this.options.showCharts.filter(
@@ -408,6 +488,7 @@ customElements.define(
);
checkboxColorEl.style.backgroundColor =
'transparent';
+ legendLineEl.style.opacity = 0.35;
}
// Update the chart.
diff --git a/views/page-widgets/content-activity.php b/views/page-widgets/content-activity.php
index 3fd00b378..c5991addb 100644
--- a/views/page-widgets/content-activity.php
+++ b/views/page-widgets/content-activity.php
@@ -13,16 +13,19 @@
$prpl_activity_types = [
'publish' => [
- 'label' => \__( 'published', 'progress-planner' ),
- 'color' => 'var(--prpl-graph-color-2)',
+ 'label' => \__( 'published', 'progress-planner' ),
+ 'color' => 'var(--prpl-graph-color-2)',
+ 'lineStyle' => 'solid',
],
'update' => [
- 'label' => \__( 'updated', 'progress-planner' ),
- 'color' => 'var(--prpl-graph-color-3)',
+ 'label' => \__( 'updated', 'progress-planner' ),
+ 'color' => 'var(--prpl-graph-color-3)',
+ 'lineStyle' => 'dotted',
],
'delete' => [
- 'label' => \__( 'deleted', 'progress-planner' ),
- 'color' => 'var(--prpl-graph-color-4)',
+ 'label' => \__( 'deleted', 'progress-planner' ),
+ 'color' => 'var(--prpl-graph-color-4)',
+ 'lineStyle' => 'dashed',
],
];
@@ -50,8 +53,9 @@
);
$prpl_chart_options['dataArgs'][ $prpl_activity_type ] = [
- 'color' => $prpl_activity_data['color'],
- 'label' => $prpl_activity_data['label'],
+ 'color' => $prpl_activity_data['color'],
+ 'label' => $prpl_activity_data['label'],
+ 'lineStyle' => $prpl_activity_data['lineStyle'],
];
}