Giter VIP home page Giter VIP logo

Comments (13)

bsautel avatar bsautel commented on June 12, 2024 2

Hi @shay972, I integrated angular-highcharts recently and I got the same issues as you.

With angular-highcharts version 3, here is the code that works.

import * as Highcharts from 'highcharts';
import highchartsMoreExtension from 'highcharts/highcharts-more.src';
import solidGaugeExtension from 'highcharts/modules/solid-gauge.src';

highchartsMoreExtension(Highcharts);
solidGaugeExtension(Highcharts);

With the version 4, this code works:

import highchartsMoreExtension from 'highcharts/highcharts-more.src';
import solidGaugeExtension from 'highcharts/modules/solid-gauge.src';
import {FactoryProvider} from '@angular/core';
import {HIGHCHARTS_MODULES} from 'angular-highcharts';

export function highchartsModules() {
  return [highchartsMoreExtension, solidGaugeExtension];
}

// Don't forget to declare this provider
const HighchartsProvider: FactoryProvider = {
  provide: HIGHCHARTS_MODULES,
  useFactory: highchartsModules
};

Note that in both cases, I had to add this in the typings declarations:

declare function HighchartsModule(H: any): any;

declare module 'highcharts/highcharts-more.src' {
  export default HighchartsModule;
}

declare module 'highcharts/modules/solid-gauge.src' {
  export default HighchartsModule;
}

I don't know why I have to declare these additional symbols. Is it due to a problem in the typing definitions coming from @types/highcharts? From the fact that I use the noImplicitAny Typescript option? From the fact I use es2015 modules? Or from something else? I am new in the Angular 4 / Typescript world and for now I cannot answer this question.

Hope it will help!

from angular-highcharts.

cebor avatar cebor commented on June 12, 2024

You have to import the gauge plugin: https://github.com/cebor/angular-highcharts#using-highcharts-modules

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

Ok thanks, I added the this to the modules, but what is the next step?
can you provide example for the component

from angular-highcharts.

cebor avatar cebor commented on June 12, 2024

@shay972 just set type: 'gauge' and it should work, maybe you also have to import highcharts-more

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

I am still getting:
ERROR Error: Highcharts error #17: www.highcharts.com/errors/17

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

I have some progress, still having issue with "series" and "yAxis"
https://www.highcharts.com/demo/gauge-speedometer
I am trying to solve it..

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

as soon as I put the series, I am getting the above error,
here is my code:

`
chart = new Chart({

chart: {
type: 'gauge',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false
},

title: {
text: 'Speedometer'
},

pane: {
startAngle: -150,
endAngle: 150,
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#FFF'],
[1, '#333']
]
},
borderWidth: 0,
outerRadius: '109%'
},
{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#333'],
[1, '#FFF']
]
},
borderWidth: 1,
outerRadius: '107%'
},
{
backgroundColor: '#DDD',
borderWidth: 0,
outerRadius: '105%',
innerRadius: '103%'
}
]},

yAxis: {
  min: 0,
  max: 200,

},

series: [{
name: 'Speed',
data: [80],
}]

});

`

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

I think I am not importing the modules correctly:
import { Chart } from 'angular-highcharts';
import 'highcharts/highcharts-more';
import 'highcharts/modules/solid-gauge';

from angular-highcharts.

cebor avatar cebor commented on June 12, 2024

@shay972 nope, this is not correct. Please follow the instructions i posted above.

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

The part you posted I already did in the app.modules
what do I need to do on the component itself in order to make it to work?
can you please send working example for the solidgauge

from angular-highcharts.

cebor avatar cebor commented on June 12, 2024

Sorry im very busy atm, maybe i have time to prepare an example for you tomorrow.

But it should very easy to accomplish what you want:

  1. Extend Highcharts with highcharts-more and solidgauge (See node_modules/highcharts for file paths).
  2. Just create Chartwith correct options object. (Just use the example from highcharts.com)
  3. To control the gauge, use yourChart.ref, which is a reference to the original Highcharts object. (You can use the official Highcharts docs for that)

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

When I am putting the data inside chart definition I am getting error 17
when I just did it as you suggested:
this.chart2.ref.series[0].setData([80]);
I got new error:
typeError: Cannot read property 'setData' of undefined

please note, that other charts such as "column" is working fine for me, only the guage* - now I am working on the solidgauge

from angular-highcharts.

shay972 avatar shay972 commented on June 12, 2024

Finally !!
Thanks @bsautel for the working solution !!!

from angular-highcharts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.