<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Another Deneb query - 2 data fields on one bar chart in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2462263#M4458</link>
    <description>&lt;P&gt;EDIT: I think that this solution doesn't stack properly and series are overlaid. I'm having a think about that one.&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="284738" data-lia-user-login="jonespossibly" class="lia-mention lia-mention-user"&gt;jonespossibly&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;It's not entirely clear what you're asking for - perhaps a sketch or mockup may help for future questions.&lt;/P&gt;
&lt;P&gt;I've taken a guess though, and hopefully what I've attempted might still get you there if it's not quite what you were envisioning.&lt;/P&gt;
&lt;P&gt;If you want to use the inbuilt legend functionality, you're best splitting into layers and either using two different encoding channels for the colour, (e.g. &lt;FONT face="courier new,courier"&gt;color&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;fill&lt;/FONT&gt;), or specifying an &lt;A href="https://vega.github.io/vega-lite/docs/resolve.html" target="_self"&gt;independent scale resolution&lt;/A&gt; for each color channel so that the legend treats them separately (I've gone for this option in my spec below).&lt;/P&gt;
&lt;P&gt;You will also need to specify a range for each &lt;FONT face="courier new,courier"&gt;color&lt;/FONT&gt; encoding's scale, as they will resolve the same &lt;FONT face="courier new,courier"&gt;color&lt;/FONT&gt; values if treated as &lt;FONT face="courier new,courier"&gt;nominal&lt;/FONT&gt; (due to them being the same across series).&lt;/P&gt;
&lt;P&gt;I've also specified a manual title for each &lt;FONT face="courier new,courier"&gt;legend&lt;/FONT&gt; so that it's apparent as to what's what, as Vega-Lite will just title it with the field you're using if not specified:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"A": 10, "B": 20, "Z": "poop", "created": "2022/01/01"},
      {"A": 10, "B": 10, "Z": "moop", "created": "2022/01/01"},
      {"A": 10, "B": 5, "Z": "doop", "created": "2022/01/01"},
      {"A": 13, "B": 12, "Z": "poop", "created": "2022/02/01"},
      {"A": 33, "B": 10, "Z": "moop", "created": "2022/02/01"},
      {"A": 0, "B": 5, "Z": "doop", "created": "2022/02/01"},
      {"A": 13, "B": 5, "Z": "poop", "created": "2022/03/01"},
      {"A": 3, "B": 2, "Z": "moop", "created": "2022/03/01"},
      {"A": 20, "B": 7, "Z": "doop", "created": "2022/03/01"}
    ]
  },
  "resolve": {"scale": {"color": "independent"}},
  "layer": [
    {
      "mark": "bar",
      "encoding": {
        "x": {"timeUnit": "month", "field": "created", "type": "ordinal"},
        "y": {"field": "A", "type": "quantitative"},
        "color": {"field": "Z", "legend": {"title": "Z (A Series)"}}
      }
    },
    {
      "mark": "bar",
      "encoding": {
        "x": {"timeUnit": "month", "field": "created", "type": "ordinal"},
        "y": {"field": "B", "type": "quantitative"},
        "color": {
          "field": "Z",
          "legend": {"title": "Z (B Series)"},
          "scale": {"range": ["red", "green", "blue"]}
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Apr 2022 23:03:19 GMT</pubDate>
    <dc:creator>dm-p</dc:creator>
    <dc:date>2022-04-18T23:03:19Z</dc:date>
    <item>
      <title>Another Deneb query - 2 data fields on one bar chart</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2457205#M4447</link>
      <description>&lt;P&gt;I have cause to render two different data fields on to the same bars in the same chart.&lt;/P&gt;&lt;P&gt;so for instance the x axis will be date&lt;/P&gt;&lt;P&gt;y axis should have field 'A' and field 'B' stacked on top of each other for the given date.&lt;/P&gt;&lt;P&gt;Also both fields are grouped by another field, 'Z'.&lt;/P&gt;&lt;P&gt;Groupings for A should be shown separately from Groupings for B in the legend,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Getting A to work is simple:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values":[
      {"A":10, "B":20, "Z":"poop", "created":"2022/01/01"},
      {"A":10, "B":10, "Z":"moop", "created":"2022/01/01"},
      {"A":10, "B":5, "Z":"doop", "created":"2022/01/01"},
      {"A":13, "B":12, "Z":"poop", "created":"2022/02/01"},
      {"A":33, "B":10, "Z":"moop", "created":"2022/02/01"},
      {"A":0, "B":5, "Z":"doop", "created":"2022/02/01"},
      {"A":13, "B":5, "Z":"poop", "created":"2022/03/01"},
      {"A":3, "B":2, "Z":"moop", "created":"2022/03/01"},
      {"A":20, "B":7, "Z":"doop", "created":"2022/03/01"}
      ]
    },
  "mark": "bar",
  "encoding": {
    "x": {
      "timeUnit": "month",
      "field": "created",
      "type": "ordinal"
    },
    "y": {
      "field":"A",
      "type": "quantitative"
    },
    "color": {
      "field": "Z",
      "type": "nominal"
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;how would i go about adding the figures from 'B' onto each bar, in different colours and presented on the legend on separate rows?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 11:23:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2457205#M4447</guid>
      <dc:creator>jonespossibly</dc:creator>
      <dc:date>2022-04-14T11:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Another Deneb query - 2 data fields on one bar chart</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2462263#M4458</link>
      <description>&lt;P&gt;EDIT: I think that this solution doesn't stack properly and series are overlaid. I'm having a think about that one.&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="284738" data-lia-user-login="jonespossibly" class="lia-mention lia-mention-user"&gt;jonespossibly&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;It's not entirely clear what you're asking for - perhaps a sketch or mockup may help for future questions.&lt;/P&gt;
&lt;P&gt;I've taken a guess though, and hopefully what I've attempted might still get you there if it's not quite what you were envisioning.&lt;/P&gt;
&lt;P&gt;If you want to use the inbuilt legend functionality, you're best splitting into layers and either using two different encoding channels for the colour, (e.g. &lt;FONT face="courier new,courier"&gt;color&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;fill&lt;/FONT&gt;), or specifying an &lt;A href="https://vega.github.io/vega-lite/docs/resolve.html" target="_self"&gt;independent scale resolution&lt;/A&gt; for each color channel so that the legend treats them separately (I've gone for this option in my spec below).&lt;/P&gt;
&lt;P&gt;You will also need to specify a range for each &lt;FONT face="courier new,courier"&gt;color&lt;/FONT&gt; encoding's scale, as they will resolve the same &lt;FONT face="courier new,courier"&gt;color&lt;/FONT&gt; values if treated as &lt;FONT face="courier new,courier"&gt;nominal&lt;/FONT&gt; (due to them being the same across series).&lt;/P&gt;
&lt;P&gt;I've also specified a manual title for each &lt;FONT face="courier new,courier"&gt;legend&lt;/FONT&gt; so that it's apparent as to what's what, as Vega-Lite will just title it with the field you're using if not specified:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"A": 10, "B": 20, "Z": "poop", "created": "2022/01/01"},
      {"A": 10, "B": 10, "Z": "moop", "created": "2022/01/01"},
      {"A": 10, "B": 5, "Z": "doop", "created": "2022/01/01"},
      {"A": 13, "B": 12, "Z": "poop", "created": "2022/02/01"},
      {"A": 33, "B": 10, "Z": "moop", "created": "2022/02/01"},
      {"A": 0, "B": 5, "Z": "doop", "created": "2022/02/01"},
      {"A": 13, "B": 5, "Z": "poop", "created": "2022/03/01"},
      {"A": 3, "B": 2, "Z": "moop", "created": "2022/03/01"},
      {"A": 20, "B": 7, "Z": "doop", "created": "2022/03/01"}
    ]
  },
  "resolve": {"scale": {"color": "independent"}},
  "layer": [
    {
      "mark": "bar",
      "encoding": {
        "x": {"timeUnit": "month", "field": "created", "type": "ordinal"},
        "y": {"field": "A", "type": "quantitative"},
        "color": {"field": "Z", "legend": {"title": "Z (A Series)"}}
      }
    },
    {
      "mark": "bar",
      "encoding": {
        "x": {"timeUnit": "month", "field": "created", "type": "ordinal"},
        "y": {"field": "B", "type": "quantitative"},
        "color": {
          "field": "Z",
          "legend": {"title": "Z (B Series)"},
          "scale": {"range": ["red", "green", "blue"]}
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 23:03:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2462263#M4458</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2022-04-18T23:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Another Deneb query - 2 data fields on one bar chart</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2462282#M4459</link>
      <description>&lt;P&gt;Here's another approach, using a single legend, but using a fold transform to unpivot, and a calculate transform to assign a unique 'grouping' value that can be coloured accordingly. This solution uses a single mark also:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"A": 10, "B": 20, "Z": "poop", "created": "2022/01/01"},
      {"A": 10, "B": 10, "Z": "moop", "created": "2022/01/01"},
      {"A": 10, "B": 5, "Z": "doop", "created": "2022/01/01"},
      {"A": 13, "B": 12, "Z": "poop", "created": "2022/02/01"},
      {"A": 33, "B": 10, "Z": "moop", "created": "2022/02/01"},
      {"A": 0, "B": 5, "Z": "doop", "created": "2022/02/01"},
      {"A": 13, "B": 5, "Z": "poop", "created": "2022/03/01"},
      {"A": 3, "B": 2, "Z": "moop", "created": "2022/03/01"},
      {"A": 20, "B": 7, "Z": "doop", "created": "2022/03/01"}
    ]
  },
  "transform": [
    {"timeUnit": "month", "field": "created", "as": "month"},
    {"fold": ["A", "B"], "as": ["series", "value"]},
    {"calculate": "datum.series + ': ' + datum.Z", "as": "grouping"}
  ],
  "mark": "bar",
  "encoding": {
    "x": {"timeUnit": "month", "field": "created", "type": "ordinal"},
    "y": {"field": "value", "type": "quantitative"},
    "color": {"field": "grouping"}
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;A href="https://vega.github.io/editor/#/url/vega-lite/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykBaADZ04JAKyUAVhDYA7EABoQAEySYUqUMSSCGcCGgDaoAIJoAjAAYlAITQAmayABaaEDjZscikFABOcGpwym6O9vYEluaR5iAAvgqmFk52qFZKrugInt5K-oGYwaGW4TEx8YkgZmkpaGIZbso5PvlBIehhEVHlCUlpAMy2FvYN6B5eLQFtxaUlPZXV-YMgqekubtkTeVOF7SCdkV2xvVVotaj16+hNW747RR0lXUcVfebLqZeZ7s3bBQ-7J6RfrzPofByjECbXJ3f57A6WEFRV6nVCOIaoADskJuMNauxmXSRxwAugkQJg-EhZBAAGZsPwIIygTA0BBwACqsjoGzk9B8tJocEEe3xRSUSAMWT5MBR9JFRlOQxJEqlhhAEDgfiFBiU2l0cBAZMqUB0UAYgiCjTUDAQlE12v0AAIANROgDkqA9rqdqkwtsorlVbjIfjYDBwNFkZHiKqhSD8AGs3EwEz44LIoGxlFGY5oQAAPNAstmc7mYXmyflKQXC0X3EJKTAATxwhvQDJzsh0FRAzeLIFrCvQ+r0PhbbbcAEcGNTWepWaRe1nBAyB0O9qHw5Ho-E4nEgA" target="_self"&gt;Editor link&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 23:29:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2462282#M4459</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2022-04-18T23:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Another Deneb query - 2 data fields on one bar chart</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2462724#M4463</link>
      <description>&lt;P&gt;a haaa!&amp;nbsp; Excellent.&amp;nbsp; I think this one will work.&amp;nbsp; I'll give it a go shortly with the real data, but the poops, moops and doops look right in this.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 06:45:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Another-Deneb-query-2-data-fields-on-one-bar-chart/m-p/2462724#M4463</guid>
      <dc:creator>jonespossibly</dc:creator>
      <dc:date>2022-04-19T06:45:54Z</dc:date>
    </item>
  </channel>
</rss>

