score:1
Accepted answer
You could use props to pass data to a child component.
https://vuejs.org/v2/guide/components-props.html
Example
App.vue
<template>
<div id="app">
<Chart :id="chartId" />
</div>
</template>
<script>
import Chart from "@/components/Chart.vue";
// @/ means src/
export default {
name: "App",
components: {
Chart,
},
data: () => ({
chartId: 2,
}),
};
</script>
Chart.vue
<template>
<div>
{{ id }}
</div>
</template>
<script>
export default {
name: "Chart",
props: {
id: {
type: Number,
required: true,
},
},
mounted() {
const apiURL = `/farfrom/chart/${this.id}`;
// API call
}
};
</script>
Source: stackoverflow.com
Related Query
- How do i have a single Chart.vue component instead of different chart components and then display charts from it by changing id of the API
- how to create multiple chart on one component vue
- How can I have different values for the chart and the tooltip in chart.js?
- How to make dynamic chart using Vue component with chart-js
- How to reuse a Chartjs Chart component in with different Data and get past the **Canvas is already in use** error?
- How to create single value Doughnut or Pie chart using Chart.js?
- How to have solid colored bars in angular-chart bar chart
- How to set single color on each bar in angular chart js
- ChartJS - how to display line chart with single element as a line? (not as a dot)
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Vue ChartKick - different colours for bar chart
- How to map json array to two different array for chart
- VueJs/ChartJs - single file component computed property only renders when I click the component in Vue Dev Tools
- Chart is too big. How can I reduce size for the chart in vue js?
- How to show different product name for every bar in chart js
- How to have mutiple charts in a single page using Chart.js?
- I have 10 points inn x-axis, ranging [-25,-20,,-15,-10,0,10,20,30,40,50]. But I want my line chart to start from -15 of x-axis. How we can achieve?
- How to highlight single bar in bar chart using Chartjs
- Chart JS, ng2-Charts - How to make the label to the right of pie chart instead on top?
- Charts.js how to have 2 different size y-axis
- How to display date instead of year in morris line chart in js
- How do I get a different label for each bar in a bar chart in ChartJS?
- How do I display two datasets on a single chart with chartjs
- How can I display desired/particular chart in App.vue from Charts.vue which contains different charts in Vuejs
- How to print a chart rendered by code
- React - How can I pass API data from one component to another in a different js file?
- How to make a chart with a string values instead of data?
- How to assign different background colors to chart.js pie chart data set?
- How to stop displaying the data values from different data objects on Chart JS 2.x?
- How to separete chart series into different pane (Chart.js)
More Query from same tag
- How to create dynamic D3 tickFormat in dc charts
- Is it possible to use Chart.js in web2py?
- Chart.js doughnut text colors
- Chart.js Bar chart resizes again when revisiting the tab
- How to create an array of objects dynamically in javascript for a pie chart
- Stack two y axes using chart.js
- Chart.js - draw horizontal line based on a certain y-value
- html2canvas Chart.js chart not rendered
- How can I highlight/format a specific date label (e.g. today) on a time axis using chart.js?
- Split assoc array by keys
- chart.js legend not working for pie chart
- Why can't I update the aspectRatio within the chartjs chart?
- How to add a horizontal line at a specific point in chart.js when hovering?
- How to change bar color acording to label value in chartjs
- Chart.js v2.0: Tooltip only for one dataset
- chart.js display even intervals between two dates and adding label to y axes
- How to use Selenium with "chart.js"
- Annotation plugin not working with Chart.js 2.8.0
- Tool tip not showing for those label who's data overlapped on each other in chart.js
- ChartJS with ChartJS DataLabels: Change Color per Dataset for Value Labels
- Is there a way to display legend's data over the chart in chart.js?
- Adding space to begin of xAxis ticks in chartJS
- Chart js how to remove numbers on circles of polar chart
- Display multiple datasets from array with chart.js
- How do I display chart on my HTML page based on JSON data sent by Node JS
- How to add the value for each label to pie legend
- Can't pass data to chart.js graph
- ChartJS set color of Line chart points depending on Y Axis
- Weird time formating with chart.js and moment.js
- How to add data dynamically to primevue Line chart from vuejs3?