I am a newbie to Nativescript and currently working on a Nativescript project using javascript. I am exploring the charts option and have installed the nativescript UI charts using the 'tns plugin add nativescript-ui-chart' command. When I try to display a simple line chart I do not get any errors, but nothing gets displayed as well.
Here is my XML file:
<Page class="page coverImage" navigatingTo="onNavigatingTo" xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:chart="nativescript-ui-chart">
<Label text="Test Charts Page"></Label>
<StackLayout>
<Label text="Test"></Label>
<chart:RadCartesianChart class="m-t-10" height="500">
<chart:RadCartesianChart.series>
<chart:LineSeries
items="{{ animeData }}"
categoryProperty="season"
valueProperty="count">
<chart:LineSeries.horizontalAxis>
<chart:CategoricalAxis labelFitMode="Rotate" />
</chart:LineSeries.horizontalAxis>
<chart:LineSeries.verticalAxis>
<chart:LinearAxis labelLayoutMode="Outer" />
</chart:LineSeries.verticalAxis>
</chart:LineSeries>
</chart:RadCartesianChart.series>
</chart:RadCartesianChart>
</StackLayout>
</Page>
My javascript file:
var frameModule = require("ui/frame");
var Observable = require("data/observable").Observable;
var pageData = new Observable();
pageData.animeData = [
{ season: "1", count: 82 }, { season: "2", count: 36 }, { season: "3", count: 41 },
{ season: "4", count: 52 }, { season: "5", count: 65 }, { season: "6", count: 40 },
{ season: "7", count: 52 }, { season: "8", count: 54 }, { season: "9", count: 47 },
{ season: "10", count: 52 }, { season: "11", count: 52 }, { season: "12", count: 53 },
{ season: "13", count: 34 }, { season: "14", count: 48 }, { season: "15", count: 49 },
{ season: "16", count: 45 }, { season: "17", count: 48 }, { season: "18", count: 45 },
{ season: "19", count: 47 }
];
exports.pageLoaded = function(args)
{
var page = args.object;
page.bindingContext = pageData;
};
I have added the nativescript-ui-chart to bundle.config as follows:
global.registerModule("nativescript-ui-chart",
() => require("../node_modules/nativescript-ui-chart"))
Package.json:
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.pregapp4",
"tns-ios": {
"version": "4.0.1"
}
},
"scripts": {
"lint": "eslint \"app/**/*.js\""
},
"dependencies": {
"nativescript-theme-core": "~1.0.4",
"nativescript-ui-chart": "^3.9.1",
"nativescript-ui-dataform": "^3.7.3",
"nativescript-ui-listview": "^3.7.2",
"nativescript-ui-sidedrawer": "^4.3.1",
"tns-core-modules": "^5.0.2"
},
"devDependencies": {
"eslint": "~4.9.0",
"nativescript-dev-sass": "~1.5.0",
"nativescript-dev-webpack": "~0.10.0",
"webpack": "~3.10.0",
"webpack-bundle-analyzer": "^2.9.1",
"webpack-sources": "~1.1.0",
"clean-webpack-plugin": "~0.1.19",
"copy-webpack-plugin": "~4.3.0",
"raw-loader": "~0.5.1",
"css-loader": "~0.28.7",
"nativescript-worker-loader": "~0.8.1",
"resolve-url-loader": "~2.2.1",
"extract-text-webpack-plugin": "~3.0.2",
"uglifyjs-webpack-plugin": "~1.1.6",
"sass-loader": "~6.0.6"
}
}
On running this I donot get an errors, but just a blank white space - not sure what I am missing - any help will be appreciated..