You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Additionally, every attributes that can be specified per-point (the
87
109
/// ones that are arrayOk: true) are available. Finally, the template
88
110
/// string has access to variables label, color, value, percent and text.
89
-
/// Anything contained in tag \<extra\> is displayed in the secondary box, for
90
-
/// example “<extra>{fullData.name}</extra>”. To hide the secondary box
91
-
/// completely, use an empty tag <extra></extra>.
111
+
/// Anything contained in tag \<extra\> is displayed in the secondary box,
112
+
/// for example “<extra>{fullData.name}</extra>”. To hide the secondary
113
+
/// box completely, use an empty tag <extra></extra>.
92
114
#[serde(rename = "hovertemplate")]
93
115
hover_template:Option<Dim<String>>,
94
116
/// Sets hover text elements associated with each sector. If a single
@@ -144,9 +166,9 @@ where
144
166
/// axis and colorbar title.text, annotation text rangeselector,
145
167
/// updatemenues and sliders label text all support meta. To access the
146
168
/// trace meta values in an attribute in the same trace, simply use
147
-
/// %{meta\[i\]} where i is the index or key of the meta item in question. To
148
-
/// access trace meta in layout attributes, use %{data[n[.meta\[i\]} where i
149
-
/// is the index or key of the meta and n is the trace index.
169
+
/// %{meta\[i\]} where i is the index or key of the meta item in question.
170
+
/// To access trace meta in layout attributes, use %{data[n[.meta\[i\]}
171
+
/// where i is the index or key of the meta and n is the trace index.
150
172
meta:Option<NumOrString>,
151
173
/// Sets the trace name. The trace name appears as the legend item and on
152
174
/// hover.
@@ -186,10 +208,10 @@ where
186
208
/// Template string used for rendering the information text that appear on
187
209
/// points. Note that this will override textinfo. Variables are
188
210
/// inserted using %{variable}, for example “y: %{y}”. Numbers are formatted
189
-
/// using d3-format’s syntax %{variable:d3-format}, for example “Price: %{y:$.2f}”.
190
-
/// <https://github.com/d3/d3-format/tree/v1.4.5#d3-format> for details on the formatting syntax.
191
-
/// Dates are formatted using d3-time-format’s syntax %{variable|d3-time-format}, for example
192
-
/// “Day: %{2019-01-01|%A}”. <https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format> for details on the date formatting syntax.
211
+
/// using d3-format’s syntax %{variable:d3-format}, for example “Price:
212
+
/// %{y:$.2f}”. <https://github.com/d3/d3-format/tree/v1.4.5#d3-format> for details on the formatting syntax.
213
+
/// Dates are formatted using d3-time-format’s syntax
214
+
/// %{variable|d3-time-format}, for example “Day: %{2019-01-01|%A}”. <https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format> for details on the date formatting syntax.
193
215
/// Every attributes that can be specified per-point (the ones that are
194
216
/// arrayOk: true) are available. Finally, the template string has
195
217
/// access to variables label, color, value, percent and text.
@@ -282,9 +304,36 @@ impl<P> Pie<P>
282
304
where
283
305
P:Serialize + Clone + 'static,
284
306
{
285
-
pubfnnew(x:Vec<P>) -> Box<Self>{
307
+
/// Build a new Pie Chart by only assigning the values field
308
+
pubfnnew(values:Vec<P>) -> Box<Self>{
309
+
Box::new(Self{
310
+
values:Some(values),
311
+
..Default::default()
312
+
})
313
+
}
314
+
315
+
/// Same as [Pie::new()]
316
+
pubfnfrom_values(values:Vec<P>) -> Box<Self>{
286
317
Box::new(Self{
287
-
values:Some(x),
318
+
values:Some(values),
319
+
..Default::default()
320
+
})
321
+
}
322
+
323
+
/// Build a new Pie Chart by only assigning the labels field. The Pie chart
324
+
/// will be generated by counting the number of unique labels, see
325
+
/// [Pie::labels] field description. Note that to create a Pie chart by
326
+
/// using this function, the type parameter `P` needs to be specialized,
327
+
/// this can be done by doing
328
+
/// ```
329
+
/// use plotly::Pie;
330
+
///
331
+
/// let labels = vec!["giraffes", "giraffes", "orangutans", "monkeys"].iter().map(|s| s.to_string()).collect();
0 commit comments