I have a chart component and i use it in a view. I want to make it smaller but max-width doesn't work.
Here is the codes:
<div id="chart">
<ChanceChart :chartData="state.chartData" :chartOptions="state.chartOptions"/>
</div>
And:
#chart {
position: absolute;
left: 0;
top: 20px;
display: block;
width: 100%;
max-width: 100px;
}
My ChanceChart.vue :
<script>
import { defineComponent } from 'vue'
import { Line } from 'vue3-chart-v2'
export default defineComponent({
name: 'ChanceChart',
extends: Line,
props: {
chartData: {
type: Object,
required: true
},
chartOptions: {
type: Object,
required: false
},
},
mounted () {
this.renderChart(this.chartData, this.chartOptions)
}
})
</script>
And maybe it can help, when my datas were in the ChanceChart.vue i could set the width. Now, when my data is in my main component and i use props, and v-binding it, it doesn't work.
And here is my data:
state: {
chartData: {
datasets: [
{
label: "Enemy's Chance",
borderColor: '#1161ed',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 41, 190]
},
{
label: 'My Chance',
borderColor: '#f87979',
color: '#fff',
data: [60,60,60,60,60,60,60,60,60,60,60,60, 60]
}
],
labels: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
},
chartOptions: {
responsive: false
}
}
Can anyone know what is the problem?