-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored with Legend component & added test
- Loading branch information
1 parent
a7fc0a9
commit 09e7b4d
Showing
21 changed files
with
608 additions
and
579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"dataset": [ | ||
{ | ||
"name": "serie 1", | ||
"color": "#3366cc", | ||
"values": [ | ||
120,120 | ||
] | ||
}, | ||
{ | ||
"name": "serie 2", | ||
"color": "#dc3912", | ||
"values": [ | ||
60,60 | ||
] | ||
}, | ||
{ | ||
"name": "serie 3", | ||
"color": "#ff9900", | ||
"values": [ | ||
15,15 | ||
] | ||
}, | ||
{ | ||
"name": "serie 4", | ||
"color": "#109618", | ||
"values": [ | ||
30,30 | ||
] | ||
} | ||
], | ||
"config": { | ||
"useCssAnimation": true, | ||
"useBlurOnHover": true, | ||
"style": { | ||
"fontFamily": "inherit", | ||
"chart": { | ||
"backgroundColor":"#FFFFFF", | ||
"color":"#2D353C", | ||
"layout": { | ||
"rings": { | ||
"strokeWidth": 2, | ||
"stroke":"#FFFFFF", | ||
"gradient": { | ||
"show": true, | ||
"intensity": 40, | ||
"underlayerColor":"#FFFFFF" | ||
}, | ||
"useShadow": true | ||
} | ||
}, | ||
"legend": { | ||
"backgroundColor": "#FFFFFF", | ||
"color": "#2D353C", | ||
"show": true, | ||
"fontSize": 16, | ||
"bold": false, | ||
"roundingValue": 0, | ||
"roundingPercentage": 0 | ||
}, | ||
"title": { | ||
"text": "Title", | ||
"color": "#2D353C", | ||
"fontSize": 20, | ||
"bold": true, | ||
"subtitle": { | ||
"color": "#A1A1A1", | ||
"text": "Subtitle", | ||
"fontSize": 16, | ||
"bold": false | ||
} | ||
}, | ||
"tooltip": { | ||
"show": true, | ||
"color": "#2D353C", | ||
"backgroundColor": "#FFFFFF", | ||
"fontSize": 14, | ||
"showValue": true, | ||
"showPercentage": true, | ||
"roundingValue": 0, | ||
"roundingPercentage": 0 | ||
} | ||
} | ||
}, | ||
"userOptions": { | ||
"show": true, | ||
"title": "options", | ||
"labels": { | ||
"showTable": "Show table" | ||
} | ||
}, | ||
"table": { | ||
"show": false, | ||
"th": { | ||
"backgroundColor": "#FAFAFA", | ||
"color": "#2D353C", | ||
"outline": "1px solid #e1e5e8" | ||
}, | ||
"td": { | ||
"backgroundColor": "#FFFFFF", | ||
"color": "#2D353C", | ||
"outline": "1px solid #e1e5e8", | ||
"roundingValue": 0, | ||
"roundingPercentage": 0 | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script setup> | ||
import Shape from './Shape.vue'; | ||
const props = defineProps({ | ||
legendSet: { | ||
type: Array, | ||
default() { | ||
return [] | ||
} | ||
}, | ||
config: { | ||
type: Object, | ||
default() { | ||
return {} | ||
} | ||
} | ||
}) | ||
const emit = defineEmits(['clickMarker']) | ||
function handleClick(legend, i) { | ||
emit('clickMarker', { legend, i}) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div | ||
:data-cy="config.cy" | ||
class="vue-data-ui-legend" | ||
:style="`background:${config.backgroundColor};font-size:${config.fontSize}px;color:${config.color};padding-bottom:${config.paddingBottom}px;font-weight:${config.fontWeight}`" | ||
> | ||
<div v-for="(legend, i) in legendSet" class="vue-data-ui-legend-item"> | ||
<svg @click="handleClick(legend, i)" v-if="legend.shape" :height="config.fontSize" :width="config.fontSize" viewBox="0 0 20 20" :style="`overflow: visible;opacity:${legend.opacity}`"> | ||
<Shape | ||
:shape="legend.shape" | ||
:radius="9" | ||
stroke="none" | ||
:plot="{ x: 10, y: 10 }" | ||
:fill="legend.color" | ||
/> | ||
</svg> | ||
<slot name="item" :legend="legend" :index="i"/> | ||
</div> | ||
|
||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.vue-data-ui-legend { | ||
height: 100%; | ||
width:100%; | ||
display: flex; | ||
align-items:center; | ||
flex-wrap: wrap; | ||
justify-content:center; | ||
column-gap: 18px; | ||
} | ||
.vue-data-ui-legend-item { | ||
display: flex; | ||
align-items:center; | ||
gap: 6px; | ||
cursor: pointer; | ||
height: 24px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.