Diferencia entre revisiones de «MediaWiki:Gadget-ec-make-pie.js»
Ir a la navegación
Ir a la búsqueda
m (tweak size) |
m (tweak size) |
||
(No se muestran 2 ediciones intermedias del mismo usuario) | |||
Línea 15: | Línea 15: | ||
mw.loader.using('ext.gadget.make-pie').then(function make_pie(require) { |
mw.loader.using('ext.gadget.make-pie').then(function make_pie(require) { |
||
// find a place for it |
// find a place for it |
||
const place = document.querySelector('.infobox'). |
const place = document.querySelector('.infobox td').parentElement.insertCell(0) |
||
place.rowSpan = 2 |
|||
place.setAttribute('style', 'max-width: 50mm; ') |
place.setAttribute('style', 'max-width: 50mm; min-width: 50mm; vertical-align: middle;') |
||
document.querySelector('.infobox th').colSpan += 1 |
|||
// make the pie |
// make the pie |
||
const make = require('ext.gadget.make-pie'); |
const make = require('ext.gadget.make-pie'); |
||
const pie = make('test', |
const pie = make('test', 75)// TODO: what radius? |
||
place.append(pie) |
place.append(pie) |
||
// fill in the data |
// fill in the data |
Revisión actual - 14:09 15 abr 2020
///# show graphs on editors corner mw.hook( 'wikipage.content' ).add(function make_pie() { if (mw.config.get('wgPageName') != "Coppermind:Editor's_Corner") return console.warn('gadget:', 'ec-make-pie') const cats = { stub: 'Stubs', part: 'Partially complete articles', good: 'Articles nearing completion', done: 'Complete articles', } // PIE CHART: mw.loader.using('ext.gadget.make-pie').then(function make_pie(require) { // find a place for it const place = document.querySelector('.infobox td').parentElement.insertCell(0) place.rowSpan = 2 place.setAttribute('style', 'max-width: 50mm; min-width: 50mm; vertical-align: middle;') document.querySelector('.infobox th').colSpan += 1 // make the pie const make = require('ext.gadget.make-pie'); const pie = make('test', 75)// TODO: what radius? place.append(pie) // fill in the data function add_wedge(name, icon, fill) { const count = +document.querySelector('[title="Category:'+ cats[name] +'"]').textContent if(!count) return pie.add_data_entry(count, name, icon, fill) } add_wedge('done', '⬤', '#DFD') add_wedge('good', '◕', '#FEB') add_wedge('part', '◒', 'white') add_wedge('stub', '◔', '#DDD') pie.render() }) // END: PIE CHART // done });