|
337 | 337 | const toEl = document.getElementById("stats-to"); |
338 | 338 | const applyRangeEl = document.getElementById("stats-apply-range"); |
339 | 339 | const customRangeEls = Array.from(document.querySelectorAll(".stats-custom-range")); |
| 340 | + function getCSSVar(name) { |
| 341 | + return getComputedStyle(document.documentElement).getPropertyValue(name).trim(); |
| 342 | + } |
| 343 | + |
| 344 | + function getChartColors() { |
| 345 | + return { |
| 346 | + textColor: getCSSVar('--color-chart-text'), |
| 347 | + cardBg: getCSSVar('--color-chart-bg'), |
| 348 | + borderColor: getCSSVar('--color-chart-border') |
| 349 | + }; |
| 350 | + } |
| 351 | + |
340 | 352 | const chartSeries = { |
341 | 353 | main: [ |
342 | | - { key: "participants_active", label: "Active participants", color: "#1f77b4" }, |
343 | | - { key: "participants_new", label: "New participants", color: "#17becf" }, |
344 | | - { key: "retained_365_participants", label: "Retained participants (365d+)", color: "#2ca02c" }, |
345 | | - { key: "new_users_replied_to_others", label: "New participants replying to others", color: "#ff9896" }, |
346 | | - { key: "topics_new", label: "New topics", color: "#9467bd" }, |
347 | | - { key: "topics_new_by_new_users", label: "New topics by new users", color: "#c5b0d5" }, |
348 | | - { key: "topics_new_with_attachments_by_new_users", label: "New topics with attachments by new users", color: "#c49c94" }, |
349 | | - { key: "topics_active", label: "Active topics", color: "#8c564b" }, |
350 | | - { key: "topics_new_with_contributor_activity", label: "New topics with contributor activity", color: "#e377c2" }, |
351 | | - { key: "topics_new_without_contributor_activity", label: "New topics without contributor activity", color: "#7f7f7f" }, |
352 | | - { key: "messages_total", label: "Total messages", color: "#ff7f0e" }, |
353 | | - { key: "messages_committers", label: "Messages by committers", color: "#d62728" }, |
354 | | - { key: "messages_contributors", label: "Messages by contributors", color: "#bcbd22" }, |
355 | | - { key: "messages_new_participants", label: "Messages by new participants", color: "#aec7e8" }, |
356 | | - { key: "topics_messages_avg", label: "Active topic avg msgs", color: "#1f77b4" }, |
357 | | - { key: "topics_messages_median", label: "Active topic median msgs", color: "#ff7f0e" }, |
358 | | - { key: "topics_messages_max", label: "Active topic max msgs", color: "#2ca02c" }, |
359 | | - { key: "topics_created_messages_avg", label: "New topic avg msgs", color: "#1f77b4" }, |
360 | | - { key: "topics_created_messages_median", label: "New topic median msgs", color: "#ff7f0e" }, |
361 | | - { key: "topics_created_messages_max", label: "New topic max msgs", color: "#2ca02c" }, |
362 | | - { key: "topic_longevity_avg_days", label: "Topic longevity avg days", color: "#9467bd" }, |
363 | | - { key: "topic_longevity_median_days", label: "Topic longevity median days", color: "#8c564b" }, |
364 | | - { key: "topic_longevity_max_days", label: "Topic longevity max days", color: "#d62728" }, |
365 | | - { key: "new_participants_lifetime_avg_days", label: "New participant lifetime avg days", color: "#1f77b4" }, |
366 | | - { key: "new_participants_lifetime_median_days", label: "New participant lifetime median days", color: "#ff7f0e" }, |
367 | | - { key: "new_participants_lifetime_max_days", label: "New participant lifetime max days", color: "#2ca02c" }, |
368 | | - { key: "retained_365_lifetime_avg_days", label: "Retained lifetime avg days", color: "#9467bd" }, |
369 | | - { key: "retained_365_lifetime_median_days", label: "Retained lifetime median days", color: "#8c564b" }, |
370 | | - { key: "new_participants_daily_avg_messages", label: "New participant daily avg msgs", color: "#1f77b4" }, |
371 | | - { key: "retained_365_daily_avg_messages", label: "Retained daily avg msgs", color: "#ff7f0e" } |
| 354 | + { key: "participants_active", label: "Active participants", color: getCSSVar('--color-chart-blue') }, |
| 355 | + { key: "participants_new", label: "New participants", color: getCSSVar('--color-chart-cyan') }, |
| 356 | + { key: "retained_365_participants", label: "Retained participants (365d+)", color: getCSSVar('--color-chart-green') }, |
| 357 | + { key: "new_users_replied_to_others", label: "New participants replying to others", color: getCSSVar('--color-chart-light-red') }, |
| 358 | + { key: "topics_new", label: "New topics", color: getCSSVar('--color-chart-purple') }, |
| 359 | + { key: "topics_new_by_new_users", label: "New topics by new users", color: getCSSVar('--color-chart-light-purple') }, |
| 360 | + { key: "topics_new_with_attachments_by_new_users", label: "New topics with attachments by new users", color: getCSSVar('--color-chart-light-brown') }, |
| 361 | + { key: "topics_active", label: "Active topics", color: getCSSVar('--color-chart-brown') }, |
| 362 | + { key: "topics_new_with_contributor_activity", label: "New topics with contributor activity", color: getCSSVar('--color-chart-pink') }, |
| 363 | + { key: "topics_new_without_contributor_activity", label: "New topics without contributor activity", color: getCSSVar('--color-chart-gray') }, |
| 364 | + { key: "messages_total", label: "Total messages", color: getCSSVar('--color-chart-orange') }, |
| 365 | + { key: "messages_committers", label: "Messages by committers", color: getCSSVar('--color-chart-red') }, |
| 366 | + { key: "messages_contributors", label: "Messages by contributors", color: getCSSVar('--color-chart-yellow-green') }, |
| 367 | + { key: "messages_new_participants", label: "Messages by new participants", color: getCSSVar('--color-chart-light-blue') }, |
| 368 | + { key: "topics_messages_avg", label: "Active topic avg msgs", color: getCSSVar('--color-chart-blue') }, |
| 369 | + { key: "topics_messages_median", label: "Active topic median msgs", color: getCSSVar('--color-chart-orange') }, |
| 370 | + { key: "topics_messages_max", label: "Active topic max msgs", color: getCSSVar('--color-chart-green') }, |
| 371 | + { key: "topics_created_messages_avg", label: "New topic avg msgs", color: getCSSVar('--color-chart-blue') }, |
| 372 | + { key: "topics_created_messages_median", label: "New topic median msgs", color: getCSSVar('--color-chart-orange') }, |
| 373 | + { key: "topics_created_messages_max", label: "New topic max msgs", color: getCSSVar('--color-chart-green') }, |
| 374 | + { key: "topic_longevity_avg_days", label: "Topic longevity avg days", color: getCSSVar('--color-chart-purple') }, |
| 375 | + { key: "topic_longevity_median_days", label: "Topic longevity median days", color: getCSSVar('--color-chart-brown') }, |
| 376 | + { key: "topic_longevity_max_days", label: "Topic longevity max days", color: getCSSVar('--color-chart-red') }, |
| 377 | + { key: "new_participants_lifetime_avg_days", label: "New participant lifetime avg days", color: getCSSVar('--color-chart-blue') }, |
| 378 | + { key: "new_participants_lifetime_median_days", label: "New participant lifetime median days", color: getCSSVar('--color-chart-orange') }, |
| 379 | + { key: "new_participants_lifetime_max_days", label: "New participant lifetime max days", color: getCSSVar('--color-chart-green') }, |
| 380 | + { key: "retained_365_lifetime_avg_days", label: "Retained lifetime avg days", color: getCSSVar('--color-chart-purple') }, |
| 381 | + { key: "retained_365_lifetime_median_days", label: "Retained lifetime median days", color: getCSSVar('--color-chart-brown') }, |
| 382 | + { key: "new_participants_daily_avg_messages", label: "New participant daily avg msgs", color: getCSSVar('--color-chart-blue') }, |
| 383 | + { key: "retained_365_daily_avg_messages", label: "Retained daily avg msgs", color: getCSSVar('--color-chart-orange') } |
372 | 384 | ], |
373 | 385 | depth: [ |
374 | | - { key: "topics_messages_avg", label: "Avg messages", color: "#1f77b4" }, |
375 | | - { key: "topics_messages_median", label: "Median messages", color: "#ff7f0e" }, |
376 | | - { key: "topics_messages_max", label: "Max messages", color: "#2ca02c" } |
| 386 | + { key: "topics_messages_avg", label: "Avg messages", color: getCSSVar('--color-chart-blue') }, |
| 387 | + { key: "topics_messages_median", label: "Median messages", color: getCSSVar('--color-chart-orange') }, |
| 388 | + { key: "topics_messages_max", label: "Max messages", color: getCSSVar('--color-chart-green') } |
377 | 389 | ], |
378 | 390 | created_depth: [ |
379 | | - { key: "topics_created_messages_avg", label: "Avg messages", color: "#1f77b4" }, |
380 | | - { key: "topics_created_messages_median", label: "Median messages", color: "#ff7f0e" }, |
381 | | - { key: "topics_created_messages_max", label: "Max messages", color: "#2ca02c" } |
| 391 | + { key: "topics_created_messages_avg", label: "Avg messages", color: getCSSVar('--color-chart-blue') }, |
| 392 | + { key: "topics_created_messages_median", label: "Median messages", color: getCSSVar('--color-chart-orange') }, |
| 393 | + { key: "topics_created_messages_max", label: "Max messages", color: getCSSVar('--color-chart-green') } |
382 | 394 | ], |
383 | 395 | message_breakdown: [ |
384 | | - { key: "messages_committers", label: "Committers", color: "#d62728" }, |
385 | | - { key: "messages_contributors_non_committers", label: "Contributors (non-committers)", color: "#bcbd22" }, |
386 | | - { key: "messages_new_participants", label: "New participants", color: "#aec7e8" }, |
387 | | - { key: "messages_regular_participants", label: "Regular participants", color: "#7f7f7f" } |
| 396 | + { key: "messages_committers", label: "Committers", color: getCSSVar('--color-chart-red') }, |
| 397 | + { key: "messages_contributors_non_committers", label: "Contributors (non-committers)", color: getCSSVar('--color-chart-yellow-green') }, |
| 398 | + { key: "messages_new_participants", label: "New participants", color: getCSSVar('--color-chart-light-blue') }, |
| 399 | + { key: "messages_regular_participants", label: "Regular participants", color: getCSSVar('--color-chart-gray') } |
388 | 400 | ], |
389 | 401 | attachments: [ |
390 | | - { key: "topics_new_no_attachments", label: "No attachments", color: "#9e9e9e" }, |
391 | | - { key: "topics_new_with_attachments_no_commitfest", label: "Attachment, not commitfest", color: "#1f77b4" }, |
392 | | - { key: "topics_new_commitfest_in_progress", label: "Commitfest in progress", color: "#ff7f0e" }, |
393 | | - { key: "topics_new_commitfest_abandoned", label: "Commitfest rejected", color: "#d62728" }, |
394 | | - { key: "topics_new_commitfest_committed", label: "Commitfest committed", color: "#2ca02c" } |
| 402 | + { key: "topics_new_no_attachments", label: "No attachments", color: getCSSVar('--color-chart-light-gray') }, |
| 403 | + { key: "topics_new_with_attachments_no_commitfest", label: "Attachment, not commitfest", color: getCSSVar('--color-chart-blue') }, |
| 404 | + { key: "topics_new_commitfest_in_progress", label: "Commitfest in progress", color: getCSSVar('--color-chart-orange') }, |
| 405 | + { key: "topics_new_commitfest_abandoned", label: "Commitfest rejected", color: getCSSVar('--color-chart-red') }, |
| 406 | + { key: "topics_new_commitfest_committed", label: "Commitfest committed", color: getCSSVar('--color-chart-green') } |
395 | 407 | ], |
396 | 408 | new_topic_attachments: [ |
397 | | - { key: "topics_new_by_new_users_no_attachments", label: "New users, no attachments", color: "#bdbdbd" }, |
398 | | - { key: "topics_new_by_new_users_with_attachments", label: "New users, attachments", color: "#9ecae1" }, |
399 | | - { key: "topics_new_by_existing_users_no_attachments", label: "Existing users, no attachments", color: "#636363" }, |
400 | | - { key: "topics_new_by_existing_users_with_attachments", label: "Existing users, attachments", color: "#3182bd" } |
| 409 | + { key: "topics_new_by_new_users_no_attachments", label: "New users, no attachments", color: getCSSVar('--color-chart-silver') }, |
| 410 | + { key: "topics_new_by_new_users_with_attachments", label: "New users, attachments", color: getCSSVar('--color-chart-steel-blue') }, |
| 411 | + { key: "topics_new_by_existing_users_no_attachments", label: "Existing users, no attachments", color: getCSSVar('--color-chart-dark-gray') }, |
| 412 | + { key: "topics_new_by_existing_users_with_attachments", label: "Existing users, attachments", color: getCSSVar('--color-chart-medium-blue') } |
401 | 413 | ], |
402 | 414 | longevity: [ |
403 | | - { key: "topic_longevity_avg_days", label: "Avg days", color: "#9467bd" }, |
404 | | - { key: "topic_longevity_median_days", label: "Median days", color: "#8c564b" }, |
405 | | - { key: "topic_longevity_max_days", label: "Max days", color: "#d62728" } |
| 415 | + { key: "topic_longevity_avg_days", label: "Avg days", color: getCSSVar('--color-chart-purple') }, |
| 416 | + { key: "topic_longevity_median_days", label: "Median days", color: getCSSVar('--color-chart-brown') }, |
| 417 | + { key: "topic_longevity_max_days", label: "Max days", color: getCSSVar('--color-chart-red') } |
406 | 418 | ], |
407 | 419 | participant_lifetime: [ |
408 | | - { key: "new_participants_lifetime_avg_days", label: "New avg days", color: "#1f77b4" }, |
409 | | - { key: "new_participants_lifetime_median_days", label: "New median days", color: "#ff7f0e" }, |
410 | | - { key: "new_participants_lifetime_max_days", label: "New max days", color: "#2ca02c" }, |
411 | | - { key: "retained_365_lifetime_avg_days", label: "Retained avg days", color: "#9467bd" }, |
412 | | - { key: "retained_365_lifetime_median_days", label: "Retained median days", color: "#8c564b" } |
| 420 | + { key: "new_participants_lifetime_avg_days", label: "New avg days", color: getCSSVar('--color-chart-blue') }, |
| 421 | + { key: "new_participants_lifetime_median_days", label: "New median days", color: getCSSVar('--color-chart-orange') }, |
| 422 | + { key: "new_participants_lifetime_max_days", label: "New max days", color: getCSSVar('--color-chart-green') }, |
| 423 | + { key: "retained_365_lifetime_avg_days", label: "Retained avg days", color: getCSSVar('--color-chart-purple') }, |
| 424 | + { key: "retained_365_lifetime_median_days", label: "Retained median days", color: getCSSVar('--color-chart-brown') } |
413 | 425 | ], |
414 | 426 | new_participant_rate: [ |
415 | | - { key: "new_participants_daily_avg_messages", label: "New participants", color: "#1f77b4" }, |
416 | | - { key: "retained_365_daily_avg_messages", label: "Retained 365d+", color: "#ff7f0e" } |
| 427 | + { key: "new_participants_daily_avg_messages", label: "New participants", color: getCSSVar('--color-chart-blue') }, |
| 428 | + { key: "retained_365_daily_avg_messages", label: "Retained 365d+", color: getCSSVar('--color-chart-orange') } |
417 | 429 | ], |
418 | 430 | participant_retention: [ |
419 | | - { key: "retained_365_participants", label: "Retained 365d+", color: "#ff7f0e" }, |
420 | | - { key: "participants_new_not_retained_365", label: "New (not retained)", color: "#1f77b4" } |
| 431 | + { key: "retained_365_participants", label: "Retained 365d+", color: getCSSVar('--color-chart-orange') }, |
| 432 | + { key: "participants_new_not_retained_365", label: "New (not retained)", color: getCSSVar('--color-chart-blue') } |
421 | 433 | ], |
422 | 434 | retention_milestones: [ |
423 | | - { key: "retention_q1", label: "3m+", color: "#1f77b4" }, |
424 | | - { key: "retention_q2", label: "6m+", color: "#ff7f0e" }, |
425 | | - { key: "retention_q4", label: "1y+", color: "#2ca02c" }, |
426 | | - { key: "retention_q6", label: "1.5y+", color: "#d62728" }, |
427 | | - { key: "retention_q8", label: "2y+", color: "#9467bd" }, |
428 | | - { key: "retention_q10", label: "2.5y+", color: "#8c564b" }, |
429 | | - { key: "retention_q12", label: "3y+", color: "#e377c2" }, |
430 | | - { key: "retention_q16", label: "4y+", color: "#7f7f7f" }, |
431 | | - { key: "retention_q20", label: "5y+", color: "#17becf" } |
| 435 | + { key: "retention_q1", label: "3m+", color: getCSSVar('--color-chart-blue') }, |
| 436 | + { key: "retention_q2", label: "6m+", color: getCSSVar('--color-chart-orange') }, |
| 437 | + { key: "retention_q4", label: "1y+", color: getCSSVar('--color-chart-green') }, |
| 438 | + { key: "retention_q6", label: "1.5y+", color: getCSSVar('--color-chart-red') }, |
| 439 | + { key: "retention_q8", label: "2y+", color: getCSSVar('--color-chart-purple') }, |
| 440 | + { key: "retention_q10", label: "2.5y+", color: getCSSVar('--color-chart-brown') }, |
| 441 | + { key: "retention_q12", label: "3y+", color: getCSSVar('--color-chart-pink') }, |
| 442 | + { key: "retention_q16", label: "4y+", color: getCSSVar('--color-chart-gray') }, |
| 443 | + { key: "retention_q20", label: "5y+", color: getCSSVar('--color-chart-cyan') } |
432 | 444 | ] |
433 | 445 | }; |
434 | 446 |
|
|
791 | 803 | return Math.max(320, Math.floor(width)); |
792 | 804 | } |
793 | 805 |
|
794 | | - function getChartColors() { |
795 | | - const isDark = document.documentElement.dataset.theme === 'dark'; |
796 | | - return { |
797 | | - textColor: isDark ? '#e2e8f0' : '#0f172a', |
798 | | - cardBg: isDark ? '#111827' : '#ffffff', |
799 | | - borderColor: isDark ? '#1f2937' : '#cdd5e7' |
800 | | - }; |
801 | | - } |
802 | | - |
803 | 806 | function buildLineSpec(intervals, width, height, enabledSeries) { |
804 | 807 | const chartColors = getChartColors(); |
805 | 808 | const points = intervals.flatMap(row => ( |
|
0 commit comments