Extension:Chart/pt-br

Category:GPL licensed extensions/pt-br
Manual de extensões do MediaWiki
Chart
Estado da versão: estávelCategory:Stable extensions/pt-br
Implementação Marcação Category:Tag extensions/pt-br
Descrição Renders charts
Autor(es) TODO
Política de
compatibilidade
Master maintains backward compatibility.
MediaWiki >= 1.44
Modifica o banco
de dados
Não
Licença GNU GPL (Licença Pública Geral) 3.0 ou superior
Download Category:Extensions in Wikimedia version control/pt-br
README
  • $wgChartRequestSizeLimit
  • $wgChartProgressiveEnhancement
  • $wgChartTransformsEnabled
  • $wgChartServiceUrl
  • $wgChartCliPath
Quarterly downloads 28 (Ranked 70th)
Para traduzir a extensão Chart, verifique sua disponibilidade no translatewiki.net
Problemas Tarefas em aberto · Relatar um bug
Category:All extensions/pt-br

A extensão Chart fornece recursos básicos de visualização de dados interativos projetados para substituir a extensão Graph e, possivelmente, também a extensão EasyTimeline. Essa extensão está atualmente em desenvolvimento para as wikis da Wikimedia. Veja Extension:Chart/Project para obter mais detalhes sobre o processo de desenvolvimento.

Essa extensão suporta os seguintes tipos de gráficos:

  • Gráfico de linhas
  • Gráfico de área
  • Gráfico de barras
  • Gráfico de pizza

Instalação

A extensão Chart requer a instalação da extensão JsonConfig, bem como o download da biblioteca JavaScript (na realidade, TypeScript) Chart Renderer.

Veja o arquivo README.md no repositório para obter as instruções completas de configuração.

For Wikimedia production usage, see Wikitech:Kubernetes/Deployments for general instructions on service deployments.

Como usar

Para renderizar um gráfico, você deve definir uma definição de gráfico para associar à fonte de dados que deseja renderizar. A chart definition is structured as a relatively simple JSON file; see Extension:Chart/Specification for the syntax details.

Todos os gráficos deste exemplo podem ser renderizados a partir da mesma fonte de dados: Data:Chart_Example_Data.tab, um conjunto de dados fictício. Exemplos de conteúdo para essas páginas podem ser encontrados no diretório sample.

{
    "license": "CC0-1.0",
    "version": 1,
    "source": "Chart Example Data.tab",
    "type": "line",
    "title": {
        "en": "Example Chart Title"
    },
    "xAxis": {
        "title": {
        	"en": "Example X Axis Title"
        },
        "format": "none"
    },
    "yAxis": {
        "title": {
            "en": "Example Y Axis Title"
        },
        "format": "none"
    },
    "mediawikiCategories": [
        {
            "name": "Example category",
            "sort": "Its sortkey"
        }
    ],
    "transform": {
        "module": "Optional lua module for data transforms",
        "function": "transform_func",
        "args": {
            "arg_name": "arg_value"
        }
    }
}

Depois que um gráfico é definido, você pode facilmente renderizá-lo usando a função #chart. Nesse caso, os dados do gráfico são definidos em Data:Chart_Example_Data.tab e o gráfico em si é definido em Data:Example.Line.chart:

