通过时钟位置、短划线和数字增强我的雷达织女星图

问题描述 投票:0回答:1

_嗨,我想修改我的雷达织女星图如下:

  • 在 12 点钟位置设置一 (1) 个位置
  • 顺时针旋转从1到12
  • 使用破折号作为径向规则
  • 在点旁边显示数字(我已成功显示!;)

我尝试了很多事情但没有成功。预先感谢
这是我的 pbix 文件

    {
  "description": "Magnitude - Radar. To show values of multiple variables.",
  "padding": 15,
  "autosize": "fit",
  "background": "white",
  "signals": [
    {
      "name": "width",
      "value": 400,
      "update": "containerSize()[0]-30"
    },
    {
      "name": "height",
      "value": 400,
      "update": "containerSize()[1]-30"
    },
    {
      "name": "titleText",
      "value": "Radar"
    },
    {
      "name": "subTitleText",
      "value": "To show values of multiple variables"
    },
    {
      "name": "titleOffset",
      "description": "Blank space between the subtitle and the chart, px",
      "value": 20
    },
    {
      "name": "subtitlePadding",
      "description": "Blank space between the title and the subtitle, px",
      "value": 10
    },
    {
      "name": "titleColor",
      "value": "#333333"
    },
    {
      "name": "color1",
      "init": "pbiColor(0)"
    },
    {
      "name": "labelColor",
      "value": "#666666"
    },
    {
      "name": "titleFontSize",
      "value": 24
    },
    {
      "name": "subtitleFontSize",
      "value": 16
    },
    {
      "name": "labelAxisFontSize",
      "value": 24
    },
    {
      "name": "labelFontSize",
      "value": 20
    },
    {"name": "labelOffset", "value": 5},
    {
      "name": "lineStrokeWidth",
      "value": 2
    },
    {
      "name": "areaFillOpacity",
      "value": 0.5
    },
    {
      "name": "radius",
      "update": "width / 3"
    },
    {
      "name": "centerx",
      "update": "width / 2"
    },
    {
      "name": "centery",
      "update": "height / 2"
    }
  ],
  "data": [
    {"name": "dataset"},
    {
      "name": "data-categories",
      "source": "dataset",
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["Month"]
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "angular",
      "type": "point",
      "range": {"signal": "[-PI, PI]"},
      "padding": 0.5,
      "domain": {
        "data": "dataset",
        "field": "Month"
      }
    },
    {
      "name": "radial",
      "type": "linear",
      "range": [
        {"signal": "0"},
        {"signal": "radius"}
      ],
      "zero": true,
      "nice": false,
      "domain": {
        "data": "dataset",
        "field": "Conso USAGEX A sur Plan 1"
      },
      "domainMin": 0
    }
  ],
  "title": {
    "text": {"signal": "titleText"},
    "anchor": "start",
    "offset": {"signal": "titleOffset"},
    "color": {"signal": "titleColor"},
    "fontSize": {
      "signal": "titleFontSize"
    },
    "subtitle": {
      "signal": "subTitleText"
    },
    "subtitlePadding": {
      "signal": "subtitlePadding"
    },
    "subtitleFontSize": {
      "signal": "subtitleFontSize"
    }
  },
  "axes": [],
  "marks": [
    {
      "type": "line",
      "name": "line-category",
      "from": {"data": "dataset"},
      "zindex": 1,
      "encode": {
        "enter": {
          "interpolate": {
            "value": "linear-closed"
          },
          "x": {
            "signal": "centerx + scale('radial', datum['Conso USAGEX A sur Plan 1']) * cos(scale('angular', datum['Month']))"
          },
          "y": {
            "signal": "centery + scale('radial', datum['Conso USAGEX A sur Plan 1']) * sin(scale('angular', datum['Month']))"
          },
          "stroke": {
            "signal": "color1"
          },
          "strokeWidth": {
            "signal": "lineStrokeWidth"
          },
          "fill": {"signal": "color1"},
          "fillOpacity": {
            "signal": "areaFillOpacity"
          }
        }
      }
    },
    {
      "type": "symbol",
      "from": {"data": "dataset"},
      "encode": {
        "enter": {
          "x": {
            "signal": "centerx + scale('radial', datum['Conso USAGEX A sur Plan 1']) * cos(scale('angular', datum['Month']))"
          },
          "y": {
            "signal": "centery + scale('radial', datum['Conso USAGEX A sur Plan 1']) * sin(scale('angular', datum['Month']))"
          },
          "fill": {"signal": "color1"},
          "size": {"value": 50}
        }
      },
      "zindex": 1
    },
    {
      "type": "text",
      "name": "value-text",
      "from": {"data": "line-category"},
      "encode": {
        "enter": {
          "x": {"signal": "datum.x"},
          "y": {"signal": "datum.y"},
          "text": {
            "signal": "datum['Conso USAGEX A sur Plan 1']"
          },
          "align": {"value": "center"},
          "baseline": {
            "value": "middle"
          },
          "fill": {"value": "black"}
        }
      }
    },
    {
      "type": "rule",
      "name": "radial-grid",
      "from": {
        "data": "data-categories"
      },
      "zindex": 0,
      "encode": {
        "enter": {
          "x": {"signal": "centerx"},
          "y": {"signal": "centery"},
          "x2": {
            "signal": "centerx + radius * cos(scale('angular', datum['Month']))"
          },
          "y2": {
            "signal": "centery + radius * sin(scale('angular', datum['Month']))"
          },
          "stroke": {
            "value": "lightgray"
          },
          "strokeWidth": {"value": 1}
        }
      }
    },
    {
      "type": "text",
      "name": "Category-label",
      "from": {
        "data": "data-categories"
      },
      "zindex": 1,
      "encode": {
        "enter": {
          "x": {
            "signal": "centerx + (radius + 5) * cos(scale('angular', datum['Month']))"
          },
          "y": {
            "signal": "centery + (radius + 5) * sin(scale('angular', datum['Month']))"
          },
          "text": {"field": "Month"},
          "align": [
            {
              "test": "abs(scale('angular', datum['Month'])) > PI / 2",
              "value": "right"
            },
            {"value": "left"}
          ],
          "baseline": [
            {
              "test": "scale('angular', datum['Month']) > 0",
              "value": "top"
            },
            {
              "test": "scale('angular', datum['Month']) == 0",
              "value": "middle"
            },
            {"value": "bottom"}
          ],
          "fill": {
            "signal": "labelColor"
          },
          "fontSize": {
            "signal": "labelFontSize"
          }
        }
      }
    },
    {
      "type": "line",
      "name": "outer-line",
      "from": {"data": "radial-grid"},
      "encode": {
        "enter": {
          "interpolate": {
            "value": "linear-closed"
          },
          "x": {"field": "x2"},
          "y": {"field": "y2"},
          "stroke": {
            "value": "lightgray"
          },
          "strokeWidth": {"value": 1}
        }
      }
    }
  ]
}
powerbi visualization powerbi-desktop vega deneb
1个回答
0
投票

