Forum Discussion

JST15's avatar
JST15
Icon for Helper I rankHelper I
1 year ago
Solved

Creating a 3 Axis Line Chart

Hello! In the attached or below, you'll see 3 axis line chart created in excel. It's a line chart using the secondary and then overlapping another line chart on top of that. It works but is a bit slo...
  • lbendlin's avatar
    lbendlin
    1 year ago

    Here's something to get you going.  Still needs coloring, smoothing etc.

     

    The key is the "resolve"  instruction at the bottom.

     

    {
      "data": {
        "name": "dataset"
      },
      "encoding": {
            "x": {
              "field": "PERIOD_YEAR",
              "type": "nominal"
            }
      },
      "layer": [
        {
          "mark": {
            "type": "line"
          },
          "encoding": {
            "y": {
              "field": "QTY ",
              "type": "quantitative"
            }
          }
        },
        {
          "mark": {
            "type": "line"
          },
          "encoding": {
            "y": {
              "field": "GM % ",
              "type": "quantitative"
            }
          }
        },
        {
          "mark": {
            "type": "line"
          },
          "encoding": {
            "y": {
              "field": "GM $/unit ",
              "type": "quantitative",
              "axis": {"offset":50}
            }
          }
        }
      ],
      "resolve": {"scale": {"y": "independent"}}
    }