: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}} |
cases | Template: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:
- ✅ basic 2-element pie chart
- read json
- calculate value with -1
- generate html
- new css + tests
- provide dumb labels (just v%)
- ✅ colors in json
- ✅ 1st value >= 50%
- ✅ custom labels support
- ✅ pie size from 'meta' param (options json)
- ✅ pl formatting for numbers?
- ✅ support undefined value (instead of -1)
- ✅ undefined in any order
- ✅ scale values to 100% (autoscale)
- ✅ order values clockwise (not left/right)
- ✅ multi-cut pie
- ✅ sanitize user values
- ✅ auto colors
- ✅ function to get color by number (for custom legend)
- ✅ remember and show autoscaled data
- ✅ generate a legend
- ✅ 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
- ✅Support templates in colors
- ✅Example for PoC Template:Sandbox/Nux/enumParams/test
- ✅Prototype/PoC Module:Sandbox/Nux
- ✅Implement in sandbox.
- ✅Support both JSON and enum-params.
- ✅Proper support for other (compatibility, but without a formatting bug).
- ✅Remove {{t|Piechart/sandbox}} call and just invoke the module directly.
- ✅Allow passing custom meta JSON.
- ✅Replace Template:Pie chart/sandbox for easier testing and stuff...
- ✅Add more test cases
- ✅Remove Template:Pie chart/sandbox2 from cases
- ✅Side-by-side view of test cases (flex = shorter)
- ✅Simple cases for
{{{thumb}}} param - ✅Footer (expected not to be supported by sandbox template yet)
- ✅Numbers that are over 100 (autoscale; expected not to be supported by current template yet)
- ✅Re-think colors
- ✅Support numbers over 100
- ✅calculate sum before settings labels (sum > 100 => autoscale)
- ✅sum > 100 => use $v in labels
- ✅support setting $v in label1..n params
- ✅generate meta-JSON from classic params (similar function to parseEnumParams)
- ✅Support
{{{footer}}} ; used in e.g.: - * :en:Jharkhand#Religion
- * :en:.br#Usage_statistics
- * :en:New_Zealand_wine#Marlborough
- ✅Re-integrate with plwiki.
- ✅Finalize?
- ✅Replace Module:Piechart code with its sandbox.
- ✅Replace Template:Piechart code with its sandbox.
- ✅Docs update?
- ✅Merge
- ✅Template:Piechart/sandbox/styles.css → Template: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])
- ✅Template:Pie chart/sandbox → Template: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])
- ✅→ 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])
- ✅Template:Pie chart (+ Pie chart/styles.css)
- (?) ✅Redirect Template:Piechart to Template:Pie chart
Hopes and dreams
= On route =
- itemTpl support (just "template" or "label-tpl" or "tpl"?)
- add new option to meta
- default value of the template: "$label: $auto"
- Add support for new value:
- $auto ($v)
- $rawNumber ($d)
- $formattedNumber (part of $v)
- $percentNumber ($p)
- shorthand support?
- $rawNumber == $raw == $value
- $formattedNumber == $formatted == $format
- $percentNumber == $percent
- Report unknown $x in template during preview.
- Report when $x is not supported in current mode (autoscale off).
- Docs:
- Use longer versions in new examples.
- Remove $v, $d, $p from docs (only keeping it for backward compatibility).
- 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 =
- legend2: customization
- (?) custom head
- (?) validation of input
- check if required values are present
- message showing whole entry, when entry is invalid
- pre-sanitize values?
- sane info when JSON fails? Maybe dump JSON and show example with quotes-n-all...
- (?) option to sort entries by value