pyblish-base icon indicating copy to clipboard operation
pyblish-base copied to clipboard

Charts and plots via logging

Open mottosso opened this issue 9 years ago • 0 comments

Goal

image

Provide support for drawing custom charts and plots via the logging mechanism.

Implementation

The log mechanism is used to output text and can be extended to include support for graphics. Instances of charts and plots can replace the arbitrary string and provide relevant data points for its visualisation in a GUI.

class MyPlugin(pyblish.api.Plugin):
  def process(self, context):
    data = [
      {"value": 2, "color": "blue"},
      {"value": 5, "color": "green"},
      {"value": 1.7, "color": "red"},
    ]

    pie = pyblish.api.PieChart(data)
    bars = pyblish.api.BarChart(data)

    self.log.info("Processing context..")
    self.log.info(pie)
    self.log.debug(bars)

    data = {
      "label": "My First dataset",
      "fillColor": "rgba(220,220,220,0.2)",
      "strokeColor": "rgba(220,220,220,1)",
      "pointColor": "rgba(220,220,220,1)",
      "pointStrokeColor": "#fff",
      "pointHighlightFill": "#fff",
      "pointHighlightStroke": "rgba(220,220,220,1)",
      "data": [65, 59, 80, 81, 56, 55, 40]
    }

    self.log.warning(pyblish.api.LineChart(data))

On the Qt side, a chart is drawn either via the Qt Graphics View framework or the Canvas element with help from Chart.js.

In a console, either the pure data can be written out or discarded based on some setting.

mottosso avatar Nov 15 '15 14:11 mottosso