{
  "description": "Magnitude - Radar. To show values of multiple variables.",
  "padding": 15,
  "autosize": "fit",
  "background": "white",
  "signals": [
    {
      "name": "width",
      "value": 400,
      "update": "containerSize()[0]-30"
    },
    {
      "name": "height",
      "value": 400,
      "update": "containerSize()[1]-30"
    },
    {
      "name": "titleText",
      "value": "Radar"
    },
    {
      "name": "subTitleText",
      "value": "To show values of multiple variables"
    },
    {
      "name": "titleOffset",
      "description": "Blank space between the subtitle and the chart, px",
      "value": 20
    },
    {
      "name": "subtitlePadding",
      "description": "Blank space between the title and the subtitle, px",
      "value": 10
    },
    {
      "name": "titleColor",
      "value": "#333333"
    },
    {
      "name": "color1",
      "init": "pbiColor(0)"
    },
    {
      "name": "labelColor",
      "value": "#666666"
    },
    {
      "name": "titleFontSize",
      "value": 24
    },
    {
      "name": "subtitleFontSize",
      "value": 16
    },
    {
      "name": "labelAxisFontSize",
      "value": 24
    },
    {
      "name": "labelFontSize",
      "value": 20
    },
    {"name": "labelOffset", "value": 5},
    {
      "name": "lineStrokeWidth",
      "value": 2
    },
    {
      "name": "areaFillOpacity",
      "value": 0.5
    },
    {
      "name": "radius",
      "update": "width / 3"
    },
    {
      "name": "centerx",
      "update": "width / 2"
    },
    {
      "name": "centery",
      "update": "height / 2"
    }
  ],
  "data": [
    {"name": "dataset"},
    {
      "name": "data-categories",
      "source": "dataset",
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["Month"]
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "angular",
      "type": "point",
      "range": {
        "signal": "[-PI+1.3, PI+1.3]"
      },
      "padding": 0.5,
      "domain": {
        "data": "dataset",
        "field": "Month",
        "sort": {
          "op": "sum",
          "field": "Month",
          "order": "ascending"
        }
      }
    },
    {
      "name": "radial",
      "type": "linear",
      "range": [
        {"signal": "0"},
        {"signal": "radius"}
      ],
      "zero": true,
      "nice": false,
      "domain": {
        "data": "dataset",
        "field": "Conso USAGEX A sur Plan 1"
      },
      "domainMin": 0
    }
  ],
  "title": {
    "text": {"signal": "titleText"},
    "anchor": "start",
    "offset": {"signal": "titleOffset"},
    "color": {"signal": "titleColor"},
    "fontSize": {
      "signal": "titleFontSize"
    },
    "subtitle": {
      "signal": "subTitleText"
    },
    "subtitlePadding": {
      "signal": "subtitlePadding"
    },
    "subtitleFontSize": {
      "signal": "subtitleFontSize"
    }
  },
  "axes": [],
  "marks": [
    {
      "type": "line",
      "sort": {"field": "test"},
      "name": "line-category",
      "transform": [
        {
          "type": "formula",
          "as": "test",
          "expr": "datum.datum.Month"
        }
      ],
      "from": {"data": "dataset"},
      "zindex": 1,
      "encode": {
        "enter": {
          "interpolate": {
            "value": "linear-closed"
          },
          "x": {
            "signal": "centerx + scale('radial', datum['Conso USAGEX A sur Plan 1']) * cos(scale('angular', datum['Month']))"
          },
          "y": {
            "signal": "centery + scale('radial', datum['Conso USAGEX A sur Plan 1']) * sin(scale('angular', datum['Month']))"
          },
          "stroke": {
            "signal": "color1"
          },
          "strokeWidth": {
            "signal": "lineStrokeWidth"
          },
          "fill": {"signal": "color1"},
          "fillOpacity": {
            "signal": "areaFillOpacity"
          }
        }
      }
    },
    {
      "type": "symbol",
      "from": {"data": "dataset"},
      "encode": {
        "enter": {
          "x": {
            "signal": "centerx + scale('radial', datum['Conso USAGEX A sur Plan 1']) * cos(scale('angular', datum['Month']))"
          },
          "y": {
            "signal": "centery + scale('radial', datum['Conso USAGEX A sur Plan 1']) * sin(scale('angular', datum['Month']))"
          },
          "fill": {"signal": "color1"},
          "size": {"value": 50}
        }
      },
      "zindex": 1
    },
    {
      "type": "text",
      "name": "value-text",
      "from": {"data": "line-category"},
      "encode": {
        "enter": {
          "x": {"signal": "datum.x"},
          "y": {"signal": "datum.y"},
          "text": {
            "signal": "datum['Conso USAGEX A sur Plan 1']"
          },
          "align": {"value": "center"},
          "baseline": {
            "value": "middle"
          },
          "fill": {"value": "black"}
        }
      }
    },
    {
      "type": "rule",
      "name": "radial-grid",
      "from": {
        "data": "data-categories"
      },
      "zindex": 0,
      "encode": {
        "enter": {
          "x": {"signal": "centerx"},
          "y": {"signal": "centery"},
          "x2": {
            "signal": "centerx + radius * cos(scale('angular', datum['Month']))"
          },
          "y2": {
            "signal": "centery + radius * sin(scale('angular', datum['Month']))"
          },
          "stroke": {
            "value": "lightgray"
          },
          "strokeWidth": {"value": 1}, "strokeDash":{"value":[4,4]}
        }
      }
    },
    {
      "type": "text",
      "name": "Category-label",
      "from": {
        "data": "data-categories"
      },
      "zindex": 1,
      "encode": {
        "enter": {
          "x": {
            "signal": "centerx + (radius + 5) * cos(scale('angular', datum['Month']))"
          },
          "y": {
            "signal": "centery + (radius + 5) * sin(scale('angular', datum['Month']))"
          },
          "text": {"field": "Month"},
          "align": [
            {
              "test": "abs(scale('angular', datum['Month'])) > PI / 2",
              "value": "right"
            },
            {"value": "left"}
          ],
          "baseline": [
            {
              "test": "scale('angular', datum['Month']) > 0",
              "value": "top"
            },
            {
              "test": "scale('angular', datum['Month']) == 0",
              "value": "middle"
            },
            {"value": "bottom"}
          ],
          "fill": {
            "signal": "labelColor"
          },
          "fontSize": {
            "signal": "labelFontSize"
          }
        }
      }
    },
    {
      "type": "line",
      "name": "outer-line",
      "sort": {"field": "sort"},
      "from": {"data": "radial-grid"},
      "transform": [
        {
          "type": "formula",
          "as": "sort",
          "expr": "datum.datum.datum.Month"
        }
      ],
      "encode": {
        "enter": {
          "interpolate": {
            "value": "linear-closed"
          },
          "x": {"field": "x2"},
          "y": {"field": "y2"},
          "stroke": {
            "value": "lightgray"
          },
          "strokeWidth": {"value": 1}
        }
      }
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.