Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70750

Get attribute of an array of objects

$
0
0

@shchekanenko wrote:

I am working on a app which should display weight log of the user on a graph.
I’ve declared a model of weight which has three attributes: date, weight, image. In my weight.ts file i would like to read and display on a graph only the weight attribute.

model:
export class Weight {
constructor( public date: Date,
public weight: number,
public imageUrl: string){}
}

weight.ts:

@Component({
selector: ‘page-my-weight’,
templateUrl: ‘my-weight.html’,
})
export class MyWeightPage implements OnInit {
chartOptions: any;
addWeightPage = AddWeightPage;
weights: Weight[] = [];
@ViewChild(‘lineCanvas’) lineCanvas;
lineChart: any;

constructor(public modalCtrl: ModalController,
public navCtrl: NavController,
private weightService: WeightService){

}
getWeight() : number{
return this.weights.values.weight;

}
ionViewDidLoad(){
this.lineChart = new Chart(this.lineCanvas.nativeElement, {

  type: 'line',
  data: {
      datasets: [
          {
              label: "My First dataset",
              fill: false,
              lineTension: 0.1,
              backgroundColor: "rgba(75,192,192,0.4)",
              borderColor: "rgba(75,192,192,1)",
              borderCapStyle: 'butt',
              borderDash: [],
              borderDashOffset: 0.0,
              borderJoinStyle: 'miter',
              pointBorderColor: "rgba(75,192,192,1)",
              pointBackgroundColor: "#fff",
              pointBorderWidth: 1,
              pointHoverRadius: 5,
              pointHoverBackgroundColor: "rgba(75,192,192,1)",
              pointHoverBorderColor: "rgba(220,220,220,1)",
              pointHoverBorderWidth: 2,
              pointRadius: 1,
              pointHitRadius: 10,
              data:     ????????????? WHAT SHALL I WRITE HERE?
              spanGaps: false,
          }
      ]
  }

});

Thanks in advance for help

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>