Skip to content

Instantly share code, notes, and snippets.

@MT-PL-SWF-Dev
Last active November 28, 2017 19:24
Show Gist options
  • Save MT-PL-SWF-Dev/cc9d5c8029b3516348eec6a6ee71d444 to your computer and use it in GitHub Desktop.
Save MT-PL-SWF-Dev/cc9d5c8029b3516348eec6a6ee71d444 to your computer and use it in GitHub Desktop.
Kendo chart bug repro
<template>
<require from="aurelia-kendoui-bridge/chart/chart"></require>
<a route-href="route.bind: 'welcome'">Go to somewhere else</a>
<ak-chart
k-title.bind="{text: 'Gross Domestic product growth GDP annual %'}"
k-legend.bind="{position: 'bottom'}"
k-series-defaults.bind="seriesDefaults"
k-series.bind="series"
k-value-axis.bind="valueAxis"
k-category-axis.bind="categoryAxis"
k-tooltip.bind="tooltip"
k-widget.two-way="chartWidget">
</ak-chart>
</template>
import {TaskQueue} from "aurelia-framework";
export class App {
static inject = [TaskQueue];
constructor(tq) {
this._taskQueue = tq;
}
attached() {
this._taskQueue.queueMicroTask((() => {
console.log("delayed");
this._chart = this.chartWidget;
}));
console.log("attach");
window.addEventListener("resize", this._resizeEventHandler, true);
}
detached() {
console.log("detach");
window.removeEventListener("resize", this._resizeEventHandler);
}
_resizeEventHandler = () => this._onResize();
_onResize(): void {
console.log("resized");
if (this.chartWidget) {
console.log("redraw");
this.chartWidget.redraw();
}
}
//////// DATA ////////////
seriesDefaults = {
type: 'area',
area: {
line: {
style: 'smooth'
}
}
};
series = [{
name: 'India',
data: [3.907, 7.943, 7.848, 9.284, 9.263, 9.801, 3.890, 8.238, 9.552, 6.855]
}, {
name: 'World',
data: [1.988, 2.733, 3.994, 3.464, 4.001, 3.939, 1.333, -2.245, 4.339, 2.727]
}, {
name: 'Haiti',
data: [-0.253, 0.362, -3.519, 1.799, 2.252, 3.343, 0.843, 2.877, -5.416, 5.590]
}];
valueAxis = {
labels: {
format: '{0}%'
},
line: {
visible: false
},
axisCrossingValue: -10
};
categoryAxis = {
categories: [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011],
majorGridLines: {
visible: false
},
labels: {
rotation: 'auto'
}
};
tooltip = {
visible: true,
format: '{0}%',
template: '${series.name} ${value}'
}
}
#undo {
text-align: center;
white-space: nowrap;
border-width: 1px;
border-style: solid;
padding: 2em;
cursor: pointer;
}
<!doctype html>
<html>
<head>
<title>Aurelia KendoUI bridge</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.common.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.default.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.mobile.all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.0/bluebird.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.2.1/chroma.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.3.1026/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.3.1026/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.3.1026/js/kendo.all.min.js"></script>
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script>
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-kendoui-bundles/1.0.0-beta.1.0.6/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-kendoui-bridge');
aurelia.start().then(a => a.setRoot('./shell.js'));
}
<template>
<router-view></router-view>
</template>
export class Shell {
configureRouter(config) {
config.map([
{
route: "",
name: "welcome",
moduleId: "./welcome.js"
},
{
route: "chart",
name: "chart",
moduleId: "./chart.js"
}
]);
}
}
<template>
<a route-href="route.bind: 'chart'">Go to chart</a>
</template>
export class Welcome {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment