Repository: holoviz/holoviews

Issue:
Sankey - Specifying hv.Dimension with label attribute breaks the usage in .opts setting 'edge_color'
#### ALL software version info
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)
Ubuntu 18.04.6 LTS (Bionic Beaver)
- Python 3.9.12
- holoviews 1.15.0
- bokeh 2.4.3 
- pandas 1.4.3
- jupyterlab 2.1.4

#### Description of expected behavior and the observed behavior
When using hv.Dimension with the label attribute in kdims or vdims when generating a Sankey diagram, it should be possible to use the name when setting the 'edge_color' attribute in the options.
Currently using both the name or label of the dimension with label attribute fails. 

#### Complete, minimal, self-contained example code that reproduces the issue
```
import pandas as pd
import numpy as np
import holoviews as hv
hv.extension('bokeh')
data = [
    ["source1", "dest1", 3],
    ["source1", "dest2", 1],
]
test = pd.DataFrame(data, columns=["Source", "Dest", "Count"])

# without using the label parameter it works fine
hv.Sankey(
    test, 
    kdims=[
        hv.Dimension("Source"),
        hv.Dimension("Dest"),
    ], 
    vdims=["Count"],
).opts(
    edge_color = "Dest",
)

# when setting the label, using both name or label to set the 'edge_color' option fails 
hv.Sankey(
    test, 
    kdims=[
        hv.Dimension("Source"),
        hv.Dimension("Dest", label="Dest Label"),
    ], 
    vdims=["Count"],
).opts(
    edge_color = "Dest",
)

hv.Sankey(
    test, 
    kdims=[
        hv.Dimension("Source"),
        hv.Dimension("Dest", label="Dest Label"),
    ], 
    vdims=["Count"],
).opts(
    edge_color = "Dest Label",
)
```

#### Stack traceback and/or browser JavaScript console output
```hv.ipython.show_traceback()```
Traceback (most recent call last):

  File "/anaconda/envs/holoviews/lib/python3.9/site-packages/holoviews/plotting/bokeh/graphs.py", line 292, in _get_graph_properties
    group_style = self._apply_transforms(element, gdata, ranges, group_style, style_group)

  File "/anaconda/envs/holoviews/lib/python3.9/site-packages/holoviews/plotting/bokeh/element.py", line 1080, in _apply_transforms
    val = self._element_transform(v, element, ranges)

  File "/anaconda/envs/holoviews/lib/python3.9/site-packages/holoviews/plotting/bokeh/element.py", line 1051, in _element_transform
    return transform.apply(element, ranges=ranges, flat=True)

  File "/anaconda/envs/holoviews/lib/python3.9/site-packages/holoviews/util/transform.py", line 725, in apply
    eldim = dataset.get_dimension(lookup).name

AttributeError: 'NoneType' object has no attribute 'name'
#### Screenshots or screencasts of the bug in action



Discussion:

Resolving patch:
diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py
--- a/holoviews/plotting/bokeh/element.py
+++ b/holoviews/plotting/bokeh/element.py
@@ -1058,8 +1058,10 @@ def _apply_transforms(self, element, data, ranges, style, group=None):
             if isinstance(v, str):
                 if validate(k, v) == True:
                     continue
-                elif v in element or (isinstance(element, Graph) and v in element.nodes):
-                    v = dim(v)
+                elif v in element:
+                    v = dim(element.get_dimension(v))
+                elif isinstance(element, Graph) and v in element.nodes:
+                    v = dim(element.nodes.get_dimension(v))
                 elif any(d==v for d in self.overlay_dims):
                     v = dim([d for d in self.overlay_dims if d==v][0])
 


Test patch:
diff --git a/holoviews/tests/plotting/bokeh/test_sankey.py b/holoviews/tests/plotting/bokeh/test_sankey.py
--- a/holoviews/tests/plotting/bokeh/test_sankey.py
+++ b/holoviews/tests/plotting/bokeh/test_sankey.py
@@ -1,6 +1,8 @@
 import numpy as np
+import pandas as pd
 
-from holoviews.core.data import Dataset
+from holoviews import render
+from holoviews.core.data import Dataset, Dimension
 from holoviews.element import Sankey
 
 
@@ -81,3 +83,18 @@ def test_sankey_label_index(self):
         graph_renderer = plot.handles['glyph_renderer']
         self.assertTrue(renderers.index(graph_renderer)<renderers.index(quad_renderer))
         self.assertTrue(renderers.index(quad_renderer)<renderers.index(text_renderer))
+
+    def test_dimension_label(self):
+        # Ref: https://github.com/holoviz/holoviews/issues/5386
+        data = [
+            ["source1", "dest1", 3],
+            ["source1", "dest2", 1],
+        ]
+        df = pd.DataFrame(data, columns=["Source", "Dest", "Count"])
+
+        kdims = [Dimension("Source"), Dimension("Dest", label="Dest Label")]
+        plot = Sankey(df, kdims=kdims, vdims=["Count"])
+        plot = plot.opts(edge_color="Dest Label")
+
+        # To provoke the error in the issue
+        render(plot)