{{#chart:Example.Line.chart}}

Personalização

No momento a personalização dos gráficos é limitada. A esperança é que, após testes, discussões e avaliações, possam ser encontradas soluções de personalização que não comprometam a acessibilidade, a renderização específica do dispositivo ou a segurança.

Dimensionamento

Atualmente, os gráficos ocupam a largura total de onde é colocado.

O objetivo final é garantir que os gráficos possam ser renderizados de forma legível, independentemente do dispositivo em que forem lidos; consulte T376845 para obter mais detalhes.

Temas

Atualmente, os gráficos estão restritos a uma única paleta de cores padrão. Essa paleta foi cuidadosamente projetada tendo em mente a acessibilidade. O raciocínio por trás dessas escolhas de cores pode ser explorado em T369863.

Alguns gráficos exigem temas de cores específicos, por exemplo, para representar dados relacionados a partidos políticos. Ainda há uma questão em aberto sobre a melhor forma de oferecer suporte a esse tipo de personalização sem comprometer a capacidade de uso dos leitores com necessidades de acessibilidade (por exemplo, daltonismo).

Note of caution

Note, while chart's currently render SVG output which can be styled via TemplateStyles, please note that styling associated SVG elements should not be considered stable as it may change at any time. Please do not rely on CSS to alter chart appearance as this may result in non-functional charts in future or may interfere with accessibility features that change font size and features such as dark mode.

Internacionalização

Os gráficos só podem ser incorporados no idioma de conteúdo da wiki; portanto, por exemplo, a string de consulta "uselang" (por exemplo, ?uselang=es) não afetará o gráfico.

O formato do gráfico suporta a definição de texto como título e rótulos em diferentes idiomas, de modo que o mesmo gráfico possa ser usado em wikis de diferentes idiomas. Veja este exemplo de um gráfico com suporte para vários idiomas exibido numa wiki em espanhol.

Problemas conhecidos

Types of chart

For all charts, data is expected to be arranged in columns, with the first column representing the x-axis and the following columns representing series on the y-axis.

Line

%supportDate0102030405009/09/199326/09/199308/10/199322/10/1993ElvesEntsOrcsHobbitsTrollsExample Line Chart

Raw data

Bar

%supportDate0102030405009/09/199326/09/199308/10/199322/10/1993ElvesEntsOrcsHobbitsTrollsExample Bar Chart

Raw data

Area

%supportDate02040608010009/09/199326/09/199319/10/1993ElvesEntsOrcsHobbitsTrollsExample Area Chart

Raw data

Pie

Pie charts are a special chart type, and data sources may require modification to be rendered appropriately.

When reading data, any non-number columns (e.g., the x-axis) will be discarded, and the sum of all rows will be represented on the chart.

For example, where multiple rows depict values for A, B, and C on numerous dates, e.g., January 1st and January 2nd, the pie chart segment for A will represent the sum of all A's row values across those dates.

ElvesEntsOrcsHobbitsTrollsElvesEntsOrcsHobbitsTrollsExample Pie Chart

Raw data

Finding existing charts

Charts that can be used in articles live on Wikimedia Commons and can be tracked using MediaWiki categories.

This query can be used as a proxy to find charts that others have made and contribute translations.

The set of wiki pages that use charts on any particular wiki can be found in the category whose name is defined at MediaWiki:chart-render-category e MediaWiki:Chart-error-category (Category:Pages using the Chart extension e Category:Pages using the Chart extension with rendering errors on this wiki). Please make sure to connect your wiki categories to d:Q131382738 and d:Q131406605 to make the interwiki search easier.

Migrating from the Graph extension

Please see the category pages with disabled graphs in various languages for old graphs that need to be migrated to the Charts extension. Some have however already been deleted without replacing them with new charts. The list can be compared with an archived list of the first 200 out of 23,811 English Wikipedia pages with disabled graphs from 2023, soon after the templates were added to that category, and corresponding in other languages.

Technical documentation

Given the problems with Extension:Graph, all the decisions regarding the new extension have been carefully considered, with the hope of building trust and confidence in its replacement.

So far, the technical decisions are documented in the code repository in the doc/adr folder.

Error Monitoring

Errors with client side chart rendering will be logged to logstash.

Tools for producing the charts

There are several conceivable methods to semi-automatically produce and edit the charts and their tabular data:

  • The script graphDataImport can be used in the web browser to extract data from existing graph wikicode, and convert it to a .tab page, and a .chart definition page.
  • Generative AI can be prompted to extract data from existing graph wikicode and tables, and convert it to .tab and .chart pages and generate new wikicode, according to given specifications. It can also provide translation of titles, and be utilized to extend and update the .tab page with new data.
  • The gadget TabularImportExport can convert Excel and .csv files to and from the .tab pages. You can activate it via your Commons preferences.
  • The JSON "edit as table" user interface (part of the Jsonconfig extension) is available from the .tab edit page.
  • Some bots can periodically import statistics from the web, or from existing Wikipedia graphs, to .tab or .chart pages, upon request. Such bots include DPLA bot and SLiuBot.
  • GraphBot ports english wikipedia graphs to charts.

See also

Category:Extensions used on Wikimedia/pt-br#Chart/pt-br
Category:All extensions/pt-br Category:Extensions in Wikimedia version control/pt-br Category:Extensions used on Wikimedia/pt-br Category:GPL licensed extensions/pt-br Category:LinksUpdateComplete extensions/pt-br Category:PageSaveComplete extensions/pt-br Category:Pages using the Chart extension Category:ParserFirstCallInit extensions/pt-br Category:Stable extensions/pt-br Category:Tag extensions/pt-br