Storybook + antd less loader - antd

I've been using storybook-addon-customize-antd-theme for a while, but it seems unmaintained and I realize I am never using it to customize the theme anyway, just load the less files. I've also been recently running into build issues that are solved by removing the add on.
I've been trying to replace it by just using the appropriate webpack loader config like this:
addons: [
...,
{
"name": "#storybook/preset-create-react-app",
"options": {
"craOverrides": {
"fileLoaderExcludes": ["less"]
}
}
}
],
webpackFinal: async (config) => {
config.module.rules.push({
// this is for both less and scss
test: /.*\.(?:le|c)ss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: false
}
},
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true
}
}
}
]
});
return config
}
But I am receiving this error:
// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?
Which makes it seem like the rule isn't being obeyed, because I have javascriptEnabled: true in the less loader.
What gives?

Thx for your config, my storybook finally works ok.
I am not sure, if it will be helpfull, but I will share my config.
So the main aim for me was, storybook + react + typescript + less + normal component styles import + classnames.
My files structure and content:
package.json
{
"name": "storybook",
"version": "0.1.0",
"private": true,
"dependencies": {
"#storybook/addon-postcss": "^2.0.0",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"#types/jest": "^27.5.2",
"#types/node": "^16.11.45",
"#types/react": "^18.0.15",
"#types/react-dom": "^18.0.6",
"classnames": "^2.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"styled-components": "^5.3.5",
"typescript": "^4.7.4",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"overrides": [
{
"files": [
"**/*.stories.*"
],
"rules": {
"import/no-anonymous-default-export": "off"
}
}
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#storybook/addon-actions": "^6.5.9",
"#storybook/addon-essentials": "^6.5.9",
"#storybook/addon-interactions": "^6.5.9",
"#storybook/addon-links": "^6.5.9",
"#storybook/builder-webpack5": "^6.5.9",
"#storybook/manager-webpack5": "^6.5.9",
"#storybook/node-logger": "^6.5.9",
"#storybook/preset-create-react-app": "^4.1.2",
"#storybook/react": "^6.5.9",
"#storybook/testing-library": "^0.0.13",
"autoprefixer": "^10.4.7",
"babel-plugin-named-exports-order": "^0.0.2",
"css-loader": "^6.7.1",
"less": "^4.1.3",
"less-loader": "^11.0.0",
"postcss-loader": "^7.0.1",
"prop-types": "^15.8.1",
"storybook-addon-designs": "^6.3.1",
"storybook-addon-pseudo-states": "^1.15.1",
"style-loader": "^3.3.1",
"stylelint": "^14.9.1",
"stylelint-config-standard": "^26.0.0",
"webpack": "^5.73.0"
}
}
main.js
const path = require('path');
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.#(js|jsx|ts|tsx)"
],
"addons": [
"#storybook/addon-links",
"#storybook/addon-essentials",
"#storybook/addon-interactions",
"storybook-addon-designs",
"storybook-addon-pseudo-states",
{
"name": "#storybook/preset-create-react-app",
"options": {
"craOverrides": {
"fileLoaderExcludes": ["less"]
}
}
}
],
"framework": "#storybook/react",
"core": {
"builder": "#storybook/builder-webpack5"
},
webpackFinal: async (config, { configType }) => {
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.
// Make whatever fine-grained changes you need
config.module.rules.push({
test: /\.less$/,
include: path.resolve(__dirname, '../'),
sideEffects: true,
exclude: /node_modules/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
modules: {
auto: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]'
},
importLoaders: 2,
}
},
'less-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
ident: 'postcss',
plugins: [
require('stylelint')(),
require('autoprefixer')()
]
}
}
}
]
});
// Return the altered config
return config;
},
}
Button.stories.tsx
import { ComponentStory, ComponentMeta } from '#storybook/react';
import { Button } from './Button';
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
title: 'Example/Button',
component: Button,
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
},
} as ComponentMeta<typeof Button>;
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/react/writing-stories/args
Primary.args = {
label: 'Button',
};
export const Secondary = Template.bind({});
Secondary.args = {
label: 'Button',
};
export const Large = Template.bind({});
Large.args = {
size: 'large',
label: 'Button',
};
export const Small = Template.bind({});
Small.args = {
size: 'small',
label: 'Button',
};
Button.tsx
import React from 'react';
// import './button.css';
import classnames from 'classnames/bind';
import styles from './ButtonStyles.less'
// import './ButtonStyles.css';
interface ButtonProps {
type?: 'primary' | 'secondary' | 'cta' | 'secondaryOnlyText' | 'distractive' | 'social';
/**
* How large should the button be?
*/
size?: 'small' | 'medium' | 'primary' | 'large';
/**
* Button contents
*/
label: string;
/**
* Optional click handler
*/
onClick?: () => void;
}
/**
* Primary UI component for user interaction
*/
const cx = classnames.bind(styles);
export const Button = ({
type = 'primary',
size = 'medium',
label,
...props
}: ButtonProps) => {
const buttonStyles = cx({
storybookButton: true
})
return (
<button
type="button"
// className="storybookButton"
className={buttonStyles}
{...props}
>
{label}
</button>
);
};
ButtonStyles.less
.storybookButton {
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: 700;
border: 0;
border-radius: 3em;
cursor: pointer;
display: inline-block;
line-height: 1;
background-color: yellow;
color: red;
}
.storybook-button--primary {
color: white;
background-color: #1ea7fd;
}
.storybook-button--secondary {
color: #333;
background-color: transparent;
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
}
.storybook-button--small {
font-size: 12px;
padding: 10px 16px;
}
.storybook-button--medium {
font-size: 14px;
padding: 11px 20px;
}
.storybook-button--large {
font-size: 16px;
padding: 12px 24px;
}

