forked from greppo-io/greppo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
38 additions
and
246 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 |
---|---|---|
@@ -1,92 +1,19 @@ | ||
<template> | ||
<div class="my-10 mx-2"> | ||
<p class="text-xl my-1">{{ name }}</p> | ||
<p class="text-base my-1">{{ description }}</p> | ||
<p class="text-sm my-1" v-if="highlightStatus"> | ||
Selected: {{ selectedData.dataLabel }}, | ||
{{ selectedData.dataValue }} of {{ selectedData.datasetLabel }} | ||
<button | ||
class="mx-2 my-2 bg-white transition duration-150 ease-in-out hover:bg-gray-100 rounded text-indigo-700 px-3 py-1 text-sm focus:outline-none" | ||
@click="resetClick" | ||
> | ||
Reset | ||
</button> | ||
</p> | ||
<bar-chart-extends | ||
style="height: 250px;" | ||
:chartData="chartData" | ||
:baseColor="baseColor" | ||
:highlightStatus="highlightStatus" | ||
@highlightEvent="handleHighlightEvent" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import BarChartExtends from "./chart-extends/BarChartExtends.vue"; | ||
import { mapActions } from "vuex"; | ||
import { Bar } from "vue-chartjs"; | ||
export default { | ||
name: "BarChart", | ||
extends: Bar, | ||
props: { | ||
id: String, | ||
name: String, | ||
description: String, | ||
chartData: Object, | ||
}, | ||
components: { | ||
BarChartExtends, | ||
}, | ||
data() { | ||
return { | ||
baseColor: [], | ||
highlightStatus: false, | ||
selectedData: {}, | ||
}; | ||
}, | ||
methods: { | ||
...mapActions(["setChartEventData"]), | ||
resetClick() { | ||
this.highlightStatus = false; | ||
this.selectedData = {}; | ||
data: () => ({ | ||
chartOptions: { | ||
responsive: true, | ||
maintainAspectRatio: false, | ||
}, | ||
handleHighlightEvent(eventData) { | ||
this.highlightStatus = eventData.status; | ||
this.selectedData = eventData.clickData; | ||
this.setChartEventData(eventData.clickData); | ||
}, | ||
}, | ||
created() { | ||
// Creates an array of the background color data variable in the dataset | ||
// object using the color input from the prop. | ||
this.baseColor = new Array(this.chartData.datasets.length).fill( | ||
"#CCCCCC" | ||
); | ||
this.chartData.datasets.forEach((dataset, index) => { | ||
if (dataset.data.length > 1) { | ||
if (dataset.backgroundColor.constructor !== Array) { | ||
this.baseColor[index] = dataset.backgroundColor; | ||
dataset.backgroundColor = new Array( | ||
dataset.data.length | ||
).fill(dataset.backgroundColor); | ||
} else if ( | ||
dataset.backgroundColor.length !== dataset.data.length | ||
) { | ||
this.baseColor[index] = dataset.backgroundColor[0]; | ||
dataset.backgroundColor = new Array( | ||
dataset.data.length | ||
).fill(dataset.backgroundColor[0]); | ||
} | ||
} else { | ||
if (dataset.backgroundColor.constructor === Array) { | ||
this.baseColor[index] = dataset.backgroundColor[0]; | ||
} else { | ||
this.baseColor[index] = dataset.backgroundColor; | ||
} | ||
} | ||
}); | ||
}), | ||
mounted() { | ||
this.renderChart(this.chartData, this.chartOptions); | ||
}, | ||
}; | ||
</script> | ||
|
||
<style></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
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 |
---|---|---|
@@ -1,93 +1,19 @@ | ||
<template> | ||
<div class="my-10 mx-2"> | ||
<p class="text-xl my-1">{{ name }}</p> | ||
<p class="text-base my-1">{{ description }}</p> | ||
<p class="text-sm my-1" v-if="highlightStatus"> | ||
Selected: {{ selectedData.dataLabel }}, | ||
{{ selectedData.dataValue }} of {{ selectedData.datasetLabel }} | ||
<button | ||
class="mx-2 my-2 bg-white transition duration-150 ease-in-out hover:bg-gray-100 rounded text-indigo-700 px-3 py-1 text-sm focus:outline-none" | ||
@click="resetClick" | ||
> | ||
Reset | ||
</button> | ||
</p> | ||
<line-chart-extends | ||
style="height: 250px;" | ||
:chartData="chartData" | ||
:baseColor="baseColor" | ||
:highlightStatus="highlightStatus" | ||
@highlightEvent="handleHighlightEvent" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import LineChartExtends from "./chart-extends/LineChartExtends.vue"; | ||
import { mapActions } from "vuex"; | ||
import { Line } from "vue-chartjs"; | ||
export default { | ||
name: "LineChart", | ||
extends: Line, | ||
props: { | ||
id: String, | ||
name: String, | ||
description: String, | ||
chartData: Object, | ||
}, | ||
components: { | ||
LineChartExtends, | ||
}, | ||
data() { | ||
return { | ||
baseColor: [], | ||
highlightStatus: false, | ||
selectedData: {}, | ||
}; | ||
}, | ||
methods: { | ||
...mapActions(["setChartEventData"]), | ||
resetClick() { | ||
this.highlightStatus = false; | ||
this.selectedData = {}; | ||
data: () => ({ | ||
chartOptions: { | ||
responsive: true, | ||
maintainAspectRatio: false, | ||
}, | ||
handleHighlightEvent(eventData) { | ||
this.highlightStatus = eventData.status; | ||
this.selectedData = eventData.clickData; | ||
this.setChartEventData(eventData.clickData); | ||
}, | ||
}, | ||
created() { | ||
// Creates an array of the background color data variable in the dataset | ||
// object using the color input from the prop. | ||
this.baseColor = new Array(this.chartData.datasets.length).fill( | ||
"#CCCCCC" | ||
); | ||
this.chartData.datasets.forEach((dataset, index) => { | ||
dataset.fill = false; | ||
if (dataset.data.length > 1) { | ||
if (dataset.backgroundColor.constructor !== Array) { | ||
this.baseColor[index] = dataset.backgroundColor; | ||
dataset.backgroundColor = new Array( | ||
dataset.data.length | ||
).fill(dataset.backgroundColor); | ||
} else if ( | ||
dataset.backgroundColor.length !== dataset.data.length | ||
) { | ||
this.baseColor[index] = dataset.backgroundColor[0]; | ||
dataset.backgroundColor = new Array( | ||
dataset.data.length | ||
).fill(dataset.backgroundColor[0]); | ||
} | ||
} else { | ||
if (dataset.backgroundColor.constructor === Array) { | ||
this.baseColor[index] = dataset.backgroundColor[0]; | ||
} else { | ||
this.baseColor[index] = dataset.backgroundColor; | ||
} | ||
} | ||
}); | ||
}), | ||
mounted() { | ||
this.renderChart(this.chartData, this.chartOptions); | ||
}, | ||
}; | ||
</script> | ||
|
||
<style></style> |
This file was deleted.
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
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
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.