MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / violinPlot

Function violinPlot

src/danfojs-base/plotting/plotly/violin.ts:31–143  ·  view source on GitHub ↗
(ndframe: DataFrame | Series, divId: string, plotConfig: InternalPlotConfigObject, Plotly: any)

Source from the content-addressed store, hash-verified

29* @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters.
30*/
31export const violinPlot = (ndframe: DataFrame | Series, divId: string, plotConfig: InternalPlotConfigObject, Plotly: any) => {
32 const config = plotConfig["config"]
33 const layout = plotConfig["layout"]
34
35 if (ndframe instanceof Series) {
36 let trace: Data = {
37 y: ndframe.values as any,
38 type: 'violin',
39 };
40
41 Plotly.newPlot(divId, [trace], layout, config);
42
43 } else {
44
45 if (config["x"] && config["y"]) {
46 //Plotting two columns against each other, when user specifies x and y column names in configuration
47 throwErrorOnWrongColName(ndframe, config["x"]);
48 throwErrorOnWrongColName(ndframe, config["y"]);
49
50 const x = ndframe[config.x].values;
51 const y = ndframe[config.y].values;
52
53 const trace: Data = {
54 x,
55 y,
56 type: 'violin',
57 };
58 const _layout = {
59 xaxis: {
60 title: config.x,
61 },
62 yaxis: {
63 title: config.y,
64 },
65 ...layout,
66 };
67
68 Plotly.newPlot(divId, [trace], _layout, config);
69
70 } else if (config["x"] || config["y"]) {
71 //plot single column specified in either of param [x | y] against index
72 if (config["x"]) {
73 throwErrorOnWrongColName(ndframe, config.x);
74
75 const x = ndframe[config.x].values;
76 const y = ndframe.index;
77
78 const trace: Data = {
79 x,
80 y,
81 type: 'violin',
82 };
83 const _layout = {
84 xaxis: {
85 title: config.x,
86 },
87 yaxis: {
88 title: "Index",

Callers 1

violinMethod · 0.85

Calls 2

throwErrorOnWrongColNameFunction · 0.90
checkIfColsExistFunction · 0.90

Tested by

no test coverage detected