0

I have an array object, and i want to filter that array. I already know how to filter data by single value using computed property,

computed: {
    filteredValue() {
        return this.graphData.filter(data => data.YEAR === this.selectedYears)
    }
},

But i want to filter data by multiple value/array. Suppose i have an array object that has Year: 1901-2000. and i only want to filter only those year which are selected (like 1901, 1902, 1903). Can anyone help me with that. TIA

1

1 Answer 1

0

I think you need to maintain an array of selectedYears.Then,use use it like this.

computed: {
   filteredValue() {
      return this.graphData.filter(data => this.selectedYears.includes(data.YEAR);
  } 
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply,, i also just figured it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.