We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Stacked area only show last label
@Pill-GZ found a bug (and a solution!) for the legend of a stacked area plot only showing the last label. See https://discourse.holoviz.org/t/how-to-add-legend-for-stacked-area-plots/2193


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `holoviews/element/chart.py`
Content:
```
1 import numpy as np
2 import param
3 
4 from ..core import util
5 from ..core import Dimension, Dataset, Element2D, NdOverlay, Overlay
6 from ..core.dimension import process_dimensions
7 from ..core.data import GridInterface
8 from .geom import Rectangles, Points, VectorField # noqa: backward compatible import
9 from .selection import Selection1DExpr, Selection2DExpr
10 
11 
12 class Chart(Dataset, Element2D):
13     """
14     A Chart is an abstract baseclass for elements representing one or
15     more independent and dependent variables defining a 1D coordinate
16     system with associated values. The independent variables or key
17     dimensions map onto the x-axis while the dependent variables are
18     usually mapped to the location, height or spread along the
19     y-axis. Any number of additional value dimensions may be
20     associated with a Chart.
21 
22     If a chart's independent variable (or key dimension) is numeric
23     the chart will represent a discretely sampled version of the
24     underlying continuously sampled 1D space. Therefore indexing along
25     this variable will automatically snap to the closest coordinate.
26 
27     Since a Chart is a subclass of a Dataset it supports the full set
28     of data interfaces but usually each dimension of a chart represents
29     a column stored in a dictionary, array or DataFrame.
30     """
31 
32     kdims = param.List(default=[Dimension('x')], bounds=(1,2), doc="""
33         The key dimension(s) of a Chart represent the independent
34         variable(s).""")
35 
36     group = param.String(default='Chart', constant=True)
37 
38     vdims = param.List(default=[Dimension('y')], bounds=(1, None), doc="""
39         The value dimensions of the Chart, usually corresponding to a
40         number of dependent variables.""")
41 
42     # Enables adding index if 1D array like data is supplied
43     _auto_indexable_1d = True
44 
45     _max_kdim_count = 1 # Remove once kdims has bounds=(1,1) instead of warning
46     __abstract = True
47 
48     def __init__(self, data, kdims=None, vdims=None, **params):
49         params.update(process_dimensions(kdims, vdims))
50         if len(params.get('kdims', [])) == self._max_kdim_count + 1:
51             self.param.warning('Chart elements should only be supplied a single kdim')
52         super(Chart, self).__init__(data, **params)
53 
54     def __getitem__(self, index):
55         return super(Chart, self).__getitem__(index)
56 
57 
58 class Scatter(Selection2DExpr, Chart):
59     """
60     Scatter is a Chart element representing a set of points in a 1D
61     coordinate system where the key dimension maps to the points
62     location along the x-axis while the first value dimension
63     represents the location of the point along the y-axis.
64     """
65 
66     group = param.String(default='Scatter', constant=True)
67 
68 
69 class Curve(Selection1DExpr, Chart):
70     """
71     Curve is a Chart element representing a line in a 1D coordinate
72     system where the key dimension maps on the line x-coordinate and
73     the first value dimension represents the height of the line along
74     the y-axis.
75     """
76 
77     group = param.String(default='Curve', constant=True)
78 
79 
80 class ErrorBars(Selection1DExpr, Chart):
81     """
82     ErrorBars is a Chart element representing error bars in a 1D
83     coordinate system where the key dimension corresponds to the
84     location along the x-axis and the first value dimension
85     corresponds to the location along the y-axis and one or two
86     extra value dimensions corresponding to the symmetric or
87     asymetric errors either along x-axis or y-axis. If two value
88     dimensions are given, then the last value dimension will be
89     taken as symmetric errors. If three value dimensions are given
90     then the last two value dimensions will be taken as negative and
91     positive errors. By default the errors are defined along y-axis.
92     A parameter `horizontal`, when set `True`, will define the errors
93     along the x-axis.
94     """
95 
96     group = param.String(default='ErrorBars', constant=True, doc="""
97         A string describing the quantity measured by the ErrorBars
98         object.""")
99 
100     vdims = param.List(default=[Dimension('y'), Dimension('yerror')],
101                        bounds=(1, None), constant=True)
102 
103     horizontal = param.Boolean(default=False, doc="""
104         Whether the errors are along y-axis (vertical) or x-axis.""")
105 
106     def range(self, dim, data_range=True, dimension_range=True):
107         """Return the lower and upper bounds of values along dimension.
108 
109         Range of the y-dimension includes the symmetric or assymetric
110         error.
111 
112         Args:
113             dimension: The dimension to compute the range on.
114             data_range (bool): Compute range from data values
115             dimension_range (bool): Include Dimension ranges
116                 Whether to include Dimension range and soft_range
117                 in range calculation
118 
119         Returns:
120             Tuple containing the lower and upper bound
121         """
122         dim_with_err = 0 if self.horizontal else 1
123         didx = self.get_dimension_index(dim)
124         dim = self.get_dimension(dim)
125         if didx == dim_with_err and data_range and len(self):
126             mean = self.dimension_values(didx)
127             neg_error = self.dimension_values(2)
128             if len(self.dimensions()) > 3:
129                 pos_error = self.dimension_values(3)
130             else:
131                 pos_error = neg_error
132             lower = np.nanmin(mean-neg_error)
133             upper = np.nanmax(mean+pos_error)
134             if not dimension_range:
135                 return (lower, upper)
136             return util.dimension_range(lower, upper, dim.range, dim.soft_range)
137         return super(ErrorBars, self).range(dim, data_range)
138 
139 
140 
141 class Spread(ErrorBars):
142     """
143     Spread is a Chart element representing a spread of values or
144     confidence band in a 1D coordinate system. The key dimension(s)
145     corresponds to the location along the x-axis and the value
146     dimensions define the location along the y-axis as well as the
147     symmetric or assymetric spread.
148     """
149 
150     group = param.String(default='Spread', constant=True)
151 
152 
153 
154 class Bars(Selection1DExpr, Chart):
155     """
156     Bars is a Chart element representing categorical observations
157     using the height of rectangular bars. The key dimensions represent
158     the categorical groupings of the data, but may also be used to
159     stack the bars, while the first value dimension represents the
160     height of each bar.
161     """
162 
163     group = param.String(default='Bars', constant=True)
164 
165     kdims = param.List(default=[Dimension('x')], bounds=(1,3))
166 
167     _max_kdim_count = 3
168 
169 
170 class Histogram(Selection1DExpr, Chart):
171     """
172     Histogram is a Chart element representing a number of bins in a 1D
173     coordinate system. The key dimension represents the binned values,
174     which may be declared as bin edges or bin centers, while the value
175     dimensions usually defines a count, frequency or density associated
176     with each bin.
177     """
178 
179     datatype = param.List(default=['grid'])
180 
181     group = param.String(default='Histogram', constant=True)
182 
183     kdims = param.List(default=[Dimension('x')], bounds=(1,1), doc="""
184         Dimensions on Element2Ds determine the number of indexable
185         dimensions.""")
186 
187     vdims = param.List(default=[Dimension('Frequency')], bounds=(1, None))
188 
189     _binned = True
190 
191     def __init__(self, data, edges=None, **params):
192         if data is None:
193             data = []
194         if edges is not None:
195             self.param.warning(
196                 "Histogram edges should be supplied as a tuple "
197                 "along with the values, passing the edges will "
198                 "be deprecated in holoviews 2.0.")
199             data = (edges, data)
200         elif isinstance(data, tuple) and len(data) == 2 and len(data[0])+1 == len(data[1]):
201             data = data[::-1]
202 
203         super(Histogram, self).__init__(data, **params)
204     def __setstate__(self, state):
205         """
206         Ensures old-style Histogram types without an interface can be unpickled.
207 
208         Note: Deprecate as part of 2.0
209         """
210         if 'interface' not in state:
211             self.interface = GridInterface
212             x, y = state['_kdims_param_value'][0], state['_vdims_param_value'][0]
213             state['data'] = {x.name: state['data'][1], y.name: state['data'][0]}
214         super(Dataset, self).__setstate__(state)
215 
216 
217     @property
218     def values(self):
219         "Property to access the Histogram values provided for backward compatibility"
220         self.param.warning('Histogram.values is deprecated in favor of '
221                            'common dimension_values method.')
222         return self.dimension_values(1)
223 
224 
225     @property
226     def edges(self):
227         "Property to access the Histogram edges provided for backward compatibility"
228         return self.interface.coords(self, self.kdims[0], edges=True)
229 
230 
231 class Spikes(Selection1DExpr, Chart):
232     """
233     Spikes is a Chart element which represents a number of discrete
234     spikes, events or observations in a 1D coordinate system. The key
235     dimension therefore represents the position of each spike along
236     the x-axis while the first value dimension, if defined, controls
237     the height along the y-axis. It may therefore be used to visualize
238     the distribution of discrete events, representing a rug plot, or
239     to draw the strength some signal.
240     """
241 
242     group = param.String(default='Spikes', constant=True)
243 
244     kdims = param.List(default=[Dimension('x')], bounds=(1, 1))
245 
246     vdims = param.List(default=[])
247 
248     _auto_indexable_1d = False
249 
250 
251 
252 class Area(Curve):
253     """
254     Area is a Chart element representing the area under a curve or
255     between two curves in a 1D coordinate system. The key dimension
256     represents the location of each coordinate along the x-axis, while
257     the value dimension(s) represent the height of the area or the
258     lower and upper bounds of the area between curves.
259 
260     Multiple areas may be stacked by overlaying them an passing them
261     to the stack method.
262     """
263 
264     group = param.String(default='Area', constant=True)
265 
266     @classmethod
267     def stack(cls, areas, baseline_name='Baseline'):
268         """
269         Stacks an (Nd)Overlay of Area or Curve Elements by offsetting
270         their baselines. To stack a HoloMap or DynamicMap use the map
271         method.
272         """
273         if not len(areas):
274             return areas
275         is_overlay = isinstance(areas, Overlay)
276         if is_overlay:
277             areas = NdOverlay({i: el for i, el in enumerate(areas)})
278         df = areas.dframe(multi_index=True)
279         levels = list(range(areas.ndims))
280         vdim = areas.last.vdims[0]
281         vdims = [vdim, baseline_name]
282         baseline = None
283         stacked = areas.clone(shared_data=False)
284         for key, sdf in df.groupby(level=levels):
285             sdf = sdf.droplevel(levels).reindex(index=df.index.levels[-1], fill_value=0)
286             if baseline is None:
287                 sdf[baseline_name] = 0
288             else:
289                 sdf[vdim.name] = sdf[vdim.name] + baseline
290                 sdf[baseline_name] = baseline
291             baseline = sdf[vdim.name]
292             stacked[key] = areas.last.clone(sdf, vdims=vdims)
293         return Overlay(stacked.values()) if is_overlay else stacked
294
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/holoviews/element/chart.py b/holoviews/element/chart.py
--- a/holoviews/element/chart.py
+++ b/holoviews/element/chart.py
@@ -289,5 +289,5 @@
                 sdf[vdim.name] = sdf[vdim.name] + baseline
                 sdf[baseline_name] = baseline
             baseline = sdf[vdim.name]
-            stacked[key] = areas.last.clone(sdf, vdims=vdims)
+            stacked[key] = areas[key].clone(sdf, vdims=vdims)
         return Overlay(stacked.values()) if is_overlay else stacked

{"golden_diff": "diff --git a/holoviews/element/chart.py b/holoviews/element/chart.py\n--- a/holoviews/element/chart.py\n+++ b/holoviews/element/chart.py\n@@ -289,5 +289,5 @@\n                 sdf[vdim.name] = sdf[vdim.name] + baseline\n                 sdf[baseline_name] = baseline\n             baseline = sdf[vdim.name]\n-            stacked[key] = areas.last.clone(sdf, vdims=vdims)\n+            stacked[key] = areas[key].clone(sdf, vdims=vdims)\n         return Overlay(stacked.values()) if is_overlay else stacked\n", "issue": "Stacked area only show last label\n@Pill-GZ found a bug (and a solution!) for the legend of a stacked area plot only showing the last label. See https://discourse.holoviz.org/t/how-to-add-legend-for-stacked-area-plots/2193\r\n\n", "before_files": [{"content": "import numpy as np\nimport param\n\nfrom ..core import util\nfrom ..core import Dimension, Dataset, Element2D, NdOverlay, Overlay\nfrom ..core.dimension import process_dimensions\nfrom ..core.data import GridInterface\nfrom .geom import Rectangles, Points, VectorField # noqa: backward compatible import\nfrom .selection import Selection1DExpr, Selection2DExpr\n\n\nclass Chart(Dataset, Element2D):\n    \"\"\"\n    A Chart is an abstract baseclass for elements representing one or\n    more independent and dependent variables defining a 1D coordinate\n    system with associated values. The independent variables or key\n    dimensions map onto the x-axis while the dependent variables are\n    usually mapped to the location, height or spread along the\n    y-axis. Any number of additional value dimensions may be\n    associated with a Chart.\n\n    If a chart's independent variable (or key dimension) is numeric\n    the chart will represent a discretely sampled version of the\n    underlying continuously sampled 1D space. Therefore indexing along\n    this variable will automatically snap to the closest coordinate.\n\n    Since a Chart is a subclass of a Dataset it supports the full set\n    of data interfaces but usually each dimension of a chart represents\n    a column stored in a dictionary, array or DataFrame.\n    \"\"\"\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1,2), doc=\"\"\"\n        The key dimension(s) of a Chart represent the independent\n        variable(s).\"\"\")\n\n    group = param.String(default='Chart', constant=True)\n\n    vdims = param.List(default=[Dimension('y')], bounds=(1, None), doc=\"\"\"\n        The value dimensions of the Chart, usually corresponding to a\n        number of dependent variables.\"\"\")\n\n    # Enables adding index if 1D array like data is supplied\n    _auto_indexable_1d = True\n\n    _max_kdim_count = 1 # Remove once kdims has bounds=(1,1) instead of warning\n    __abstract = True\n\n    def __init__(self, data, kdims=None, vdims=None, **params):\n        params.update(process_dimensions(kdims, vdims))\n        if len(params.get('kdims', [])) == self._max_kdim_count + 1:\n            self.param.warning('Chart elements should only be supplied a single kdim')\n        super(Chart, self).__init__(data, **params)\n\n    def __getitem__(self, index):\n        return super(Chart, self).__getitem__(index)\n\n\nclass Scatter(Selection2DExpr, Chart):\n    \"\"\"\n    Scatter is a Chart element representing a set of points in a 1D\n    coordinate system where the key dimension maps to the points\n    location along the x-axis while the first value dimension\n    represents the location of the point along the y-axis.\n    \"\"\"\n\n    group = param.String(default='Scatter', constant=True)\n\n\nclass Curve(Selection1DExpr, Chart):\n    \"\"\"\n    Curve is a Chart element representing a line in a 1D coordinate\n    system where the key dimension maps on the line x-coordinate and\n    the first value dimension represents the height of the line along\n    the y-axis.\n    \"\"\"\n\n    group = param.String(default='Curve', constant=True)\n\n\nclass ErrorBars(Selection1DExpr, Chart):\n    \"\"\"\n    ErrorBars is a Chart element representing error bars in a 1D\n    coordinate system where the key dimension corresponds to the\n    location along the x-axis and the first value dimension\n    corresponds to the location along the y-axis and one or two\n    extra value dimensions corresponding to the symmetric or\n    asymetric errors either along x-axis or y-axis. If two value\n    dimensions are given, then the last value dimension will be\n    taken as symmetric errors. If three value dimensions are given\n    then the last two value dimensions will be taken as negative and\n    positive errors. By default the errors are defined along y-axis.\n    A parameter `horizontal`, when set `True`, will define the errors\n    along the x-axis.\n    \"\"\"\n\n    group = param.String(default='ErrorBars', constant=True, doc=\"\"\"\n        A string describing the quantity measured by the ErrorBars\n        object.\"\"\")\n\n    vdims = param.List(default=[Dimension('y'), Dimension('yerror')],\n                       bounds=(1, None), constant=True)\n\n    horizontal = param.Boolean(default=False, doc=\"\"\"\n        Whether the errors are along y-axis (vertical) or x-axis.\"\"\")\n\n    def range(self, dim, data_range=True, dimension_range=True):\n        \"\"\"Return the lower and upper bounds of values along dimension.\n\n        Range of the y-dimension includes the symmetric or assymetric\n        error.\n\n        Args:\n            dimension: The dimension to compute the range on.\n            data_range (bool): Compute range from data values\n            dimension_range (bool): Include Dimension ranges\n                Whether to include Dimension range and soft_range\n                in range calculation\n\n        Returns:\n            Tuple containing the lower and upper bound\n        \"\"\"\n        dim_with_err = 0 if self.horizontal else 1\n        didx = self.get_dimension_index(dim)\n        dim = self.get_dimension(dim)\n        if didx == dim_with_err and data_range and len(self):\n            mean = self.dimension_values(didx)\n            neg_error = self.dimension_values(2)\n            if len(self.dimensions()) > 3:\n                pos_error = self.dimension_values(3)\n            else:\n                pos_error = neg_error\n            lower = np.nanmin(mean-neg_error)\n            upper = np.nanmax(mean+pos_error)\n            if not dimension_range:\n                return (lower, upper)\n            return util.dimension_range(lower, upper, dim.range, dim.soft_range)\n        return super(ErrorBars, self).range(dim, data_range)\n\n\n\nclass Spread(ErrorBars):\n    \"\"\"\n    Spread is a Chart element representing a spread of values or\n    confidence band in a 1D coordinate system. The key dimension(s)\n    corresponds to the location along the x-axis and the value\n    dimensions define the location along the y-axis as well as the\n    symmetric or assymetric spread.\n    \"\"\"\n\n    group = param.String(default='Spread', constant=True)\n\n\n\nclass Bars(Selection1DExpr, Chart):\n    \"\"\"\n    Bars is a Chart element representing categorical observations\n    using the height of rectangular bars. The key dimensions represent\n    the categorical groupings of the data, but may also be used to\n    stack the bars, while the first value dimension represents the\n    height of each bar.\n    \"\"\"\n\n    group = param.String(default='Bars', constant=True)\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1,3))\n\n    _max_kdim_count = 3\n\n\nclass Histogram(Selection1DExpr, Chart):\n    \"\"\"\n    Histogram is a Chart element representing a number of bins in a 1D\n    coordinate system. The key dimension represents the binned values,\n    which may be declared as bin edges or bin centers, while the value\n    dimensions usually defines a count, frequency or density associated\n    with each bin.\n    \"\"\"\n\n    datatype = param.List(default=['grid'])\n\n    group = param.String(default='Histogram', constant=True)\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1,1), doc=\"\"\"\n        Dimensions on Element2Ds determine the number of indexable\n        dimensions.\"\"\")\n\n    vdims = param.List(default=[Dimension('Frequency')], bounds=(1, None))\n\n    _binned = True\n\n    def __init__(self, data, edges=None, **params):\n        if data is None:\n            data = []\n        if edges is not None:\n            self.param.warning(\n                \"Histogram edges should be supplied as a tuple \"\n                \"along with the values, passing the edges will \"\n                \"be deprecated in holoviews 2.0.\")\n            data = (edges, data)\n        elif isinstance(data, tuple) and len(data) == 2 and len(data[0])+1 == len(data[1]):\n            data = data[::-1]\n\n        super(Histogram, self).__init__(data, **params)\n    def __setstate__(self, state):\n        \"\"\"\n        Ensures old-style Histogram types without an interface can be unpickled.\n\n        Note: Deprecate as part of 2.0\n        \"\"\"\n        if 'interface' not in state:\n            self.interface = GridInterface\n            x, y = state['_kdims_param_value'][0], state['_vdims_param_value'][0]\n            state['data'] = {x.name: state['data'][1], y.name: state['data'][0]}\n        super(Dataset, self).__setstate__(state)\n\n\n    @property\n    def values(self):\n        \"Property to access the Histogram values provided for backward compatibility\"\n        self.param.warning('Histogram.values is deprecated in favor of '\n                           'common dimension_values method.')\n        return self.dimension_values(1)\n\n\n    @property\n    def edges(self):\n        \"Property to access the Histogram edges provided for backward compatibility\"\n        return self.interface.coords(self, self.kdims[0], edges=True)\n\n\nclass Spikes(Selection1DExpr, Chart):\n    \"\"\"\n    Spikes is a Chart element which represents a number of discrete\n    spikes, events or observations in a 1D coordinate system. The key\n    dimension therefore represents the position of each spike along\n    the x-axis while the first value dimension, if defined, controls\n    the height along the y-axis. It may therefore be used to visualize\n    the distribution of discrete events, representing a rug plot, or\n    to draw the strength some signal.\n    \"\"\"\n\n    group = param.String(default='Spikes', constant=True)\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1, 1))\n\n    vdims = param.List(default=[])\n\n    _auto_indexable_1d = False\n\n\n\nclass Area(Curve):\n    \"\"\"\n    Area is a Chart element representing the area under a curve or\n    between two curves in a 1D coordinate system. The key dimension\n    represents the location of each coordinate along the x-axis, while\n    the value dimension(s) represent the height of the area or the\n    lower and upper bounds of the area between curves.\n\n    Multiple areas may be stacked by overlaying them an passing them\n    to the stack method.\n    \"\"\"\n\n    group = param.String(default='Area', constant=True)\n\n    @classmethod\n    def stack(cls, areas, baseline_name='Baseline'):\n        \"\"\"\n        Stacks an (Nd)Overlay of Area or Curve Elements by offsetting\n        their baselines. To stack a HoloMap or DynamicMap use the map\n        method.\n        \"\"\"\n        if not len(areas):\n            return areas\n        is_overlay = isinstance(areas, Overlay)\n        if is_overlay:\n            areas = NdOverlay({i: el for i, el in enumerate(areas)})\n        df = areas.dframe(multi_index=True)\n        levels = list(range(areas.ndims))\n        vdim = areas.last.vdims[0]\n        vdims = [vdim, baseline_name]\n        baseline = None\n        stacked = areas.clone(shared_data=False)\n        for key, sdf in df.groupby(level=levels):\n            sdf = sdf.droplevel(levels).reindex(index=df.index.levels[-1], fill_value=0)\n            if baseline is None:\n                sdf[baseline_name] = 0\n            else:\n                sdf[vdim.name] = sdf[vdim.name] + baseline\n                sdf[baseline_name] = baseline\n            baseline = sdf[vdim.name]\n            stacked[key] = areas.last.clone(sdf, vdims=vdims)\n        return Overlay(stacked.values()) if is_overlay else stacked\n", "path": "holoviews/element/chart.py"}], "after_files": [{"content": "import numpy as np\nimport param\n\nfrom ..core import util\nfrom ..core import Dimension, Dataset, Element2D, NdOverlay, Overlay\nfrom ..core.dimension import process_dimensions\nfrom ..core.data import GridInterface\nfrom .geom import Rectangles, Points, VectorField # noqa: backward compatible import\nfrom .selection import Selection1DExpr, Selection2DExpr\n\n\nclass Chart(Dataset, Element2D):\n    \"\"\"\n    A Chart is an abstract baseclass for elements representing one or\n    more independent and dependent variables defining a 1D coordinate\n    system with associated values. The independent variables or key\n    dimensions map onto the x-axis while the dependent variables are\n    usually mapped to the location, height or spread along the\n    y-axis. Any number of additional value dimensions may be\n    associated with a Chart.\n\n    If a chart's independent variable (or key dimension) is numeric\n    the chart will represent a discretely sampled version of the\n    underlying continuously sampled 1D space. Therefore indexing along\n    this variable will automatically snap to the closest coordinate.\n\n    Since a Chart is a subclass of a Dataset it supports the full set\n    of data interfaces but usually each dimension of a chart represents\n    a column stored in a dictionary, array or DataFrame.\n    \"\"\"\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1,2), doc=\"\"\"\n        The key dimension(s) of a Chart represent the independent\n        variable(s).\"\"\")\n\n    group = param.String(default='Chart', constant=True)\n\n    vdims = param.List(default=[Dimension('y')], bounds=(1, None), doc=\"\"\"\n        The value dimensions of the Chart, usually corresponding to a\n        number of dependent variables.\"\"\")\n\n    # Enables adding index if 1D array like data is supplied\n    _auto_indexable_1d = True\n\n    _max_kdim_count = 1 # Remove once kdims has bounds=(1,1) instead of warning\n    __abstract = True\n\n    def __init__(self, data, kdims=None, vdims=None, **params):\n        params.update(process_dimensions(kdims, vdims))\n        if len(params.get('kdims', [])) == self._max_kdim_count + 1:\n            self.param.warning('Chart elements should only be supplied a single kdim')\n        super(Chart, self).__init__(data, **params)\n\n    def __getitem__(self, index):\n        return super(Chart, self).__getitem__(index)\n\n\nclass Scatter(Selection2DExpr, Chart):\n    \"\"\"\n    Scatter is a Chart element representing a set of points in a 1D\n    coordinate system where the key dimension maps to the points\n    location along the x-axis while the first value dimension\n    represents the location of the point along the y-axis.\n    \"\"\"\n\n    group = param.String(default='Scatter', constant=True)\n\n\nclass Curve(Selection1DExpr, Chart):\n    \"\"\"\n    Curve is a Chart element representing a line in a 1D coordinate\n    system where the key dimension maps on the line x-coordinate and\n    the first value dimension represents the height of the line along\n    the y-axis.\n    \"\"\"\n\n    group = param.String(default='Curve', constant=True)\n\n\nclass ErrorBars(Selection1DExpr, Chart):\n    \"\"\"\n    ErrorBars is a Chart element representing error bars in a 1D\n    coordinate system where the key dimension corresponds to the\n    location along the x-axis and the first value dimension\n    corresponds to the location along the y-axis and one or two\n    extra value dimensions corresponding to the symmetric or\n    asymetric errors either along x-axis or y-axis. If two value\n    dimensions are given, then the last value dimension will be\n    taken as symmetric errors. If three value dimensions are given\n    then the last two value dimensions will be taken as negative and\n    positive errors. By default the errors are defined along y-axis.\n    A parameter `horizontal`, when set `True`, will define the errors\n    along the x-axis.\n    \"\"\"\n\n    group = param.String(default='ErrorBars', constant=True, doc=\"\"\"\n        A string describing the quantity measured by the ErrorBars\n        object.\"\"\")\n\n    vdims = param.List(default=[Dimension('y'), Dimension('yerror')],\n                       bounds=(1, None), constant=True)\n\n    horizontal = param.Boolean(default=False, doc=\"\"\"\n        Whether the errors are along y-axis (vertical) or x-axis.\"\"\")\n\n    def range(self, dim, data_range=True, dimension_range=True):\n        \"\"\"Return the lower and upper bounds of values along dimension.\n\n        Range of the y-dimension includes the symmetric or assymetric\n        error.\n\n        Args:\n            dimension: The dimension to compute the range on.\n            data_range (bool): Compute range from data values\n            dimension_range (bool): Include Dimension ranges\n                Whether to include Dimension range and soft_range\n                in range calculation\n\n        Returns:\n            Tuple containing the lower and upper bound\n        \"\"\"\n        dim_with_err = 0 if self.horizontal else 1\n        didx = self.get_dimension_index(dim)\n        dim = self.get_dimension(dim)\n        if didx == dim_with_err and data_range and len(self):\n            mean = self.dimension_values(didx)\n            neg_error = self.dimension_values(2)\n            if len(self.dimensions()) > 3:\n                pos_error = self.dimension_values(3)\n            else:\n                pos_error = neg_error\n            lower = np.nanmin(mean-neg_error)\n            upper = np.nanmax(mean+pos_error)\n            if not dimension_range:\n                return (lower, upper)\n            return util.dimension_range(lower, upper, dim.range, dim.soft_range)\n        return super(ErrorBars, self).range(dim, data_range)\n\n\n\nclass Spread(ErrorBars):\n    \"\"\"\n    Spread is a Chart element representing a spread of values or\n    confidence band in a 1D coordinate system. The key dimension(s)\n    corresponds to the location along the x-axis and the value\n    dimensions define the location along the y-axis as well as the\n    symmetric or assymetric spread.\n    \"\"\"\n\n    group = param.String(default='Spread', constant=True)\n\n\n\nclass Bars(Selection1DExpr, Chart):\n    \"\"\"\n    Bars is a Chart element representing categorical observations\n    using the height of rectangular bars. The key dimensions represent\n    the categorical groupings of the data, but may also be used to\n    stack the bars, while the first value dimension represents the\n    height of each bar.\n    \"\"\"\n\n    group = param.String(default='Bars', constant=True)\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1,3))\n\n    _max_kdim_count = 3\n\n\nclass Histogram(Selection1DExpr, Chart):\n    \"\"\"\n    Histogram is a Chart element representing a number of bins in a 1D\n    coordinate system. The key dimension represents the binned values,\n    which may be declared as bin edges or bin centers, while the value\n    dimensions usually defines a count, frequency or density associated\n    with each bin.\n    \"\"\"\n\n    datatype = param.List(default=['grid'])\n\n    group = param.String(default='Histogram', constant=True)\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1,1), doc=\"\"\"\n        Dimensions on Element2Ds determine the number of indexable\n        dimensions.\"\"\")\n\n    vdims = param.List(default=[Dimension('Frequency')], bounds=(1, None))\n\n    _binned = True\n\n    def __init__(self, data, edges=None, **params):\n        if data is None:\n            data = []\n        if edges is not None:\n            self.param.warning(\n                \"Histogram edges should be supplied as a tuple \"\n                \"along with the values, passing the edges will \"\n                \"be deprecated in holoviews 2.0.\")\n            data = (edges, data)\n        elif isinstance(data, tuple) and len(data) == 2 and len(data[0])+1 == len(data[1]):\n            data = data[::-1]\n\n        super(Histogram, self).__init__(data, **params)\n    def __setstate__(self, state):\n        \"\"\"\n        Ensures old-style Histogram types without an interface can be unpickled.\n\n        Note: Deprecate as part of 2.0\n        \"\"\"\n        if 'interface' not in state:\n            self.interface = GridInterface\n            x, y = state['_kdims_param_value'][0], state['_vdims_param_value'][0]\n            state['data'] = {x.name: state['data'][1], y.name: state['data'][0]}\n        super(Dataset, self).__setstate__(state)\n\n\n    @property\n    def values(self):\n        \"Property to access the Histogram values provided for backward compatibility\"\n        self.param.warning('Histogram.values is deprecated in favor of '\n                           'common dimension_values method.')\n        return self.dimension_values(1)\n\n\n    @property\n    def edges(self):\n        \"Property to access the Histogram edges provided for backward compatibility\"\n        return self.interface.coords(self, self.kdims[0], edges=True)\n\n\nclass Spikes(Selection1DExpr, Chart):\n    \"\"\"\n    Spikes is a Chart element which represents a number of discrete\n    spikes, events or observations in a 1D coordinate system. The key\n    dimension therefore represents the position of each spike along\n    the x-axis while the first value dimension, if defined, controls\n    the height along the y-axis. It may therefore be used to visualize\n    the distribution of discrete events, representing a rug plot, or\n    to draw the strength some signal.\n    \"\"\"\n\n    group = param.String(default='Spikes', constant=True)\n\n    kdims = param.List(default=[Dimension('x')], bounds=(1, 1))\n\n    vdims = param.List(default=[])\n\n    _auto_indexable_1d = False\n\n\n\nclass Area(Curve):\n    \"\"\"\n    Area is a Chart element representing the area under a curve or\n    between two curves in a 1D coordinate system. The key dimension\n    represents the location of each coordinate along the x-axis, while\n    the value dimension(s) represent the height of the area or the\n    lower and upper bounds of the area between curves.\n\n    Multiple areas may be stacked by overlaying them an passing them\n    to the stack method.\n    \"\"\"\n\n    group = param.String(default='Area', constant=True)\n\n    @classmethod\n    def stack(cls, areas, baseline_name='Baseline'):\n        \"\"\"\n        Stacks an (Nd)Overlay of Area or Curve Elements by offsetting\n        their baselines. To stack a HoloMap or DynamicMap use the map\n        method.\n        \"\"\"\n        if not len(areas):\n            return areas\n        is_overlay = isinstance(areas, Overlay)\n        if is_overlay:\n            areas = NdOverlay({i: el for i, el in enumerate(areas)})\n        df = areas.dframe(multi_index=True)\n        levels = list(range(areas.ndims))\n        vdim = areas.last.vdims[0]\n        vdims = [vdim, baseline_name]\n        baseline = None\n        stacked = areas.clone(shared_data=False)\n        for key, sdf in df.groupby(level=levels):\n            sdf = sdf.droplevel(levels).reindex(index=df.index.levels[-1], fill_value=0)\n            if baseline is None:\n                sdf[baseline_name] = 0\n            else:\n                sdf[vdim.name] = sdf[vdim.name] + baseline\n                sdf[baseline_name] = baseline\n            baseline = sdf[vdim.name]\n            stacked[key] = areas[key].clone(sdf, vdims=vdims)\n        return Overlay(stacked.values()) if is_overlay else stacked\n", "path": "holoviews/element/chart.py"}]}