I have highcharts used with highcharts-vue.
I have several plugins loaded and working as expected:
import Vue from 'vue';
import Highcharts from 'highcharts';
import HighchartsVue from 'highcharts-vue';
import stockInit from 'highcharts/modules/stock';
import noDataToDisplay from 'highcharts/modules/no-data-to-display';
import solidGauge from 'highcharts/modules/solid-gauge';
if (typeof Highcharts === 'object' && typeof window !== 'undefined') {
stockInit(Highcharts);
solidGauge(Highcharts);
noDataToDisplay(Highcharts);
}
Vue.use(HighchartsVue, {tagName: 'charts'});
But the solid-gauge module I just added generates an error:
Uncaught TypeError: Object prototype may only be an Object or null: undefined
at setPrototypeOf (<anonymous>)
at a (solid-gauge.js:15:327)
at eval (solid-gauge.js:15:388)
at eval (solid-gauge.js:16:308)
at eval (solid-gauge.js:19:291)
at f (solid-gauge.js:11:175)
at eval (solid-gauge.js:14:442)
at eval (highcharts.js:34:72)
at Module../plugins/highcharts.js (app.js:5244:1)
at __webpack_require__ (runtime.js:854:30)
I hardly see how I can investigate further from this step.
I did update my highcharts npm dependency up to 10.0.1 but the error still occurs.
Help would be greatly appreciated!
Cheers
You need to import and initialize the highcharts-more module before solid-gauge.
import Vue from 'vue';
import Highcharts from 'highcharts';
import HighchartsVue from 'highcharts-vue';
import hcMore from 'highcharts/highcharts-more';
import stockInit from 'highcharts/modules/stock';
import noDataToDisplay from 'highcharts/modules/no-data-to-display';
import solidGauge from 'highcharts/modules/solid-gauge';
if (typeof Highcharts === 'object' && typeof window !== 'undefined') {
hcMore(Highcharts);
stockInit(Highcharts);
solidGauge(Highcharts);
noDataToDisplay(Highcharts);
}
Live demo: https://jsfiddle.net/BlackLabel/2dqL70hy/
Related
Using intl package how can I initialize multiple libraries. For example I have some translation on lib1 and other on lib2, I would like to initialize both translations so they can be used in my code. Until the moment I have this:
import 'package:lib1/_l10n/messages_all.dart' as lib1;
import 'package:lib2/_l10n/messages_all.dart' as lib2;
import 'package:intl/intl.dart';
import 'package:mylib/_l10n/messages_all.dart' as mylib;
main() {
intl.defaultLocle = 'es';
await lib1.initializeMessages('es');
await lib2.initializeMessages('es');
await mylib.initializeMessages('es');
print(lib1.helloMessage());
print(lib2.hiMessage());
print(mylib.whatUpMessage());
}
It only translate lib1.helloMessage() since is the first one, the rest of message keep being shown in english.
That doesn't work right now. You would have to generate a combined library and use that.
I am trying to use Razor to generate the html used in an Angular template. I am using Angular v 2.0.0. I have a Contract.cshtml that looks like:
<script>
System.import('contract.js').catch(function(err){ console.error(err); });
</script>
<my-contract>
<h1>Hello {{name}} this is a quick starter for angular 2 app</h1>
</my-contract>
A Contract.ts that looks like
import { platformBrowserDynamic } from '#angular/platform-browser-dynamic';
import { ContractModule } from './app/Contract/contract.module';
platformBrowserDynamic().bootstrapModule(ContractModule);
A contract.component.ts that looks like:
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import { ContractComponent } from './contract.component';
#NgModule({
imports: [ BrowserModule ],
declarations: [ ContractComponent ],
bootstrap: [ ContractComponent ]
})
export class ContractModule { }
And a contract.component.ts that looks like:
import { Component } from '#angular/core';
#Component({
selector: 'my-contract'
})
export class ContractComponent {
public name = 'Nigel Findlater';
consturctor() {}
}
When I run this I get
Error: Error: No template specified for component ContractComponent
at DirectiveNormalizer.normalizeDirective (http://localhost:2600/lib/#angular/compiler/bundles/compiler.umd.js:13476:21) at RuntimeCompiler._createCompiledTemplate (http://localhost:2600/lib/#angular/compiler/bundles/compiler.umd.js:16869:210)
at eval (http://localhost:2600/lib/#angular/compiler/bundles/compiler.umd.js:16807:43)
at Array.forEach (native)
at eval (http://localhost:2600/lib/#angular/compiler/bundles/compiler.umd.js:16805:50)
at Array.forEach (native)
at RuntimeCompiler._compileComponents (http://localhost:2600/lib/#angular/compiler/bundles/compiler.umd.js:16804:45)
at RuntimeCompiler._compileModuleAndComponents (http://localhost:2600/lib/#angular/compiler/bundles/compiler.umd.js:16741:39)
at RuntimeCompiler.compileModuleAsync (http://localhost:2600/lib/#angular/compiler/bundles/compiler.umd.js:16732:23)
at PlatformRef_._bootstrapModuleWithZone (http://localhost:2600/lib/#angular/core/bundles/core.umd.js:6954:29)
Evaluating http://localhost:2600/contract.js
Error loading http://localhost:2600/contract.js
I think the error is in contract.component.ts, but I don't know how not to specify a template here
Angular2 is not designed to be used with Razor generated templates. It is best to allow Angular2 to handle all the routing and not use MVC because this adds an unnecessary dependency which makes the project harder to test.
I use Angular to offload a lot of work from the server to the client and host complex websites using much less resources. Those websites are not SPAs.
In that context it can be really useful to use ASP.NET router and razor generated templates (sometimes precompiled).
The only problem I faced in using razor generated templates in Angular was the way webpack was configured.
After removing the angular2-template-loader everything worked smoothly.
I'm trying to learn react-native from Tyler McGinnis tutorial: https://egghead.io/lessons/react-react-native-basic-ios-routing#/tab-code
The error message below seems straight forward, but I'm not sure what I'm doing wrong.
Seems you're trying to access 'ReactNative.Component' from the 'react-native' package. Perhaps your meant to access 'React.Component' from the 'react' package instead. For example instead of:
import React, {Component,View} from 'react-native';
You should now do:
import React, {Component} from 'react'; import {View} from
'react-native';
import React, { Component } from 'react';
import {AppRegistry,NavigatorIOS,StyleSheet,Text,View} from 'react-native';
import {Main} from './App/Components/Main';
var styles = StyleSheet.create({ container: {
flex: 1,
backgroundColor: '#111111' }, });
The cause of your error:
Your file sets React to 'react-native' default export and not 'react' one. Later in the file you are
Accessing React.Component on a variable that is set to the 'react-native' default export won't work (React native doesn't contain Component as a named export)The 'react' library is where the {Component} (and therefore React.Component) named export is defined.
Solution:
In Main change your imports to the following:
import React from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
...
class Main extends React.Component {
render(){
return(
<View style={styles.mainContainer}>
<Text>Testing the Router</Text>
</View>
)
}
};
When you refer to React.Component now, there is no issue because it has been defined properly whilst still retaining references to React-Native components.
This error message was supposed to be a warning about a deprecation introduced with v 0.25.1
https://github.com/facebook/react-native/releases/tag/v0.25.1
Requiring React API from react-native is now deprecated. You still have it in your Main.js
var React = require('react-native');
var {
StyleSheet,
Text,
View
} = React;
Change it to :
import React, { Component } from 'react';
import {StyleSheet,Text,View} from 'react-native';
I have three components in Angular Dart 2.0 which are menu,company,address.. Which is the best method to bootstrap this.. In a single main.dart file or using import of every component.dart file to main file and each one bootstrap. My code is given below please help
Menu.dart
#Component(
selector: 'menu'
)
#View(
templateUrl: 'lib/menu.html'
)
class Menu{
}
Company.dart
import 'package:angular2/angular2.dart';
#Component(
selector: 'company'
)
#View(
templateUrl: 'lib/company.html'
)
class Company{
}
How can I define the main Function
import 'package:angular2/angular2.dart';
import 'package:angular2/src/reflection/reflection.dart' show reflector;
import 'package:angular2/src/reflection/reflection_capabilities.dart'
show ReflectionCapabilities;
import 'lib/menu.dart';
import 'lib/company.dart';
import 'lib/address.dart';
main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrap(Menu);
bootstrap(Company);
bootstrap(Address);
}
Is this a correct method
The first argument to bootstrap() is root component of the polymer application. You probably won't create 3 independent Angular applications in your page.
Create an additional application component and pass it to bootstrap
bootstrap(Application);
If you add all code in one file or split it to a file per component is just a preference.
I am attempting to refactor some dart-polymer components to use the #HtmlImport annotation.
.dart
part of epimss_shared.components;
#CustomTag('associated-symptoms-form')
class AssociatedSymptomsForm extends PolymerElement {
AssociatedSymptomsForm.created() : super.created();
#override
void attached() {
super.attached();
}
}
.html
<polymer-element name='associated-symptoms-form'>
<template>
<div layout horizontal center>
<h1>Symptoms</h1>
</template>
<script type = 'application/dart' src='associated_symptoms_form.dart'></script>
</polymer-element>
library
The library epimss_shared.components; is part of the imported epimss.shared library.
#HtmlImport('../components/tooltip/tool_tip.html')
#HtmlImport('../components/misc/associated_symptoms_form.html')
library epimss_shared.components;
import 'dart:html' as dom;
import 'package:polymer/polymer.dart';
import 'package:epimss_shared/epimss_shared.dart';
import 'package:epimss_shared/epimss_shared_client.dart';
part '../components/tooltip/tool_tip.dart';
part '../components/misc/associated_symptoms_form.dart';
When I attempt to use the component, the application is not displayed with the following console error:
'package:epimss_shared/components/misc/associated_symptoms_form.dart': error: line 1 pos 6: url expected
part of epimss_shared.components;
^: package:epimss_shared/components/misc/associated_symptoms_form.dart
The peculiar thing is this - if I creat a new component with a different name with everything remaining the same (as done with the tooltip component shown in the library) there is no problem at all!
It seems that previous information of the component is cached and is being reused.
Any help is appreciated.