Skip to content
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

Code refactoring to simplify unit testing and make codebase more readable. #23

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
8 changes: 6 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"env": {
"browser": true,
"es2021": true
"es2021": true,
"jest": true
},
"extends": "eslint:recommended",
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {}
}
14 changes: 7 additions & 7 deletions radialgauge_v2.js

Large diffs are not rendered by default.

Empty file added src/constants/mocks.js
Empty file.
361 changes: 361 additions & 0 deletions src/constants/plot_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,361 @@
const DEFAULT_MAX_RANGE = null;

export const plotConfig = {
// PLOT ADVANCED
arm_length: {
type: 'number',
label: 'Arm Length',
default: 9,
section: 'Plot',
display: 'range',
min: 0,
max: 50,
step: 0.5,
order: 200,
display_size: 'half',
},
arm_weight: {
type: 'number',
label: 'Thickness',
default: 48,
section: 'Plot',
display: 'range',
min: 0,
max: 100,
order: 300,
display_size: 'half',
},
spinner_length: {
type: 'number',
label: 'Pointer Length',
default: 153,
section: 'Plot',
display: 'range',
min: 0,
max: 200,
order: 400,
display_size: 'half',
},
spinner_weight: {
type: 'number',
label: 'Thickness',
section: 'Plot',
display: 'range',
min: 0,
max: 100,
default: 25,
order: 500,
display_size: 'half',
},
target_length: {
type: 'number',
label: 'Target Length',
default: 10,
section: 'Target',
display: 'range',
min: 0,
max: 30,
order: 600,
display_size: 'third',
},
target_gap: {
type: 'number',
label: 'Dash Gap',
default: 10,
section: 'Target',
display: 'range',
min: 0,
max: 30,
order: 610,
display_size: 'third',
},
target_weight: {
type: 'number',
label: 'Thickness',
default: 8,
section: 'Target',
display: 'range',
min: 0,
max: 100,
order: 700,
display_size: 'third',
},

// PLOT
range_min: {
type: 'number',
label: 'Range Min Override',
section: 'Plot',
order: 30,
default: 0,
display_size: 'half',
},
range_max: {
type: 'number',
label: 'Range Max Override',
section: 'Plot',
order: 31,
default: DEFAULT_MAX_RANGE,
display_size: 'half',
},
value_label_type: {
type: 'string',
label: 'Value Label Type',
display: 'select',
section: 'Value',
values: [
{'Value and Measure Label': 'both'},
{'Value and Dimension': 'dboth'},
{'Only Value': 'value'},
{'Only Label': 'label'},
{'Only Dimension': 'dim'},
{None: 'none'},
],
default: 'both',
order: 40,
},
value_label_font: {
type: 'number',
label: 'Value Label Font Size',
section: 'Value',
default: 12,
order: 50,
},
value_formatting: {
type: 'string',
label: 'Value Formatting Override',
section: 'Value',
order: 51,
},
value_label_override: {
type: 'string',
label: 'Value Label Override',
section: 'Value',
order: 60,
},
value_label_padding: {
type: 'number',
label: 'Value Label Padding',
default: 45,
section: 'Value',
display: 'range',
min: 0,
max: 120,
order: 70,
},
target_source: {
type: 'string',
label: 'Target Source',
display: 'select',
section: 'Target',
values: [
{'First Measure': 'first'},
{'Second Measure': 'second'},
{Override: 'override'},
{'No Target': 'off'},
],
default: 'off',
order: 80,
},
target_label_type: {
type: 'string',
label: 'Target Label Type',
display: 'select',
section: 'Target',
values: [
{'Value and Label': 'both'},
{'Only Value': 'value'},
{'Only Label': 'label'},
{'Value and Dimension': 'dboth'},
{'Only Dimension': 'dim'},
{'No Label': 'nolabel'},
],
default: 'both',
order: 90,
},
target_label_font: {
type: 'number',
label: 'Target Label Font Size',
section: 'Target',
default: 3,
order: 100,
},
target_label_override: {
type: 'string',
label: 'Target Label Override',
section: 'Target',
order: 120,
},
target_value_override: {
type: 'string',
label: 'Target Value Override',
section: 'Target',
order: 110,
},
target_value_format: {
type: 'string',
label: 'Target Value Formatting',
section: 'Target',
order: 120,
},
label_font_size: {
type: 'number',
label: 'Range Label Font Size',
section: 'Plot',
default: 3,
order: 140,
},
range_formatting: {
type: 'string',
label: 'Range Label Value Formatting',
section: 'Plot',
order: 150,
},
spinner_type: {
type: 'string',
label: 'Spinner Type',
display: 'select',
section: 'Plot',
values: [
{Needle: 'needle'},
{Spinner: 'spinner'},
{Automotive: 'auto'},
{Inner: 'inner'},
],
default: 'needle',
order: 151,
},

// STYLE
fill_color: {
type: 'string',
label: 'Gauge Fill Color',
section: 'Style',
display: 'color',
default: '#0092E5',
order: 10,
},
background_color: {
type: 'string',
label: 'Background Color',
default: '#CECECE',
section: 'Style',
display: 'color',
order: 20,
},
spinner_color: {
type: 'string',
label: 'Pointer Color',
default: '#282828',
section: 'Style',
display: 'color',
order: 30,
},
range_color: {
type: 'string',
label: 'Range Label Color',
default: '#282828',
section: 'Style',
display: 'color',
order: 40,
},
gauge_fill_type: {
type: 'string',
label: 'Gauge Fill Type',
display: 'select',
section: 'Style',
values: [
{Progress: 'progress'},
{'Progress Segment': 'progress-gradient'},
{Segment: 'segment'},
],
default: 'progress',
order: 1,
},
fill_colors: {
type: 'array',
label: 'Gauge Segment Colors',
section: 'Style',
default: ['#7FCDAE', '#ffed6f', '#EE7772'],
display: 'colors',
order: 11,
},
viz_trellis_by: {
type: 'string',
label: 'Trellis By',
display: 'select',
section: 'Plot',
values: [{None: 'none'}, {Row: 'row'}, {Pivot: 'pivot'}],
default: 'none',
order: 0,
},
trellis_rows: {
type: 'number',
label: 'Trellis Rows',
section: 'Plot',
display_size: 'half',
default: 2,
order: 1,
},
trellis_cols: {
type: 'number',
label: 'Trellis Columns',
section: 'Plot',
display_size: 'half',
default: 2,
order: 2,
},
angle: {
type: 'number',
label: 'Radial Gauge Angle',
default: 90,
section: 'Plot',
display: 'range',
min: 10,
max: 170,
order: 10,
},
cutout: {
type: 'number',
label: 'Radial Gauge Cutout',
default: 30,
section: 'Plot',
display: 'range',
min: 0,
max: 100,
order: 20,
},
range_x: {
type: 'number',
label: 'Range Width',
default: 1,
section: 'Plot',
display: 'range',
min: -2,
max: 4,
step: 0.1,
order: 800,
},
range_y: {
type: 'number',
label: 'Range Height',
default: 1,
section: 'Plot',
display: 'range',
min: -2,
max: 4,
step: 0.1,
order: 900,
},
target_label_padding: {
type: 'number',
label: 'Target Label Padding',
default: 1.06,
section: 'Target',
display: 'range',
min: 1,
max: 2,
step: 0.01,
order: 130,
},
};
File renamed without changes.
Loading