-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/piechart #168
base: dev
Are you sure you want to change the base?
Feat/piechart #168
Changes from all commits
e2280d1
d83ec07
d5b2e4b
b4514ea
e21e984
949df9c
8427fef
e21259e
ad59106
6c494e2
9c83b56
38ebcb3
1937904
4675ede
cd1864f
1f81acc
e3371ec
84fe419
8bf219a
006de63
3cea6f1
174b386
0413f2f
87d5ef6
10772ba
34cdd69
7a5f0e6
54091b1
0ecc993
5c7c296
b4bc6e2
ce09723
9896338
2187adf
f8f4b8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { parseHTML } from '../support/parseHTML'; | ||
import piechartData from '../data_src/piechart.data.json'; | ||
|
||
const FEATURE_NAME = "piechart" | ||
|
||
before(() => { | ||
parseHTML(FEATURE_NAME, piechartData) | ||
}) | ||
|
||
describe('PIECHART CANVAS', function () { | ||
const describeTitle = this.title + ' -- ' | ||
beforeEach(() => { | ||
cy.visit("cypress/html_files/" + FEATURE_NAME + ".html"); | ||
}) | ||
|
||
it("should draw canvas", function () { | ||
cy.compareSnapshot(describeTitle + this.test.title, 0.05); | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<script src=$core_path></script> | ||
</head> | ||
<div id="app"> | ||
<canvas id="canvas" style="border: 1px solid black;"></canvas> | ||
|
||
<script type="text/javascript"> | ||
var width = 0.95*window.innerWidth; | ||
var height = Math.max(0.95*window.innerHeight, 350); | ||
var data = $data; | ||
var number_plot_data = data.length; | ||
var plot_data = new PlotData.PlotPieChart(data, width, height, true, 0, 0, "canvas"); | ||
plot_data.define_canvas("canvas"); | ||
plot_data.draw_initial(); | ||
plot_data.mouse_interaction(false); | ||
</script> | ||
</div> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -755,6 +755,30 @@ def __init__(self, x_variable: str, y_variable: str, tooltip: Tooltip = None, po | |
PlotDataObject.__init__(self, type_='scatterplot', name=name) | ||
|
||
|
||
class PieChart(PlotDataObject): | ||
""" | ||
A class for drawing pie plots. | ||
|
||
:param data_samples: [{'name_param_1': any,..., 'name_param_p': any},..., | ||
{'name_param_1': any,..., 'name_param_p': any}] | ||
:type data_samples: List[dict] | ||
:param slicing_variable: variable that you want to use to fill pie parts | ||
:type slicing_variable: str | ||
""" | ||
|
||
def __init__(self, slicing_variable: str, | ||
data_samples: List[Any] = None, | ||
name: str = ''): | ||
|
||
self.slicing_variable = slicing_variable | ||
if not data_samples: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self.data_samples = [] | ||
else: | ||
self.data_samples = data_samples | ||
|
||
PlotDataObject.__init__(self, type_='piechart', name=name) | ||
|
||
|
||
class ScatterMatrix(PlotDataObject): | ||
def __init__(self, elements: List[Sample] = None, axes: List[str] = None, | ||
point_style: PointStyle = None, surface_style: SurfaceStyle = None, | ||
|
@@ -1199,6 +1223,8 @@ def plot_canvas(plot_data_object: PlotDataObject, | |
template = templates.histogram_template | ||
elif plot_type == "scattermatrix": | ||
template = templates.scatter_matrix_template | ||
elif plot_type == "piechart": | ||
template = templates.piechart_template | ||
else: | ||
raise NotImplementedError('Type {} not implemented'.format(plot_type)) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,3 +225,35 @@ | |
</body> | ||
</html> | ||
''') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this template any different than the cypress' one ? Can't they be mutualized ? Should they ? |
||
|
||
piechart_template = Template(''' | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<script src=$core_path></script> | ||
</head> | ||
<div id="app"> | ||
<canvas id="$canvas_id" width="2000" height="490" | ||
style="border: 1px solid black;"> | ||
</canvas> | ||
|
||
<!-- Sets the basepath for the library if not in same directory --> | ||
|
||
<script> | ||
var width = 0.95*window.innerWidth; | ||
var height = Math.max(0.95*window.innerHeight, 350); | ||
|
||
var data = $data; | ||
var number_plot_data = data.length; | ||
|
||
var plot_data = new PlotData.PlotPieChart( | ||
data, width, height, true, 0, 0, $canvas_id.id | ||
); | ||
plot_data.define_canvas($canvas_id.id); | ||
plot_data.draw_initial(); | ||
plot_data.mouse_interaction(false); | ||
</script> | ||
</div> | ||
</html> | ||
''') |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
"plot_scatter.py", | ||
"primitive_group.py", | ||
"simple_shapes.py", | ||
"pie_chart.py", | ||
"text_scaling.py" | ||
] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Fri Jun 3 16:18:31 2022 | ||
|
||
@author: tanguy | ||
""" | ||
|
||
import plot_data | ||
import plot_data.colors as colors | ||
import random | ||
|
||
|
||
data_samples = [] | ||
SHAPES = ['round', 'square', 'triangle', 'ellipse'] | ||
COLORS = [colors.RED, colors.BLUE, colors.GREEN, colors.YELLOW, colors.ORANGE, colors.VIOLET] | ||
for i in range(50): | ||
random_shape = SHAPES[random.randint(0, len(SHAPES) - 1)] | ||
random_color = COLORS[random.randint(0, len(SHAPES) - 1)] | ||
data_samples.append({'mass': random.uniform(0, 50), | ||
'length': random.uniform(0, 100), | ||
'shape': random_shape, | ||
'color': random_color | ||
}) | ||
|
||
|
||
piechart1 = plot_data.PieChart(data_samples=data_samples, | ||
slicing_variable='mass') | ||
|
||
plot_data_object = plot_data.PieChart(data_samples=data_samples, | ||
slicing_variable='length') | ||
|
||
|
||
plot_data.plot_canvas(plot_data_object=piechart1, debug_mode=True) | ||
plot_data.plot_canvas(plot_data_object=plot_data_object, debug_mode=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ export class MultiplePlots { | |
} else if (object_type_ === 'parallelplot') { | ||
this.dataObjects[i]['elements'] = elements; | ||
newObject = new ParallelPlot(this.dataObjects[i], this.sizes[i]['width'], this.sizes[i]['height'], buttons_ON, this.initial_coords[i][0], this.initial_coords[i][1], canvas_id, true); | ||
} else if (object_type_ === 'primitivegroup') { | ||
} else if (object_type_ === 'primitivegroup') { | ||
newObject = new PlotContour(this.dataObjects[i], this.sizes[i]['width'], this.sizes[i]['height'], buttons_ON, this.initial_coords[i][0], this.initial_coords[i][1], canvas_id, true); | ||
} else if (object_type_ === 'primitivegroupcontainer') { | ||
newObject = new PrimitiveGroupContainer(this.dataObjects[i], this.sizes[i]['width'], this.sizes[i]['height'], buttons_ON, this.initial_coords[i][0], this.initial_coords[i][1], canvas_id, true); | ||
|
@@ -101,6 +101,7 @@ export class MultiplePlots { | |
} | ||
this.initializeObjectContext(newObject); | ||
this.objectList.push(newObject); | ||
console.log(newObject) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intempestive log ? |
||
} | ||
if (elements) {this.initialize_point_families();} | ||
|
||
|
@@ -109,6 +110,7 @@ export class MultiplePlots { | |
this.display_order.push(i); | ||
this.to_display_plots.push(i); | ||
} | ||
|
||
this.mouse_interaction(); | ||
|
||
if (buttons_ON) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should update changelog to set it in the right version (ie. current)