:en:User:Nux/pie chart - todo#Hopes and dreams

__toc__

Links

class="wikitable"

! Wiki !! Type !! Link

rowspan="4" | enwiki

| css

{{User:Nux/cmp|Template:Pie chart/styles.css|Template:Pie chart/sandbox/styles.css}}
tpl{{User:Nux/cmp|Template:Pie chart|Template:Pie chart/sandbox}}
mod{{User:Nux/cmp|Module:Piechart|Module:Piechart/sandbox}}
casesTemplate:Pie chart/testcases
rowspan="4" | plwiki

| css

{{User:Nux/links-pl|Template:Piechart/style.css}}
tpl{{User:Nux/links-pl|Template:Piechart}}
mod{{User:Nux/links-pl|Moduł:Piechart}}
cases/tests{{User:Nux/links-pl|Moduł:Piechart/test}}

= Tracing =

Pie chart 1.0

Pie chart for pl.wiki and later for en.wiki.

PoC and some helpers: https://github.com/Eccenux/css-piechart

TODO / features:

  1. ✅ basic 2-element pie chart
  2. read json
  3. calculate value with -1
  4. generate html
  5. new css + tests
  6. provide dumb labels (just v%)
  7. ✅ colors in json
  8. ✅ 1st value >= 50%
  9. ✅ custom labels support
  10. ✅ pie size from 'meta' param (options json)
  11. ✅ pl formatting for numbers?
  12. ✅ support undefined value (instead of -1)
  13. ✅ undefined in any order
  14. ✅ scale values to 100% (autoscale)
  15. ✅ order values clockwise (not left/right)
  16. ✅ multi-cut pie
  17. ✅ sanitize user values
  18. ✅ auto colors
  19. ✅ function to get color by number (for custom legend)
  20. ✅ remember and show autoscaled data
  21. ✅ generate a legend
  22. ✅ simple legend positioning by (flex-)direction

Pie chart 2.0

Integration with :en:Template:Pie chart. Support for enumerated template parameters (i.e. value1..n, label1..n, color1..n).

Merge Talk: https://en.wikipedia.org/wiki/Wikipedia:Templates_for_discussion/Log/2025_January_30#c-Rjjiii-20250215200500-Nux-20250215163400

  1. ✅Support templates in colors
  2. ✅Example for PoC Template:Sandbox/Nux/enumParams/test
  3. ✅Prototype/PoC Module:Sandbox/Nux
  4. ✅Implement in sandbox.
  5. ✅Support both JSON and enum-params.
  6. ✅Proper support for other (compatibility, but without a formatting bug).
  7. ✅Remove {{t|Piechart/sandbox}} call and just invoke the module directly.
  8. ✅Allow passing custom meta JSON.
  9. ✅Replace Template:Pie chart/sandbox for easier testing and stuff...
  10. ✅Add more test cases
  11. ✅Remove Template:Pie chart/sandbox2 from cases
  12. ✅Side-by-side view of test cases (flex = shorter)
  13. ✅Simple cases for {{{thumb}}} param
  14. ✅Footer (expected not to be supported by sandbox template yet)
  15. ✅Numbers that are over 100 (autoscale; expected not to be supported by current template yet)
  16. ✅Re-think colors
  17. ✅Support numbers over 100
  18. ✅calculate sum before settings labels (sum > 100 => autoscale)
  19. ✅sum > 100 => use $v in labels
  20. ✅support setting $v in label1..n params
  21. ✅generate meta-JSON from classic params (similar function to parseEnumParams)
  22. ✅Support {{{footer}}}; used in e.g.:
  23. * :en:Jharkhand#Religion
  24. * :en:.br#Usage_statistics
  25. * :en:New_Zealand_wine#Marlborough
  26. ✅Re-integrate with plwiki.
  27. ✅Finalize?
  28. ✅Replace Module:Piechart code with its sandbox.
  29. ✅Replace Template:Piechart code with its sandbox.
  30. ✅Docs update?
  31. ✅Merge
  32. Template:Piechart/sandbox/styles.cssTemplate:Piechart/styles.css ([https://en.wikipedia.org/wiki/Special:ComparePages?page1=Template%3APiechart%2Fstyles.css&rev1=&page2=Template%3APiechart%2Fsandbox%2Fstyles.css&rev2=&action=&unhide= diff])
  33. Template:Pie chart/sandboxTemplate:Pie chart (+ Piechart/styles.css) ([https://en.wikipedia.org/wiki/Special:ComparePages?page1=Template%3APie+chart&rev1=&page2=Template%3APie+chart%2Fsandbox&rev2=&action=&unhide= diff])
  34. ✅→ Template:Pie chart/styles.css ([https://en.wikipedia.org/wiki/Special:ComparePages?page1=Template%3APiechart%2Fstyles.css&rev1=&page2=Template%3APie+chart%2Fstyles.css&rev2=&action=&unhide= diff])
  35. Template:Pie chart (+ Pie chart/styles.css)
  36. (?) ✅Redirect Template:Piechart to Template:Pie chart

Hopes and dreams

= On route =

  1. itemTpl support (just "template" or "label-tpl" or "tpl"?)
  2. add new option to meta
  3. default value of the template: "$label: $auto"
  4. Add support for new value:
  5. $auto ($v)
  6. $rawNumber ($d)
  7. $formattedNumber (part of $v)
  8. $percentNumber ($p)
  9. shorthand support?
  10. $rawNumber == $raw == $value
  11. $formattedNumber == $formatted == $format
  12. $percentNumber == $percent
  13. Report unknown $x in template during preview.
  14. Report when $x is not supported in current mode (autoscale off).
  15. Docs:
  16. Use longer versions in new examples.
  17. Remove $v, $d, $p from docs (only keeping it for backward compatibility).
  18. Check adding labels in value mode after changes... [https://en.wikipedia.org/wiki/Template_talk:Pie_chart#c-Novarupta-20250601085500-Template_adds_incorrect_percentages_to_labels Module was adding percentages to labels unexpectedly]

= Maybe =

  1. legend2: customization
  2. (?) custom head
  3. (?) validation of input
  4. check if required values are present
  5. message showing whole entry, when entry is invalid
  6. pre-sanitize values?
  7. sane info when JSON fails? Maybe dump JSON and show example with quotes-n-all...
  8. (?) option to sort entries by value