score:1
Presumably this.myChart2
is declared elsewhere and will be used to access the chart object, and I'm guessing that this property is never == 0
so isn't a suitable test condition.
The property you are looking for is the length of the data array in the dataset this.myChart2.data.dataset.data.length
, unfortunately this property does exist until the data is received from the server so referencing it directly will result in 'cannot read property length of undefined' errors
My suggestion would be to initalize another property in your vue component to store your data length, say this.myChart2Length = 0;
and update this when you get your axios response this.myChart2Length = vm.best_beneficiaries.length || 0;
Then in your template you can reference the new property in your v-if
condition
<div class="wrapper mt-5">
<canvas ref="myChart2" id="myChart2" v-if="myChart2Length > 0" width="600" height="250" class="mb-5"></canvas>
<span v-else >No data</span>
</div>
Source: stackoverflow.com
Related Query
- How can I show "No Data" message in Pie Chart when there is no data using VueJS?
- Show 'No data' in Pie when there is no data using VueJS and ChartJS?
- How can I show a subset of data on pie pieces in Chart.JS while still displaying the superset when hovering?
- Show "No Data" message for Pie chart with no data
- How to show percentage (%) using chartjs-plugin-labels ( Pie chart ) in angular 2/8
- How to show slice value inside of slice in pie chart using chart.js
- How can I re-distribute values within a charts.js pie chart when a legend item is turned off/on?
- How to get Data from API to display chart using chartjs in Vuejs
- ng2-Chart: can we show the tooltip data of pie chart on load?
- How can i display my data in a chart using chart js
- How to show tooltip only when data available in chart js?
- How can I remove the white border from Chart.js pie chart when all legends are hidden?
- How can I build some chart with Chart.js and ng2-charts using an array of revenus & budgets per month date as Data source?
- how to show data value on bar chart body rather than using tooltip?
- chart js tooltip how to control the data that show
- How to disable Chart JS tooltip when there is no value?
- How to display data labels outside in pie chart with lines in ionic
- How to create single value Doughnut or Pie chart using Chart.js?
- How can I display the xAxes and yAxes data in the tooltip, Chart JS?
- How can I show Bootstrap modal when on click in individual bars in chart.js
- How to show data values in top of bar chart and line chart in chart.js 3
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Angular chart how to show the legend data value by default along with legend name
- how to show data label on barchart using chart.js in Angular10 project?
- How can I rotate a pie chart in charts.js?
- Using chart js version 3, how to add custom data to external tooltip?
- How can I achieve displaying data points on chart but Dotted? Chart.js V3.7.0
- How can I show JSON data in Chart.js with Javascript if static values are working but dynamic from mySQL are not?
- how to add percentage value to legend field in pie chart using chart.js
- How to display chart using Chartjs with JSON data in Laravel
More Query from same tag
- Chart.js. Edit bar width -v2.5-
- Uncaught ReferenceError: require is not defined using react-chartjs.min.js
- ChartJS - Show values in the center of each bar
- Does this library have a way of showing a world map?
- Chartjs 2: Multi level/hierarchical category axis in chartjs
- How to execute a JavaScript function with ChartJS and FreeMarker?
- Ionic 3 + Angular 4 + chart.js - loading data from array
- How to pass a nested function to an HTML button and Dropdown menu
- Chart.js different y axis depending on graph from select options
- Is it possible to get chart js data using ajax?
- chart js bar chart add animation to change color
- Line Chart x-Axis datapoints with Strings
- ChartJS: Custom tooltip always displaying
- How can I delete an instance of a chart using chart.js
- How to toggle between Custom tooltip and normal tooltip in chartjs and angular
- Why are the default Chart.js legend boxes transparent rectangles?
- Create Line Chart and populate with database information
- Converting JSON data into Chart.js array from strings
- Remove bullet points from chart.js legend
- Multiple Range Highlighting of Background in Chart.js
- Pass variable from function js to other function js
- How do remove the bottom scale on a Chart.js bar chart
- Chart.js custom tooltipTemplate index
- Update ChartJS line chart from DynamoDB query
- ChartJS GridLine Dynamically
- Chartjs: update the min and maximum of the yaxes ticks on a click
- Vue Chart.js -- can I give a line chart a default value for missing data?
- Mixed bubble chart with line chart in vue-chartjs4
- Changing width of chart.js chart without changing height
- How can I pass the data into the chartjs label?