Skip to content

Commit 0fd4741

Browse files
committed
fix axis name
1 parent 0a017f0 commit 0fd4741

1 file changed

Lines changed: 1 addition & 126 deletions

File tree

danfojs/src/plotting/plot.js

Lines changed: 1 addition & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -16,132 +16,6 @@ export class Plot {
1616
this.ndframe = ndframe
1717
}
1818

19-
plot(config) {
20-
let params = Object.keys(config)
21-
let this_config = {}
22-
23-
params.forEach(param => {
24-
this_config[param] = config[param]
25-
})
26-
27-
if (!utils.__key_in_object(config, "layout")) {
28-
this_config['layout'] = {}
29-
}
30-
31-
if (this.ndframe instanceof Series) {
32-
let trace = {}
33-
34-
if (this_config['type'] == 'histogram') {
35-
let x = this.ndframe.values
36-
trace["x"] = x
37-
} else {
38-
let y = this.ndframe.values
39-
trace["y"] = y
40-
}
41-
42-
params.forEach(param => {
43-
trace[param] = config[param]
44-
})
45-
newPlot(this.div, [trace], this_config['layout']);
46-
47-
} else {
48-
49-
//DataFrame
50-
if (utils.__key_in_object(this_config, 'x') && utils.__key_in_object(this_config, 'y')) {
51-
if (!this.ndframe.column_names.includes(this_config['x'])) {
52-
throw Error(`Column Error: ${this_config['x']} not found in columns`)
53-
}
54-
if (!this.ndframe.column_names.includes(this_config['y'])) {
55-
throw Error(`Column Error: ${this_config['y']} not found in columns`)
56-
}
57-
58-
59-
let x = this.ndframe[this_config['x']].values
60-
let y = this.ndframe[this_config['y']].values
61-
62-
let trace = {
63-
x: x,
64-
y: y,
65-
type: config["type"],
66-
mode: config["mode"],
67-
}
68-
69-
let xaxis = {}; let yaxis = {}
70-
xaxis['title'] = this_config['x']
71-
yaxis['title'] = this_config['y']
72-
73-
this_config['layout']['xaxis'] = xaxis
74-
this_config['layout']['yaxis'] = yaxis
75-
76-
77-
newPlot(this.div, [trace], this_config['layout']);
78-
79-
80-
} else if (this_config['type'] == 'pie') {
81-
if (!this.ndframe.column_names.includes(this_config['values'])) {
82-
throw Error(`Column Error: ${this_config['values']} not found in columns`)
83-
}
84-
if (!this.ndframe.column_names.includes(this_config['labels'])) {
85-
throw Error(`Column Error: ${this_config['labels']} not found in columns`)
86-
}
87-
let data = [{
88-
values: this.ndframe[this_config['values']].values,
89-
labels: this.ndframe[this_config['labels']].values,
90-
type: 'pie'
91-
}];
92-
93-
newPlot(this.div, data, this_config['layout'])
94-
95-
} else if (this_config['type'] == 'box') {
96-
let cols_2_show = []
97-
let data = []
98-
99-
if (this_config['columns'] != undefined) {
100-
cols_2_show = this_config['columns']
101-
cols_2_show.forEach(col => {
102-
if (!this.ndframe.column_names.includes(col)) {
103-
throw Error(`Column Error: ${this_config['labels']} not found in columns`)
104-
}
105-
})
106-
} else {
107-
cols_2_show = this.ndframe.column_names
108-
}
109-
110-
111-
cols_2_show.forEach(col => {
112-
let col_idx = this.ndframe.column_names.indexOf(col)
113-
let trace = []
114-
trace['y'] = this.ndframe.col_data[col_idx]
115-
trace["type"] = 'box'
116-
trace["name"] = col
117-
118-
data.push(trace)
119-
})
120-
newPlot(this.div, data, this_config['layout']);
121-
122-
} else {
123-
//plot all
124-
let x = this.ndframe.index
125-
let data = []
126-
this.ndframe.column_names.forEach(c_name => {
127-
let trace = {}
128-
trace["x"] = x
129-
trace["y"] = this.ndframe[c_name].values
130-
trace['name'] = c_name
131-
params.forEach(param => {
132-
trace[param] = config[param]
133-
})
134-
data.push(trace)
135-
136-
})
137-
newPlot(this.div, data, this_config['layout']);
138-
}
139-
140-
141-
}
142-
}
143-
144-
14519

14620
/**
14721
* Plot Series or DataFrame as lines. This function is useful to plot lines using DataFrame’s values as coordinates.
@@ -701,6 +575,7 @@ export class Plot {
701575

702576
trace["y"] = y
703577
trace['type'] = "box"
578+
704579

705580
newPlot(this.div, [trace], this_config['layout']);
706581

0 commit comments

Comments
 (0)