Since the rules are already set for less files, You will get exactly this error if you try to load global less files in preview.js like this :
import '!style-loader!css-loader!less-loader!../path/to/antd.less';
If this is the case, , just simply import them like this :
import '../path/to/antd.less';

Related

#ngtools/webpack not compiling project code after migrating from Angular4 to Angular7

I migrated angular4 application to Angular7 and resolved the dev and prod builds but AOT build is not transpiling the application code(app.module). The main and polyfill bundle size is only 1 kb each. looking at the output console it seems it is not compiling any module.
webpack.config.js
:
/**
* #author: #AngularClass
*/
const webpack = require('webpack');
const helpers = require('./helpers');
const ngw = require('#ngtools/webpack');
const AssetsPlugin = require('assets-webpack-plugin');
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin');
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
const HtmlElementsPlugin = require('./html-elements-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const HMR = helpers.hasProcessFlag('hot');
const AOT = Boolean(process.env.BUILD_AOT) || helpers.hasNpmFlag('aot');
let METADATA = {
isDevServer: helpers.isWebpackDevServer(),
HMR
};
const sassConfig = require('./scss-config.common');
console.info(`[BUILD STARTED WITH ${AOT ? 'AOT' : 'WITHOUT AOT'}]`);
module.exports = function (options) {
const isProd = options.env === 'production';
const envString = isProd ? 'prod' : 'dev';
METADATA = Object.assign({}, METADATA, require(`./environment/meta-${envString}`));
return {
target: "web",
entry: {
'polyfills': './src/polyfills.browser.ts',
'main': AOT ? './src/main.browser.aot.ts' :
'./src/main.browser.ts'
},
resolve: {
alias: {
'tslib$': 'tslib/tslib.es6.js',
},
extensions: ['.ts', '.js', '.json'],
modules: [helpers.root('src'), helpers.root('node_modules')],
},
module: {
rules: [
{
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
loader: '#ngtools/webpack'
},
{
test: /\.css$/,
use: [
`to-string-loader${isProd? '' : '?sourceMap'}`,
`css-loader?${JSON.stringify({ sourceMap: !isProd, importLoaders: 1 })}`,
'postcss-loader',
],
exclude: [helpers.root('src', 'styles')]
},
{
test: /\.scss$/,
use: [
`to-string-loader${isProd? '' : '?sourceMap'}`,
`css-loader?${JSON.stringify({ sourceMap: !isProd, importLoaders: 2 })}`,
'postcss-loader',
{
loader: 'sass-loader',
options: {
includePaths: sassConfig.includePaths,
sourceMap: !isProd
}
}
],
exclude: [helpers.root('src', 'styles')]
},
{
test: /\.html$/,
// use: { loader: 'html-loader' },
use: 'raw-loader',
exclude: [helpers.root('src/index.html')]
},
{
test: /\.(jpg|png|gif)$/,
use: 'file-loader'
},
{
test: /\.(eot|woff2?|svg|ttf)([\?]?.*)$/,
use: 'file-loader'
}
],
},
plugins: [
new webpack.ProvidePlugin({
'__assign': ['tslib', '__assign'],
'__extends': ['tslib', '__extends'],
}),
new AssetsPlugin({
path: helpers.root('dist'),
filename: 'webpack-assets.json',
prettyPrint: true
}),
new CheckerPlugin(),
new ContextReplacementPlugin( /(.+)?angular(\\|\/)core(.+)?/, helpers.root('./src'), {} ),
new CopyWebpackPlugin([
{ from: 'src/assets', to: 'assets' },
{ from: 'src/meta'}
],
isProd ? { ignore: [ 'mock-data/**/*' ] } : undefined
),
new HtmlWebpackPlugin({
minify: isProd ? {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
decodeEntities: true,
processConditionalComments: true,
} : false,
template: 'src/index.html',
title: METADATA.title,
metadata: METADATA,
chunksSortMode: "manual",
chunks: ['polyfills', 'vendor', 'main'],
inject: false
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'defer'
}),
new HtmlElementsPlugin({
headTags: require('./head-config.common')(envString)
}),
new LoaderOptionsPlugin({}),
new NormalModuleReplacementPlugin(
/facade(\\|\/)async/,
helpers.root('node_modules/#angular/core/src/facade/async.js')
),
new NormalModuleReplacementPlugin(
/facade(\\|\/)collection/,
helpers.root('node_modules/#angular/core/src/facade/collection.js')
),
new NormalModuleReplacementPlugin(
/facade(\\|\/)errors/,
helpers.root('node_modules/#angular/core/src/facade/errors.js')
),
new NormalModuleReplacementPlugin(
/facade(\\|\/)lang/,
helpers.root('node_modules/#angular/core/src/facade/lang.js')
),
new NormalModuleReplacementPlugin(
/facade(\\|\/)math/,
helpers.root('node_modules/#angular/core/src/facade/math.js')
),
new ngw.AngularCompilerPlugin({
tsConfigPath: helpers.root('tsconfig.webpack.json'),
entryModule: helpers.root('src', 'app/app.module#AppModule'),
sourceMap: true,
skipCodeGeneration: true
})
],
node: {
global: true,
crypto: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false,
fs: 'empty'
},
optimization: {
splitChunks: {
cacheGroups: {
polyfills: {
name: 'polyfills',
chunks: (chunk) => {
return chunk.name === 'polyfills';
}
},
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: (chunk) => {
return chunk.name === 'main';
}
}
}
}
}
};
}
tsconfig.webpack.json:
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmit": true,
"noEmitHelpers": true,
"importHelpers": true,
"paths": { "tslib": ["./node_modules/tslib/tslib.d.ts"] },
"baseUrl": "./",
"strictNullChecks": false,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"node_modules/#types"
],
"types": [
"hammerjs",
"node"
]
},
"exclude": [
"node_modules",
"dist",
"src/**/*.spec.ts",
"src/**/*.e2e.ts"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"angularCompilerOptions": {
"skipMetadataEmit": true,
"skipTemplateCodegen" : false
},
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Angular- V7
Webpack - 4
Node - 8.11.1
Finally, I managed to resolve this and the root cause was a silly one.
As my project is a legacy one so there are many unnecessary configurations and one such was "noEmit: true" in 'compilerOptions' in 'tsconfig.webpack.json' file.
After removing this property the artifacts are generating properly.

why Service worker is slow?

I am developing a project with nuxt. I installed Service Worker to this project using this package. The nuxt.config.js file is like this:
export default {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: 'my_project',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1'},
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
'~/static/css/base.css',
'~/static/css/hooper.css',
'~/static/css/font-awesome/css/all.min.css',
],
/*
** Plugins to load before mounting the App
*/
plugins: [
{ src: '~plugins/ga.js', ssr: false }
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'#nuxtjs/axios',
// Doc: https://bootstrap-vue.js.org/docs/
'bootstrap-vue/nuxt',
'#nuxtjs/pwa',
'#nuxtjs/device',
],
manifest:{
"short_name": "my_project",
"name": "my_project",
"icons": [
{
"src": "/static/icon.png",
"type": "image/png",
},
],
"start_url": "/",
"background_color": "white",
"display": "standalone",
"scope": "/",
"theme_color": "white"
},
workbox:{
},
/*
** Axios module configuration
*/
axios: {
// See https://github.com/nuxt-community/axios-module#options
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
},
hooks:{
// This hook is called before generatic static html files for SPA mode
'generate:page': (page) => {
if(page.path.includes('/amp/')){
page.html = modify_html(page.html)
}
},
// This hook is called before rendering the html to the browser
'render:route': (url, page, { req, res }) => {
if(url.includes('/amp/')){
page.html = modify_html(page.html)
}
}
}
}
But Service Worker is so slow. for example:
In this example normal query to the server takes 1.43 seconds and Service Worker query takes 1.37 seconds. How can i make Service Worker faster?

React Native Expo App Missing Status Bar in TestFlight

After building the standalone iOS native binary using Expo, uploading to Testflight and running it on an iPhone, the status bar looks like there are many elements missing.
What might be the cause of this? How can we fix it? Thanks!
In iPhone Expo Client:
Status bar looks normal.
In TestFlight:
Status bar appears to be empty except for the green battery indicator
/src/Routes/index.js
import React from 'react';
import { createBottomTabNavigator, createStackNavigator, createSwitchNavigator, createAppContainer } from 'react-navigation';
import { BottomNavigation, BottomNavigationTab, BottomNavigationProps, withStyles } from 'react-native-ui-kitten';
...
class BottomNavigationTabsComponent extends React.Component {
render() { ... }
}
BottomNavigationTabs = withStyles(BottomNavigationTabsComponent, (theme) => ({
bottomNavigation: {
borderTopColor: theme['border-basic-color-2'],
borderTopWidth: 1
}
}));
const TabNavigator = createBottomTabNavigator(
{
Foo: FooScreen,
Bar: BarScree,
}, {
initialRouteName: 'Foo',
tabBarComponent: BottomNavigationTabs,
tabBarOptions: {
indicatorStyle: {
height: 0 // remove indicator
}
}
}
)
const AuthStack = createStackNavigator({
Login: LoginScreen,
Baz: BazScreen,
}, {
headerMode: 'none',
})
const RootNavigator = createSwitchNavigator({
Main: TabNavigator,
AuthLoading: AuthLoadingScreen,
Auth: AuthStack,
}, {
initialRouteName: 'AuthLoading'
})
const AppContainer = createAppContainer(RootNavigator);
export default AppContainer
/src/App.js
import React, { Component } from 'react';
import { mapping, light as lightTheme } from '#eva-design/eva';
import { ApplicationProvider, Layout } from 'react-native-ui-kitten';
import ApplicationLoader from './ApplicationLoader'
import AppContainer from './Routes';
export class App extends Component {
render() {
return (
<ApplicationLoader assets={assets}>
<ApplicationProvider
mapping={mapping}
theme={lightTheme}>
<AppContainer/>
</ApplicationProvider>
</ApplicationLoader>
)
}
}
export default App
app.json
{
"expo": {
"name": "FooBar",
"slug": "foo-bar",
"privacy": "public",
"sdkVersion": "33.0.0",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#000"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.foo.bar"
},
"android": {
"package": "com.foo.bar"
}
}
}

Can't bind to 'options' since it isn't a known property of 'chart'

I have created a chart module using Angular2-highcharts but when I try to run the application I am getting the followoing error.
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'chart'. ("
<!-- <p text-center>Kye Info Page under construction</p> -->
<chart [ERROR ->][options]="chartOptions" type="chart"></chart>
</ion-content>
"): ng:///KeyinfoPageModule/KeyinfoPage.html#27:9
'chart' is not a known element:
1. If 'chart' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '#NgModule.schemas' of this component. ("
<ion-content>
Code
1. app.module.ts
import { ChartModule } from 'angular2-highcharts';
import * as highcharts from 'Highcharts';
imports: [
---------
ChartModule.forRoot(highcharts)
],
2. html File
<ion-content>
<chart [options]="chartOptions" type="chart"></chart>
</ion-content>
3. .ts file
export class KeyinfoPage {
chartOptions:any;
constructor(public navCtrl: NavController) {
}
ionViewDidLoad() {
this.chartOptions={chart: {
type: 'area'
},
title: {
text: 'US and USSR nuclear stockpiles'
},
subtitle: {
text: 'Source: <a href="http://thebulletin.metapress.com/content/c4120650912x74k7/fulltext.pdf">' +
'thebulletin.metapress.com</a>'
},
xAxis: {
allowDecimals: false,
labels: {
formatter: function () {
return this.value; // clean, unformatted number for year
}
}
},
yAxis: {
title: {
text: 'Nuclear weapon states'
},
labels: {
formatter: function () {
return this.value / 1000 + 'k';
}
}
},
tooltip: {
pointFormat: '{series.name} produced <b>{point.y:,.0f}</b><br/>warheads in {point.x}'
},
plotOptions: {
area: {
pointStart: 1940,
marker: {
enabled: false,
symbol: 'circle',
radius: 2,
states: {
hover: {
enabled: true
}
}
}
}
},
series: [{
name: 'USA',
data: [null, null, null, null, null, 6, 11, 32, 110, 235, 369, 640,
1005, 1436, 2063, 3057, 4618, 6444, 9822, 15468, 20434, 24126,
27387, 29459, 31056, 31982, 32040, 31233, 29224, 27342, 26662,
26956, 27912, 28999, 28965, 27826, 25579, 25722, 24826, 24605,
24304, 23464, 23708, 24099, 24357, 24237, 24401, 24344, 23586,
22380, 21004, 17287, 14747, 13076, 12555, 12144, 11009, 10950,
10871, 10824, 10577, 10527, 10475, 10421, 10358, 10295, 10104]
}, {
name: 'USSR/Russia',
data: [null, null, null, null, null, null, null, null, null, null,
5, 25, 50, 120, 150, 200, 426, 660, 869, 1060, 1605, 2471, 3322,
4238, 5221, 6129, 7089, 8339, 9399, 10538, 11643, 13092, 14478,
15915, 17385, 19055, 21205, 23044, 25393, 27935, 30062, 32049,
33952, 35804, 37431, 39197, 45000, 43000, 41000, 39000, 37000,
35000, 33000, 31000, 29000, 27000, 25000, 24000, 23000, 22000,
21000, 20000, 19000, 18000, 18000, 17000, 16000]
}]
}
console.log('ionViewDidLoad KeyinfoPage');
}
viewDashboard(){
this.navCtrl.setRoot('DashboardPage')
}
}
Please help me to solve this issue. I have found several questions like this but none of them helped me to solve this error. I am following this video to create the charts
https://www.youtube.com/watch?v=FSg8n5_uaWs&index=2&list=LLTJRcsGtG-ZMAf9dklVIikA&t=610s
keyinfo.module.ts
import { NgModule } from '#angular/core';
import { IonicPageModule } from 'ionic-angular';
import { KeyinfoPage } from './keyinfo';
import { ChartModule } from 'angular2-highcharts';
import * as highcharts from 'highcharts';
#NgModule({
declarations: [
KeyinfoPage,
],
imports: [
IonicPageModule.forChild(KeyinfoPage),
ChartModule
],
})
export class KeyinfoPageModule {}
You can set import the HighChartsModule in the IonicPageModule in which it is used instead of the app.module.ts
import { ChartModule } from 'angular2-highcharts';
import * as highcharts from 'highcharts';
#NgModule({
declarations: [
KeyinfoPage,
],
imports: [
IonicPageModule.forChild(KeyinfoPage),
ChartModule.forRoot(highcharts)
],
})
export class KeyinfoPageModule {}

Highcharts error bars not linking with the datapoints.

This could be trivial question, I am trying for past few hours on doing Error bars on Highcharts
Following is my fiddle
$(function() {
$('#container').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Temperature vs Rainfall'
},
xAxis: [{
}],
yAxis: [{ // Primary yAxis
labels: {
format: '{value} °C',
style: {
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: 'Temperature',
style: {
color: Highcharts.getOptions().colors[1]
}
}
}, { // Secondary yAxis
title: {
text: 'Rainfall',
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
format: '{value} mm',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}],
tooltip: {
shared: true
},
series: [{
"id": "1",
"name": "Gas",
"color": "#3366CC",
"data": [
[906.75, 0.0000100686],
[914.5, 0.0000101503],
[922.25, 0.0000102317],
[930, 0.000010313],
[937.75, 0.0000103941],
[945.5, 0.0000104751],
[953.25, 0.0000105558],
[961, 0.0000106364],
[968.75, 0.0000107168],
[976.5, 0.000010797],
[984.25, 0.000010877],
[992, 0.0000109569],
[999.75, 0.0000110366],
[1007.5, 0.0000111161],
[1015.25, 0.0000111954],
[1023, 0.0000112745],
[1030.75, 0.0000113535],
[1038.5, 0.0000114323],
[1046.25, 0.0000115108],
[1054, 0.0000115893],
[1061.75, 0.0000116675],
[1069.5, 0.0000117455],
[1077.25, 0.0000118234],
[1085, 0.000011901],
[1092.75, 0.0000119785],
[1100.5, 0.0000120558],
[1108.25, 0.000012133],
[1116, 0.0000122099],
[1123.75, 0.0000122866],
[1131.5, 0.0000123632],
[1139.25, 0.0000124396],
[1147, 0.0000125157],
[1154.75, 0.0000125917],
[1162.5, 0.0000126675],
[1170.25, 0.0000127432],
[1178, 0.0000128186],
[1185.75, 0.0000128938],
[1193.5, 0.0000129689],
[1201.25, 0.0000130437],
[1209, 0.0000131184],
[1216.75, 0.0000131929],
[1224.5, 0.0000132672],
[1232.25, 0.0000133413],
[1240, 0.0000134152],
[1247.75, 0.0000134889],
[1255.5, 0.0000135624],
[1263.25, 0.0000136357],
[1271, 0.0000137088],
[1278.75, 0.0000137818],
[1286.5, 0.0000138545],
[1294.25, 0.0000139271],
[1302, 0.0000139994],
[1309.75, 0.0000140716],
[1310, 0.0000140739],
[690, 0.00000771572],
[697.5, 0.00000779934],
[705.25, 0.00000788558],
[713, 0.00000797166],
[720.75, 0.00000805757],
[728.5, 0.00000814331],
[736.25, 0.00000822889],
[744, 0.0000083143],
[751.75, 0.00000839954],
[759.5, 0.00000848462],
[767.25, 0.00000856953],
[775, 0.00000865426],
[782.75, 0.00000873883],
[790.5, 0.00000882323],
[798.25, 0.00000890746],
[806, 0.00000899152],
[813.75, 0.00000907541],
[821.5, 0.00000915913],
[829.25, 0.00000924268],
[837, 0.00000932606],
[844.75, 0.00000940926],
[852.5, 0.00000949229],
[860.25, 0.00000957515],
[868, 0.00000965783],
[875.75, 0.00000974035],
[883.5, 0.00000982268],
[891.25, 0.00000990484],
[899, 0.00000998683]
]
}, {
"name": "Gas Uncertainity",
"color": "#3366CC",
"data": [
[0.0000079392, 0.000012198],
[0.00000804165, 0.00001225895],
[0.0000081433, 0.000012320100000000001],
[0.00000824331, 0.000012382689999999998],
[0.00000834055, 0.00001244765],
[0.000008434150000000001, 0.00001251605],
[0.00000852307, 0.00001258853],
[0.00000860678, 0.00001266602],
[0.00000868463, 0.00001274897],
[0.00000875628, 0.00001283772],
[0.00000882159, 0.000012932409999999999],
[0.00000888074, 0.00001303306],
[0.00000893391, 0.00001313929],
[0.0000089816, 0.0000132506],
[0.00000902445, 0.00001336635],
[0.00000906322, 0.00001348578],
[0.00000909888, 0.00001360812],
[0.00000913225, 0.00001373235],
[0.00000916418, 0.00001385742],
[0.000009195939999999999, 0.00001398266],
[0.00000922814, 0.00001410686],
[0.000009261779999999999, 0.00001422922],
[0.0000092978, 0.000014349],
[0.000009336759999999999, 0.000014465240000000001],
[0.00000937955, 0.00001457745],
[0.000009426630000000001, 0.00001468497],
[0.00000947856, 0.000014787440000000001],
[0.00000953547, 0.00001488433],
[0.00000959761, 0.00001497559],
[0.00000966503, 0.00001506137],
[0.00000973737, 0.00001514183],
[0.000009813969999999999, 0.00001521743],
[0.00000989415, 0.00001528925],
[0.000009976540000000001, 0.00001535846],
[0.0000100595, 0.0000154269],
[0.00001014056, 0.00001549664],
[0.00001021695, 0.00001557065],
[0.000010285320000000001, 0.00001565248],
[0.00001034137, 0.00001574603],
[0.000010380729999999999, 0.00001585607],
[0.00001039843, 0.00001598737],
[0.000010389550000000001, 0.000016144850000000002],
[0.00001034949, 0.000016333110000000002],
[0.00001027427, 0.00001655613],
[0.00001016072, 0.00001681708],
[0.00001000665, 0.00001711815],
[0.0000098107, 0.0000174607],
[0.00000957223, 0.00001784537],
[0.00000929121, 0.00001827239],
[0.00000896759, 0.000018741409999999997],
[0.00000860191, 0.000019252289999999998],
[0.0000081943, 0.0000198045],
[0.00000774527, 0.00002039793],
[0.00000773007, 0.000020417729999999998],
[0.000003741599999999999, 0.00001168984],
[0.000004200829999999999, 0.00001139785],
[0.00000463468, 0.00001113648],
[0.000005026089999999999, 0.00001091723],
[0.000005373990000000001, 0.00001074115],
[0.00000567765, 0.00001060897],
[0.000005937139999999999, 0.00001052064],
[0.000006153729999999999, 0.00001047487],
[0.000006330319999999999, 0.00001046876],
[0.00000647147, 0.00001049777],
[0.00000658298, 0.00001055608],
[0.0000066713, 0.00001063722],
[0.000006742800000000001, 0.00001073486],
[0.000006803219999999999, 0.00001084324],
[0.0000068574199999999995, 0.0000109575],
[0.00000690924, 0.000011073799999999999],
[0.0000069616, 0.00001118922],
[0.000007016640000000001, 0.00001130162],
[0.000007075800000000001, 0.00001140956],
[0.000007140009999999999, 0.000011512109999999998],
[0.00000720975, 0.000011608770000000001],
[0.00000728518, 0.0000116994],
[0.000007366199999999999, 0.0000117841],
[0.0000074524299999999996, 0.00001186323],
[0.000007543390000000001, 0.00001193731],
[0.00000763838, 0.00001200698],
[0.00000773662, 0.00001207306],
[0.000007837229999999999, 0.00001213643]
],
"type": "errorbar",
"tooltip": {
"pointFormat": "(Uncertainity: {point.low}-{point.high})<br/>"
},
"linkedTo": "1"
}]
});
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="height: 400px; margin: auto; min-width: 310px; max-width: 600px"></div>
http://jsfiddle.net/Dilip/m69wuyts/
The error bars are getting detached, not sure how to link them. Please help.
Thanks in advance.
Your error bar data should be in the form of [x, low, high] you have [low, high].
Also, you should sort your data by x values.
I added some processing to your data sets
http://jsfiddle.net/m69wuyts/1/

Resources