@@ -51,38 +51,38 @@ sqlpage_chart = (() => {
5151 /**
5252 * Aligns series data points by their x-axis categories, ensuring all series have data points
5353 * for each unique category. Missing values are filled with zeros. Categories are sorted.
54- *
54+ *
5555 * @example
5656 * // Input series:
5757 * const series = [
5858 * { name: "A", data: [{x: "Jan", y: 10}, {x: "Mar", y: 30}] },
5959 * { name: "B", data: [{x: "Jan", y: 20}, {x: "Feb", y: 25}] }
6060 * ];
61- *
61+ *
6262 * // Output after align_categories:
6363 * // [
6464 * // { name: "A", data: [{x: "Feb", y: 0}, {x: "Jan", y: 10}, {x: "Mar", y: 30}] },
6565 * // { name: "B", data: [{x: "Feb", y: 25}, {x: "Jan", y: 20}, {x: "Mar", y: 0}] }
6666 * // ]
67- *
67+ *
6868 * @param {Series[string][] } series - Array of series objects, each containing name and data points
6969 * @returns {Series[string][] } Aligned series with consistent categories across all series
7070 */
7171 function align_categories ( series ) {
7272 // Collect all unique categories
73- const categories = new Set ( series . flatMap ( s => s . data . map ( p => p . x ) ) ) ;
73+ const categories = new Set ( series . flatMap ( ( s ) => s . data . map ( ( p ) => p . x ) ) ) ;
7474 const sortedCategories = Array . from ( categories ) . sort ( ) ;
7575
7676 // Create a map of category -> value for each series
77- return series . map ( s => {
78- const valueMap = new Map ( s . data . map ( point => [ point . x , point . y ] ) ) ;
77+ return series . map ( ( s ) => {
78+ const valueMap = new Map ( s . data . map ( ( point ) => [ point . x , point . y ] ) ) ;
7979
8080 return {
8181 name : s . name ,
82- data : sortedCategories . map ( category => ( {
82+ data : sortedCategories . map ( ( category ) => ( {
8383 x : category ,
84- y : valueMap . get ( category ) || 0
85- } ) )
84+ y : valueMap . get ( category ) || 0 ,
85+ } ) ) ,
8686 } ;
8787 } ) ;
8888 }
@@ -160,7 +160,7 @@ sqlpage_chart = (() => {
160160 ? ( _val , { seriesIndex, w } ) => w . config . series [ seriesIndex ] . name
161161 : data . type === "pie"
162162 ? ( value , { seriesIndex, w } ) =>
163- `${ w . config . labels [ seriesIndex ] } : ${ value . toFixed ( ) } %`
163+ `${ w . config . labels [ seriesIndex ] } : ${ value . toFixed ( ) } %`
164164 : ( value ) => value . toLocaleString ( ) ,
165165 } ,
166166 fill : {
0 commit comments