query: # Average gestation period of genera, color-coded by order
  #defaultView:BubbleChart
  SELECT ?genus (AVG(?period) AS ?period) (SAMPLE(?label) AS ?genusLabel) (SAMPLE(?rgb) AS ?rgb)
  WHERE
  {
    {
      BIND("en" AS ?language).
      # find species with gestation period and convert to seconds (SI base unit)
      ?species p:P3063/psv:P3063 [
        wikibase:quantityAmount ?basePeriod;
        wikibase:quantityUnit [
          p:P2370/psv:P2370 [
            wikibase:quantityAmount ?unitPeriod;
            wikibase:quantityUnit wd:Q11574
          ]
        ]
      ].
      # convert back to days
      BIND((?basePeriod * ?unitPeriod)/(60*60*24) AS ?period).
      # find genus
      ?species wdt:P171* ?genus.
      ?genus wdt:P105 wd:Q34740.
      # find a good label – trivial name, else label, else “<no name>”
      OPTIONAL {
        ?genus wdt:P1843 ?trivialName.
        FILTER(LANG(?trivialName) = ?language).
      }
      OPTIONAL {
        ?genus rdfs:label ?genusLabel.
        FILTER(LANG(?genusLabel) = ?language).
      }
      BIND(IF(BOUND(?trivialName),?trivialName,IF(BOUND(?genusLabel),?genusLabel,"<no name>")) AS ?label).
      # find order
      ?genus wdt:P171* ?order.
      ?order wdt:P105 wd:Q36602.
      # choose “random but deterministic” color per order; you can play around with "-" (can be any string) to find a pleasing resulting color distribution
      BIND(UCASE(SUBSTR(SHA256(CONCAT("-", STR(?order))), 0, 6)) AS ?rgb).
    }
    UNION
    {
      # add scale
      VALUES (?genus ?period ?label) {
        (wd:Q23387 7 "week"@en)
        (wd:Q5151 30.436875 "month"@en)
        (wd:Q1643308 91.310625 "3 months"@en)
        (wd:Q2269240 182.62125 "6 months"@en)
        (wd:Q577 365.2425 "year"@en)
      }
      BIND("CCCCCC" AS ?rgb).
    }
  }
  GROUP BY ?genus