Skip to content
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

Highcharts How to show data from API REST #8697

Closed
brayhanlt2 opened this issue Jul 26, 2018 · 1 comment
Closed

Highcharts How to show data from API REST #8697

brayhanlt2 opened this issue Jul 26, 2018 · 1 comment

Comments

@brayhanlt2
Copy link

brayhanlt2 commented Jul 26, 2018

Hi, i'm new with all those stuff of charts and i've realized that its difficult. I want to create 3 different charts, piechart and two linecharts in the same page(for segments). For the pie chart i just have two values:

  1. Incomes( infoInco )
  2. Other incomes( infoOtInco )

Now i have this code and the values are showed in the console, but when i put them in the chart, it says undefined, so i don't know if i need an specific kind of value. Help please :c
Here's my code.

THE PAGE.HTML:
`


`

THE PAGE.TS:

`import { Component, ViewChild } from '@angular/core';
import { AlertController,
NavController,
NavParams,
Platform } from 'ionic-angular';
import * as Highcharts from 'highcharts';
import { VentaserviciosInfoPage,
VentaarticulosInfoPage,
OtrasventasInfoPage } from './paginas.informes';

import { InformesProvider } from '../../providers/informes/informes';

@component({
selector: 'page-informes',
templateUrl: 'informes.html',
providers: [InformesProvider]
})
export class InformesPage {

data: any;
informes: any;
userData: any;
datosResp: any;
infoInco: any;
infoOtInco: any;

constructor(public navCtrl: NavController,
public navParams: NavParams,
private _ip: InformesProvider) {

    this.informes = "Ingresos";

}

abrirVS(){
this.navCtrl.push(VentaserviciosInfoPage);
}

abrirOV(){
this.navCtrl.push(OtrasventasInfoPage);
}

showIncomes(){

  let now = new Date();
  let day = ("0" + now.getDate()).slice(-2);
  let month = ("0" + (now.getMonth() + 1)).slice(-2);
  let year = now.getFullYear();
  let today = now.getFullYear()+"-"+(month)+"-"+(day);


  let idusuario = (localStorage.getItem('idusuario'));
  this.userData = {
    idusuario: idusuario,
    periodo: year
  };
  this._ip.traerDatos(this.userData, "prueba").then((result) =>{
    this.datosResp = result;
    this.infoInco = this.datosResp[0];
    this.infoOtInco = this.datosResp[1];
    console.log(this.infoInco);
    console.log(this.infoOtInco);
  });


  this.data = this.showHighchart(this.infoInco, this.infoOtInco);

}

ionViewDidLoad(){

this.showIncomes();

}

showHighchart(infoInco, infoOtInco){

  console.log(infoInco);
  console.log(infoOtInco);

   Highcharts.chart('container', {
      chart: {
      type: 'pie'
      },
      title: {
      text: 'Country population'
      },
      series: [{
      name: 'Population',
      data:  [{
          name: 'Venta de Servicios',
          y: infoInco
      }, {
          name: 'Otras ventas',
          y: infoOtInco
      }
    ]}]
});

}

}`

Chrome's console says undefined.

@Denyllon
Copy link
Contributor

hi @brayhanlt2 ,

GitHub issues section is our bug tracker, but in order to get help with some implementation, please contact our support team on forum, or ask your question on StackOverflow platform. I'm sure that you will receive help there.

Kind regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants