MIERUNE / qgis-plugx-plugin

QGIS to Illustrator with PlugX
GNU General Public License v2.0
3 stars 0 forks source link

[Diagram] technical research #48

Open Kanahiro opened 12 months ago

Kanahiro commented 12 months ago

image

bordoray commented 12 months ago
image

Memo

# get attributes renderer
lyr[0].diagramRenderer().diagramSettings()[0].categoryAttributes
>>> [' "code" /100', 'rand(0,100)', 'rand(0,100)']

#get legends
lyr[0].diagramRenderer().diagramSettings()[0].categoryLabels
>>> ['one', 'two', 'three']

#get colors
lyr[0].diagramRenderer().diagramSettings()[0].categoryColors
>>> [<PyQt5.QtGui.QColor object at 0x000001F7E7F96EB0>, <PyQt5.QtGui.QColor object at 0x000001F7C9EC6C10>, <PyQt5.QtGui.QColor object at 0x000001F7C9EC6CF0>]

#get size
lyr[0].diagramRenderer().diagramSettings()[0].size
>>> PyQt5.QtCore.QSizeF(15.0, 15.0)
bordoray commented 12 months ago

To detect diagram

lyr[0].diagramsEnabled()
True
nodiag[0].diagramsEnabled()
False
bordoray commented 11 months ago

Tentative process idea:

Issue : may work only for centroid placed diagram

image
bordoray commented 11 months ago

Tentative JSON diagram_{n}.json

{
    "layer": "population",
    "type": "pie_chart",
    "size": "15.0",
    "legends" : ['legend1','legend2','legend3'],
    "colors" : ['#232323','#999999','#aaaaaa'],
    "attributes": [
        {
            "x": 420744.52217771474,
            "y": 4034541.0965687246,
            "legend1": 151,
            "legend2": 250,
            "legend3": 55,
        },
        {
            "x": 420744.52217771474,
            "y": 4034541.0965687246,
            "legend1": 251,
            "legend2": 180,
            "legend3": 65,
        },
    ...
]
bordoray commented 11 months ago

To detect diagram type

lyr[0].diagramRenderer().diagram()
<qgis._core.QgsPieDiagram object at 0x000002625B1D9DC0>
lyr[0].diagramRenderer().diagram()
<qgis._core.QgsHistogramDiagram object at 0x000002625B1D9C10>
lyr[0].diagramRenderer().diagram()
<qgis._core.QgsStackedBarDiagram object at 0x000002625B1D9DC0>
lyr[0].diagramRenderer().diagram()
<qgis._core.QgsTextDiagram object at 0x000002625B1D9C10>
Kanahiro commented 11 months ago

It is technically difficult to support Diagrams because:

So, set a priority for this very lower.