3liz / lizmap-documentation

Full documentation for Lizmap Web Client and Lizmap Plugin
20 stars 40 forks source link

Labels for dataviz bar charts, javascript provided #174

Open ygorigor opened 4 years ago

ygorigor commented 4 years ago

If it's possible add an option to display labels on or inside bars for a bar charts

Gustry commented 4 years ago

Are you using LWC 3.4? It might be already possible with the JSON description.

ygorigor commented 4 years ago

@Gustry can you point me to right direction, where I can find a json template?

Gustry commented 4 years ago

Sorry, I was fast ;-) AFAIK, you are using LWC 3.4 right? If you really want to enjoy the latest features of LWC 3.4, you need to have the latest version of the QGIS plugin version. The version published on plugins.qgis.org is only <= 3.3, it's the master branch on the repository.

There is also the dev branch on this repository. Either use git to have it, or have a look on https://packages.3liz.org/ to have the dev version. This versions enables the 3.4 features.

Read here https://github.com/3liz/lizmap-plugin#lizmap-qgis-plugin

ygorigor commented 4 years ago

Thanks

Gustry commented 4 years ago

Let me know if it answers your question. But I think @mdouchin asks this new JSON configuration for this.

ygorigor commented 4 years ago

@Gustry I tried dev version of QGIS plugin. There is an option to change chart layout with a JSON, but it's not possible to show labels on bars, or I can't figure out how to do this.

Gustry commented 4 years ago

An example from @mdouchin :

            "user_layout": {
              "xaxis": {
                  "showticklabels": "False"
              },
              "yaxis": {
                  "showticklabels": "False"
              },
              ...
            }

and he gave this link: https://plotly.com/javascript/reference/#layout

Ticket in the documentation : https://github.com/3liz/lizmap-documentation/issues/159

@mdouchin Can you tell us if it's possible or not with this new widget?

mdouchin commented 4 years ago

I think the labels for bars cannot be changed with this JSON, since this JSON is used to override the layout, not the plot config. For the labels in bars, I think we should:

NB: To keep references for the layout, here are some examples:

You can combine these examples to fit your needs.

ygorigor commented 3 years ago

I found a solution with Java script so I will close it

pcav commented 3 years ago

Would you mind sharing your js? Thanks.

ygorigor commented 3 years ago

Would you mind sharing your js? Thanks.

@pcav this is script that I use

lizMap.events.on({ 'datavizplotloaded': function(e) { var update_style = { 'cliponaxis': false, 'textposition': 'auto', 'insidetextanchor': 'middle', 'texttemplate': '%{value}', 'insidetextfont': { 'color': 'white' }, 'outsidetextfont': { 'color': 'black' } }; Plotly.restyle(e.id, update_style); } });

pcav commented 3 years ago

Thanks

mdouchin commented 3 years ago

Thanks We should add it in the documentation.

Gustry commented 3 years ago

Ticket transferred into the documentation