-
-
Notifications
You must be signed in to change notification settings - Fork 832
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
Legend or other options not working in reactiveProps #188
Comments
This will not work this way. You have to pass the options either as a prop or data model import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ['chartData'],
data () {
return {
options: {
legend: {
display: false
}
}
}
}
mounted () {
this.renderChart(this.chartData, this.options)
}
}) This is because the reactive prop will check what data changed and either call As it is the base class, there is no way AFAIK to check that you are passing there. Thats why you need to store your options in |
Trying to pass |
Please show the code snippet or codepen/jsfiddle/webpackbin etc. |
Sure @apertureless Here: import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
// Overwriting base render method with actual data.
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
}, {
scaleShowGridLines: true,
scaleGridLineColor: "rgba(0,0,0,.05)",
scaleGridLineWidth: 1,
scaleShowHorizontalLines: true,
scaleShowVerticalLines: true,
barShowStroke: true,
barStrokeWidth: 2,
barValueSpacing: 5,
barDatasetSpacing: 1,
legend: {
display: true
}
})
}
}) and <template>
<dash-chart role="user" :width="500" :height="400" />
</template> I copied the data from the GitHub commits, and this is what I get: |
Well I can't find anything about |
I believe I was using an incorrect version. I apologize. I got it to work: scales : {
xAxes : [ {
gridLines : {
display : true
}
} ]
}, |
nice! |
I have followed the code sample in the website and created a lineChart.js that looks like this
Expected Behavior
Legend should be disabled. And other options such as tooltip, responsive should work.
Actual Behavior
Chart works as intended but the legend is still showing. Any other options delivered to this.renderChart is not working.
Environment
The text was updated successfully, but these errors were encountered: