Flutter How to display JSON response on Listview - flutter

I want to display JSON data on Listview when I do button click, I can print valid JSON data on console so I want a way to show it on a listview, I am still a beginner in Flutter, your help will be appreaciated.
My model class
class Vehicle {
int? id;
int? sourceId;
int? serviceId;
int? categoryId;
String? category;
String? description;
dynamic value;
int? serviceResponsePropertyId;
int? mappingId;
bool? isVisible;
int? packageRequestId;
int? sortOrder;
Vehicle(
{required this.id,
required this.sourceId,
required this.serviceId,
required this.categoryId,
required this.category,
required this.description,
required this.value,
required this.serviceResponsePropertyId,
required this.mappingId,
required this.isVisible,
required this.packageRequestId,
required this.sortOrder});
Vehicle.fromJson(Map<String, dynamic> json) {
id = json['Id'];
sourceId = json['SourceId'];
serviceId = json['ServiceId'];
categoryId = json['CategoryId'];
category = json['Category'];
description = json['Description'];
value = json['Value'];
serviceResponsePropertyId = json['ServiceResponsePropertyId'];
mappingId = json['MappingId'];
isVisible = json['IsVisible'];
packageRequestId = json['PackageRequestId'];
sortOrder = json['SortOrder'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = {};
data['Id'] = id;
data['SourceId'] = sourceId;
data['ServiceId'] = serviceId;
data['CategoryId'] = categoryId;
data['Category'] = category;
data['Description'] = description;
data['Value'] = value;
data['ServiceResponsePropertyId'] = serviceResponsePropertyId;
data['MappingId'] = mappingId;
data['IsVisible'] = isVisible;
data['PackageRequestId'] = packageRequestId;
data['SortOrder'] = sortOrder;
return data;
}
}
JSON response
[
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 5,
"Category": "Valuation",
"Description": "AdjustedValues",
"Value": [],
"ServiceResponsePropertyId": 474,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 1,
"Category": "General",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 475,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "CarId",
"Value": 120354,
"ServiceResponsePropertyId": 100,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Year",
"Value": 2017,
"ServiceResponsePropertyId": 103,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 6
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Full Model Description",
"Value": "2017 AUDI A3 Sedan 1.0T FSI S tronic [2016-2017]",
"ServiceResponsePropertyId": 104,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Model",
"Value": "A3 Sedan 1.0T FSI S tronic [2016-2017]",
"ServiceResponsePropertyId": 105,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 5
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "ImageUrl",
"Value": "https://cdn.lightstoneauto.co.za/PHOTOS/AUDI/120354_1_Z7.jpg",
"ServiceResponsePropertyId": 107,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Make",
"Value": "AUDI",
"ServiceResponsePropertyId": 110,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 3
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Type",
"Value": "AUDI A3 Sedan",
"ServiceResponsePropertyId": 111,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 4
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 125,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 126,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13870410,
"SortOrder": 9999
},
{
"CarId": 0,
"SpecCategory": "General",
"Id": -1,
"SourceId": -1,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "Body shape",
"Value": "Sedan",
"ServiceResponsePropertyId": 320,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 9999
},
{
"CarId": 0,
"SpecCategory": "General",
"Id": -6,
"SourceId": -6,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "Drive type",
"Value": "4x2",
"ServiceResponsePropertyId": 154,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 9999
},
{
"CarId": 0,
"SpecCategory": "General",
"Id": -7,
"SourceId": -7,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "Fuel type",
"Value": "Petrol",
"ServiceResponsePropertyId": 153,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 9999
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "LastFiveSales",
"Value": [
{
"SaleId": 701436,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-06-24T14:09:04Z",
"SalePrice": 289900.0,
"MunicipalityName": "CITY OF TSHWANE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 698229,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-06-09T15:30:38Z",
"SalePrice": 299900.0,
"MunicipalityName": "CITY OF TSHWANE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 695530,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-05-30T13:24:17Z",
"SalePrice": 289995.0,
"MunicipalityName": "CITY OF TSHWANE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 685020,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-04-14T12:27:37Z",
"SalePrice": 366948.0,
"MunicipalityName": "EMFULENI",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 683843,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-04-11T15:00:38Z",
"SalePrice": 315500.0,
"MunicipalityName": "UMHLATHUZE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
}
],
"ServiceResponsePropertyId": 481,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 0
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 482,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13870410,
"SortOrder": 0
},
{
"EstimateType": "Auction",
"CarId": 0,
"Id": 1,
"SourceId": 1,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Auction Estimate",
"Value": 189400.0,
"ServiceResponsePropertyId": 494,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"EstimateType": "Cost",
"CarId": 0,
"Id": 2,
"SourceId": 2,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Cost Estimate",
"Value": 238300.0,
"ServiceResponsePropertyId": 495,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"EstimateType": "Cost",
"CarId": 0,
"Id": 3,
"SourceId": 3,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Cost Estimate High",
"Value": 259800.0,
"ServiceResponsePropertyId": 496,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 3
},
{
"EstimateType": "Cost",
"CarId": 0,
"Id": 4,
"SourceId": 4,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Cost Estimate Low",
"Value": 218700.0,
"ServiceResponsePropertyId": 497,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 2
},
{
"EstimateType": "Retail",
"CarId": 0,
"Id": 5,
"SourceId": 5,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Retail Estimate",
"Value": 300800.0,
"ServiceResponsePropertyId": 498,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"EstimateType": "Retail",
"CarId": 0,
"Id": 6,
"SourceId": 6,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Retail Estimate High",
"Value": 327900.0,
"ServiceResponsePropertyId": 499,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 3
},
{
"EstimateType": "Retail",
"CarId": 0,
"Id": 7,
"SourceId": 7,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Retail Estimate Low",
"Value": 276000.0,
"ServiceResponsePropertyId": 500,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 2
},
{
"EstimateType": "Trade",
"CarId": 0,
"Id": 8,
"SourceId": 8,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Trade Estimate",
"Value": 261300.0,
"ServiceResponsePropertyId": 501,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 1
},
{
"EstimateType": "Trade",
"CarId": 0,
"Id": 9,
"SourceId": 9,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Trade Estimate High",
"Value": 284900.0,
"ServiceResponsePropertyId": 502,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 3
},
{
"EstimateType": "Trade",
"CarId": 0,
"Id": 10,
"SourceId": 10,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Trade Estimate Low",
"Value": 239800.0,
"ServiceResponsePropertyId": 503,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13870410,
"SortOrder": 2
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 7,
"Category": "Report",
"Description": "ReportUrl",
"Value": "https://pdf.lightstoneauto.co.za/Index.aspx?sourceurl=https://cdn.lightstoneauto.co.za/REPORTS/LIVE/f1a817b0-6b13-479a-b667-19d4ecd65a65.html",
"ServiceResponsePropertyId": 0,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 7,
"Category": "Report",
"Description": "HtmlUrl",
"Value": "https://cdn.lightstoneauto.co.za/REPORTS/LIVE/f1a817b0-6b13-479a-b667-19d4ecd65a65.html",
"ServiceResponsePropertyId": 0,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
}
]
I want to only show certain items in the list,which are in "Value" like model, year, model etc..
My API function
Future<List<Vehicle>?> signInData() async {
final prefs = await SharedPreferences.getInstance();
final String? token = prefs.getString('token');
try {
Response response = await _dio.post('$_baseUrl/api/gateway',
data: {
"ClientPackageId": "0cdd231a-d7ad-4a68-a934-d373affb5100",
"PlatformId": "ios",
"ClientUserId": "AhmedOmar",
"VinNumber": VINumber
},
options: Options(
headers: {
"Content-Type": "application/json;charset=UTF-8",
"Charset": 'utf-8',
"Authorization": "Bearer $token",
},
));
print("data is here");
print(json.encode(response.data));
print(response.statusCode);
if (response.statusCode == 200) {
print("decoded");
final parsedJson = json.decode(json.encode(response.data));
print(
List<Vehicle>.from(parsedJson.map((job) => Vehicle.fromJson(job))));
return List<Vehicle>.from(
parsedJson.map((job) => Vehicle.fromJson(job)));
} else if (response.statusCode == 500) {
// call your refresh token api here and save it in shared preference
print(response.statusCode);
await getToken();
signInData();
} else {
throw Exception('Failed to load data');
}
} catch (e) {
print(e);
}
}
void showSnackBar(BuildContext context, String text) {
final snackBar = SnackBar(
content: Text(text),
duration: const Duration(seconds: 3), //default is 4s
);
// Find the Scaffold in the widget tree and use it to show a SnackBar.
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
}
The results I want to achieve is below, shown in a picture

You can do something like this : List<Vehicle> _vehicleList;
instead of return statement write :
_vehicleList = List<Vehicle>.from(
parsedJson.map((job) => Vehicle.fromJson(job)));
and then after setState((){});
and I hope that you have ListView is available inside Build method
ListView.builder(
itemBuilder: (BuildContext context, int index) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text($_vehicleList[index].category),
Text($_vehicleList[index].value),
],
);
},
itemCount: _vehicleList.length)

Related

RangeError (index): Invalid value: Not in inclusive range 0..5: 12

this is my first provider class. I'm trying to retrieve the name of my item from my list
before getting this error I got another error that said '_internallinkedhashmap<string, dynamic>' I search that online and add .cast<String, dynamic>().
now I'm getting this one. is this something to do with my list length
import 'package:ecnomic/provider/provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:provider/provider.dart';
import '../service/colors.dart';
class ItemProperties extends StatefulWidget {
const ItemProperties({super.key});
#override
State<ItemProperties> createState() => _ItemPropertiesState();
}
class _ItemPropertiesState extends State<ItemProperties> {
#override
Widget build(BuildContext context) {
List items = [];
final itemprovider =
Provider.of<onlineShopingProvider>(context, listen: false);
items = itemprovider.getOnlineItem;
return Container(
color: Colors.blue,
height: 500,
width: double.infinity,
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 5,
// mainAxisSpacing: 10,
// childAspectRatio: 3 / 2,
),
itemCount: 20,
itemBuilder: ((context, index) {
return
// Card(
// color: Colors.amber,
// child:
Column(
children: [
Image.network(
'https://hips.hearstapps.com/hmg-prod/images/2020-bmw-750i-xdrive-252-1566180109.jpg?crop=1.00xw:0.927xh;0,0.0366xh&resize=2048:*'),
Text('$index'),
Text(
'${itemprovider.getOnlineItem[index].item_name.cast<String, dynamic>()}'),
],
);
//);
})));
}
}
and this is my provider class
import 'package:flutter/material.dart';
class onlineShopingProvider with ChangeNotifier {
final dynamic _onlineitem = [
{
"item_id": 2,
"item_name": "Jeep Wrangler Sahara",
"item_price": "80000",
"item_image":
"https://www.motortrend.com/uploads/sites/11/2020/01/2020-Jeep-Wrangler-Unlimited-Sahara-4x4-25958.jpg?fit=around%7C875:492",
"category_id": 22,
"category_name": "Jeep",
"item_color": "#FF0000"
},
{
"item_id": 2,
"item_name": "Jeep Wrangler Sahara",
"item_price": "80000",
"item_image":
"https://www.motortrend.com/uploads/sites/11/2020/01/2020-Jeep-Wrangler-Unlimited-Sahara-4x4-25958.jpg?fit=around%7C875:492",
"category_id": 22,
"category_name": "Jeep",
"item_color": "#FF0000"
},
{
"item_id": 18,
"item_name": "Jeep Grand Cherokee Summit",
"item_price": "80000",
"item_image":
"https://hips.hearstapps.com/hmg-prod/images/2023-jeep-grand-cherokee-summit-4x4-101-1667328305.jpeg?crop=0.617xw:0.520xh;0.353xw,0.451xh&resize=2048:*",
"category_id": 22,
"category_name": "Jeep",
"item_color": "#FF0000"
},
{
"item_id": 3,
"item_name": "BMW X5",
"item_price": "100000",
"item_image":
"https://www.motortrend.com/uploads/2022/11/2023-BMW-X5-xDrive40i-front-three-quarter-view-11.jpg?fit=around%7C875:492.1875",
"category_id": 23,
"category_name": "BMW",
"item_color": "#000000"
},
{
"item_id": 4,
"item_name": "BMW 7 Series",
"item_price": "100000",
"item_image":
"https://hips.hearstapps.com/hmg-prod/images/2020-bmw-750i-xdrive-252-1566180109.jpg?crop=1.00xw:0.927xh;0,0.0366xh&resize=2048:*",
"category_id": 23,
"category_name": "BMW",
"item_color": "#000000"
},
{
"item_id": 4,
"item_name": "BMW 8 Series",
"item_price": "107000",
"item_image":
"https://www.caranddriver.com/photos/g27011971/2020-bmw-7-series-drive-gallery/",
"category_id": 23,
"category_name": "BMW",
"item_color": "#000000"
}
];
final dynamic shopingCatagory = [
{
"category_id": 22,
"category_name": "Jeep",
"category_image": "https://pngimg.com/uploads/jeep/jeep_PNG95.png"
},
{
"category_id": 24,
"category_name": "Toyota",
"category_image":
"https://www.freepnglogos.com/uploads/toyota-logo-png/toyota-logos-brands-logotypes-0.png"
},
{
"category_id": 23,
"category_name": "BMW",
"category_image":
"https://pngimg.com/uploads/bmw_logo/bmw_logo_PNG19714.png"
}
];
get getOnlineItem => _onlineitem;
get getShopingCatagory => shopingCatagory;
}
Your itemCount should be the size of the list, try changing to
itemCount: itemprovider.getOnlineItem.length,
And also change your text to this
Text(itemprovider.getOnlineItem[index]['item_name']),
You are setting hard-code value itemCount: 20, but list doesn't contains this much data. You can do
itemCount: items.lenght,
itemCount: items.length,
use size of your list.when you give item count greater than size of your list it will throw an error
also you dont have to access list in provider because you already assigned it to block variable items
items[index].item_name

Survey design for multilevel analysis

I am new in using R, and I need to run a multilevel analysis (two-phase design on two levels) using Cox frailty survival model on a survey data (Nigeria Demographic and Health Survey Data).
My problem is how to write the design weight using the two weights needed and apply them to the analysis.
I have identified the needed variables for the survey design, which are :
psu/cluster= v021
individual-level weight= wt1_1
cluster-level weigh= wt2_1
strata/stratum= v022
Please can someone help me with the survey design (svydesign) code and how to include it and the weights in a model.
I understand I have to use svycoxph in the model. Please how do I include survey design and account for the 2 weights (individual-level and cluster-level weights) in the gamma frailty model below?
Frailty1 <- coxph (Surv(study_time, died) ~ factor(v024) + factor(mat_edu) + v025 + frailty(v021,distribution="gamma"), data=rcom2018)
Really looking forward to your help as my project is hanging on this.
Many thanks.
library(survival)
#> Warning: package 'survival' was built under R version 4.0.5
library(frailtypack)
#> Warning: package 'frailtypack' was built under R version 4.0.5
#> Loading required package: boot
#>
#> Attaching package: 'boot'
#> The following object is masked from 'package:survival':
#>
#> aml
#> Loading required package: MASS
#> Loading required package: survC1
#> Warning: package 'survC1' was built under R version 4.0.5
#> Loading required package: doBy
#> Warning: package 'doBy' was built under R version 4.0.5
#>
#> Attaching package: 'frailtypack'
#> The following object is masked from 'package:survival':
#>
#> cluster
rcom1 <- data.frame(
data.frame(
pid = c(
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
93, 94, 95, 96, 97, 98, 99, 100
),
study_time = c(
13, 9, 17, 31, 39, 22, 24, 0, 23, 12, 9, 35,
18, 20, 60, 18, 5, 46, 26, 54, 37, 51, 31, 55, 27, 15, 39, 6,
29, 0, 9, 40, 23, 12, 35, 56, 14, 40, 57, 42, 5, 42, 39, 39,
54, 19, 52, 42, 7, 28, 53, 5, 28, 13, 37, 0, 23, 33, 27, 36, 20,
24, 58, 34, 12, 44, 3, 34, 14, 5, 10, 40, 12, 36, 19, 58, 17,
40, 39, 58, 53, 53, 1, 50, 2, 28, 24, 13, 13, 50, 46, 46, 19, 6,
32, 59, 9, 30, 30, 43
),
died = c(
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0
),
v021 = c(
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6
),
v022 = c(
"1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2"
),
v012 = c(
40, 37, 27, 27, 24, 32, 35, 35, 34, 20, 28,
28, 26, 24, 24, 25, 26, 26, 26, 26, 28, 27, 25, 25, 27, 26, 26,
21, 21, 31, 36, 36, 27, 23, 32, 32, 33, 33, 33, 28, 25, 37,
33, 34, 33, 28, 28, 29, 33, 33, 33, 39, 38, 38, 38, 38, 24, 27,
35, 40, 22, 38, 38, 21, 30, 30, 30, 39, 43, 18, 23, 23, 25, 25,
30, 45, 26, 26, 35, 35, 35, 35, 32, 32, 40, 25, 27, 30, 30, 30,
28, 28, 18, 27, 30, 30, 27, 21, 21, 30
),
wt2_1 = c(
401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031,
401.200012207031, 401.200012207031, 401.200012207031, 401.200012207031,
631.818176269531, 631.818176269531, 631.818176269531,
631.818176269531, 631.818176269531, 631.818176269531, 631.818176269531,
631.818176269531, 631.818176269531, 631.818176269531
),
wt1_1 = c(
2.5074667930603, 2.5074667930603,
2.5074667930603, 2.5074667930603, 2.5074667930603, 2.5074667930603,
2.5074667930603, 2.5074667930603, 2.5074667930603, 2.5074667930603,
2.5074667930603, 2.5074667930603, 2.5074667930603,
2.5074667930603, 2.5074667930603, 5.1194109916687, 5.1194109916687,
5.1194109916687, 5.1194109916687, 5.1194109916687, 5.1194109916687,
5.1194109916687, 5.1194109916687, 5.1194109916687,
5.1194109916687, 5.1194109916687, 5.1194109916687, 5.1194109916687,
5.1194109916687, 5.1194109916687, 5.1194109916687, 5.1194109916687,
5.1194109916687, 5.1194109916687, 2.40910983085632,
2.40910983085632, 2.40910983085632, 2.40910983085632, 2.40910983085632,
2.40910983085632, 2.40910983085632, 2.40910983085632,
2.40910983085632, 2.40910983085632, 2.40910983085632, 2.40910983085632,
2.40910983085632, 2.40910983085632, 1.06203985214233,
1.06203985214233, 1.06203985214233, 1.06203985214233, 1.06203985214233,
1.06203985214233, 1.06203985214233, 1.06203985214233,
1.06203985214233, 1.06203985214233, 1.06203985214233, 1.06203985214233,
1.06203985214233, 1.06203985214233, 1.06203985214233,
1.06203985214233, 1.06203985214233, 1.06203985214233, 1.06203985214233,
2.80098295211792, 2.80098295211792, 2.80098295211792,
2.80098295211792, 2.80098295211792, 2.80098295211792, 2.80098295211792,
2.80098295211792, 2.80098295211792, 2.80098295211792,
2.80098295211792, 2.80098295211792, 2.80098295211792, 2.80098295211792,
2.80098295211792, 2.80098295211792, 2.80098295211792,
2.80098295211792, 2.80098295211792, 2.80098295211792, 2.80098295211792,
2.80098295211792, 2.80098295211792, 1.24210178852081,
1.24210178852081, 1.24210178852081, 1.24210178852081, 1.24210178852081,
1.24210178852081, 1.24210178852081, 1.24210178852081,
1.24210178852081, 1.24210178852081
),
v024 = c(
"1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1"
),
v025 = c(
"1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2"
),
mat_edu = c(
"5", "5", "5", "4", "4", "5", "4", "4", "4",
"4", "4", "4", "5", "5", "5", "5", "5", "5", "4", "4", "5",
"4", "4", "4", "5", "3", "3", "4", "4", "5", "5", "5", "5", "4",
"2", "2", "0", "0", "0", "5", "5", "0", "1", "5", "5", "3",
"3", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "4", "5",
"5", "4", "5", "5", "3", "4", "4", "5", "3", "1", "3", "3", "3",
"1", "3", "2", "1", "3", "3", "4", "4", "0", "0", "2", "2",
"1", "0", "4", "4", "4", "4", "0", "0", "3", "4", "2", "2", "3",
"3", "3", "0"
)
)
)
Created on 2022-02-01 by the reprex package (v2.0.1)

Heat Map using Chart::Gnuplot Perl

I was trying to create something like
But I was not able to get the x and y axis tics coming in
I tried something like this to see if the x axis tics are coming
my #data = (
[0, 0, 10],
[0, 1, 10],
[0, 2, 10],
[],
[1, 0, 10],
[1, 1, 5],
[1, 2, 10],
[],
[2, 0, 10],
[2, 1, 1],
[2, 2, 10],
[],
[3, 0, 10],
[3, 1, 0],
[3, 2, 10],
);
my $chart = Chart::Gnuplot->new(
output => "test1.png",
title => "3D plot from arrays of x, y and z coordinates",
xlabel => 'x',
ylabel => 'y',
xtics => {
labels => ['"pi" 3.1416', '"-pi" -3.1416'],
},
);
$chart->set(pm3d => 'map');
$chart->set(palette => 'defined (0 0 0 1, 1 1 1 0, 2 1 0 0)');
my $dataSet = Chart::Gnuplot::DataSet->new(
points => \#data,
);
$chart->plot3d($dataSet);
I am not sure how the dataset should be and how the x and y axis tics should be added
I tested the above with some examples that I got from the internet but was not able to see the result .
Any help to get this like the image would be greatly appreciated
Got one more issue, when tried to get all the values on X and Y axis, the xtics and ytics are not showing fully as in the above image, the one I got seems like this
The dataset is like this
[
0,
1,
'2.66556908091426'
],
[
0,
2,
'4.37897014657203'
],
[
0,
3,
'1.22514023397498'
],
[
0,
4,
'4.53000730040497'
],
[
0,
5,
'3.01982096624856'
],
[
0,
6,
'0.499618756879272'
],
[
0,
7,
'4.84182728928223'
],
[
0,
8,
'1.96005062661005'
],
[
0,
9,
'2.42800730644825'
],
[
0,
10,
'1.86670807696721'
],
[
0,
11,
'1.81614100038358'
],
[
0,
12,
'4.39616981937487'
],
[
0,
13,
'3.35256272447085'
],
[
0,
14,
'3.24814393010016'
],
[
0,
15,
'1.06219230833835'
],
[
0,
16,
'1.12793288928973'
],
[
0,
17,
'3.26476861756371'
],
[
0,
18,
'3.10578946862982'
],
[
0,
19,
'2.93146341009402'
],
[
0,
20,
'1.72192716962012'
],
[
0,
21,
'4.04316953579938'
],
[
0,
22,
'0.32291976646917'
],
[
0,
23,
'4.42019093014144'
],
[
0,
24,
'3.31129513399691'
],
[
0,
25,
'4.561835018284'
],
[
0,
26,
'1.23709783845847'
],
[
0,
27,
'2.65864379090912'
],
[
0,
28,
'2.30212288203429'
],
[
0,
29,
'0.621743568938786'
],
[
0,
30,
'1.80416068716383'
],
[
0,
31,
'2.66465304546164'
],
[
0,
32,
'3.45680173240485'
],
[
0,
33,
'2.70739617274879'
],
[
0,
34,
'1.11428672300967'
],
[
0,
35,
'1.67761705545201'
],
[
0,
36,
'2.74299975084073'
],
[
0,
37,
'1.80397491377351'
],
[
0,
38,
'4.47728976228916'
],
[
0,
39,
'4.68895286431879'
],
[
0,
40,
'0.14021332300036'
],
[
0,
41,
'2.33736192052044'
],
[
0,
42,
'0.177482592020581'
],
[
0,
43,
'4.73906999291613'
],
[
0,
44,
'2.31796437164231'
],
[
0,
45,
'3.99016409499582'
],
[
0,
46,
'3.38293261332254'
],
[
0,
47,
'2.61350773461833'
],
[
0,
48,
'4.73763682658106'
],
[
0,
49,
'0.882213941365624'
],
[
0,
50,
'0.772076148467349'
],
[
0,
51,
'0.211627911950369'
],
[
0,
52,
'0.983901796963771'
],
[
0,
53,
'4.20512536118553'
],
[
0,
54,
'1.23297443353948'
],
[
0,
55,
'3.81554353946163'
],
[
0,
56,
'3.65498488100304'
],
[
0,
57,
'2.57928958709011'
],
[
0,
58,
'2.59561593117475'
],
[
0,
59,
'0.00576648038274286'
],
[
0,
60,
'3.7901264909274'
],
[
0,
61,
'2.01073954816936'
],
[
0,
62,
'4.20235419868604'
],
[
0,
63,
'0.0699755500835941'
],
[
0,
64,
'1.89704728306967'
],
[
0,
65,
'3.60775496050488'
],
[
0,
66,
'0.210700948492715'
],
[
0,
67,
'1.46456716998541'
],
[
0,
68,
'1.17475107720264'
],
[
0,
69,
'3.05671437798837'
],
[
0,
70,
'2.68927795266336'
],
[
0,
71,
'2.51310517387102'
],
[
0,
72,
'2.47339733795219'
],
[
0,
73,
'0.0279383841017911'
],
[
0,
74,
'0.722901884055389'
],
[
0,
75,
'2.87491127698443'
],
[
0,
76,
'4.06219968687022'
],
[
0,
77,
'1.10014911730135'
],
[
0,
78,
'2.12579086549013'
],
[
0,
79,
'0.969934599414497'
],
[
0,
80,
'0.0104263290325335'
],
[
0,
81,
'4.76235946351673'
],
[
0,
82,
'0.790123228138313'
],
[
0,
83,
'0.0974340515172223'
],
[
0,
84,
'2.25078802534153'
],
[
0,
85,
'1.52078958155231'
],
[
0,
86,
'1.81615557330844'
],
[
0,
87,
'4.29625290304719'
],
[
0,
88,
'3.46711963355933'
],
[
0,
89,
'3.9427030133586'
],
[
0,
90,
'0.10345150062939'
],
[
0,
91,
'3.43953703174092'
],
[
0,
92,
'4.31073758997368'
],
[
0,
93,
'2.58639853373042'
],
[
0,
94,
'4.08224212269872'
],
[],
Here is an example of how you can set the axis labels:
use strict;
use warnings;
use Chart::Gnuplot;
my #data = (
[0, 0, 10],
[0, 1, 10],
[0, 2, 10],
[0, 3, 10],
[],
[1, 0, 10],
[1, 1, 5],
[1, 2, 10],
[1, 3, 10],
[],
[2, 0, 10],
[2, 1, 1],
[2, 2, 1],
[2, 3, 10],
[],
[3, 0, 10],
[3, 1, 0],
[3, 2, 5],
[3, 3, 10],
);
my $chart = Chart::Gnuplot->new(
bg => 'white',
pm3d => 'map',
palette => 'defined (0 0 0 1, 1 1 1 0, 2 1 0 0)',
output => "test.png",
title => "3D plot from arrays of x, y and z coordinates",
xlabel => 'x',
ylabel => 'y',
xtics => {
labels => ['"0030" 0', '"0100" 1', '"0130" 2', '"0200" 3'],
rotate => 90,
},
ytics => {
labels => ['"04-Oct" 0', '"03-Oct" 1', '"02-Oct" 2', '"01-Oct" 3'],
},
);
my $dataSet = Chart::Gnuplot::DataSet->new( points => \#data );
$chart->plot3d($dataSet);
Update:
You can create the xtics in a loop like this (given a DataTime $dt):
my #xtics;
for ( my $i=0; $i<($interval_count-1); $i++ ){
$dt->add(minutes => $interval_period);
my $xtic = '"' . $dt->hour . ':' . $dt->minute . '"' . ' ' . $i;
push #xtics, $xtic;
}
Then set the xtics parameter to Chart::Gnuplot->new() like this:
xtics => { labels => \#xtics, rotate => 90, },

How can I properly setup flow with eslint?

My .eslintrc file is:
{
"extends": "google",
"plugins": [
"mocha",
"flowtype"
],
"rules": {
"strict": [
"error",
"never"
],
"comma-dangle": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"always"
],
"require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": false,
"ArrowFunctionExpression": false,
"FunctionExpression": false
}
}
],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"semi": [
"warn",
"always"
],
"no-console": [
"warn",
{
"allow": [
"debug",
"error"
]
}
],
"max-len": [
"off"
],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "should"
}
],
"flowtype/boolean-style": [
2,
"boolean"
],
"flowtype/define-flow-type": 1,
"flowtype/delimiter-dangle": [
2,
"never"
],
"flowtype/generic-spacing": [
2,
"never"
],
"flowtype/no-primitive-constructor-types": 2,
"flowtype/no-types-missing-file-annotation": 2,
"flowtype/no-weak-types": 2,
"flowtype/object-type-delimiter": [
2,
"comma"
],
"flowtype/require-parameter-type": 2,
"flowtype/require-return-type": [
2,
"always",
{
"annotateUndefined": "never"
}
],
"flowtype/require-valid-file-annotation": 2,
"flowtype/semi": [
2,
"always"
],
"flowtype/space-after-type-colon": [
2,
"always"
],
"flowtype/space-before-generic-bracket": [
2,
"never"
],
"flowtype/space-before-type-colon": [
2,
"never"
],
"flowtype/type-id-match": [
2,
"^([A-Z][a-z0-9]+)+Type$"
],
"flowtype/union-intersection-spacing": [
2,
"always"
],
"flowtype/use-flow-type": 1,
"flowtype/valid-syntax": 1
},
"env": {
"es6": true,
"node": true
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": false
}
}
}
VSCode still shows:
Changing my .eslintrc to:
{
"extends": "google",
"parser": "babel-eslint",
"plugins": [
"mocha",
"flowtype"
],
"rules": {
"strict": [
"error",
"never"
],
"comma-dangle": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"always"
],
"require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": false,
"ArrowFunctionExpression": false,
"FunctionExpression": false
}
}
],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"semi": [
"warn",
"always"
],
"no-console": [
"warn",
{
"allow": [
"debug",
"error"
]
}
],
"max-len": [
"off"
],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "should"
}
]
},
"env": {
"es6": true,
"node": true
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
}
}
}
helped

How to put date into drilldown chart title based on drilled point x value (datetime)..?

My drilldown works fine, yet I can't figure out how to make my drilldown chart title show the drilled point x value (datetime) in the format "Sales of YYYY-MM-DD".
Going back to initial chart title "Sales" (on drillup event) works good.
$(function () {
Highcharts.setOptions({
global: {
useUTC: false,
timeZoneOffset: -180
},
lang: {
drillUpText: ' < Back '
}
});
// Create the chart
$('#container').highcharts({
credits: {
enabled: false
},
xAxis: [{
id: 0,
minorTickLength: 0,
labels: {
y: 15,
format: '{value:%e %b}',
zIndex: 0
},
tickPixelInterval: 10,
tickWidth: 0,
title: {
text: null
},
tickColor: '#e0e0e0',
pointPadding: 0.05,
tickmarkPlacement: 'on',
type: 'datetime'
},{
id: 1,
minorTickLength: 0,
labels: {
y: 15,
zIndex: 0
},
tickPixelInterval: 2,
tickWidth: 0,
title: {
text: null
},
tickColor: '#e0e0e0',
pointPadding: 0.2,
tickmarkPlacement: 'on',
type: 'category',
lineWidth: 0
}],
yAxis: {
gridLineWidth: 0,
gridLineColor: '#e0e0e0',
labels: {
y: 0,
x: 0,
overflow: 'justify',
enabled: false,
maxStaggerLines: 0,
align: 'center'
},
title: {
margin: 0,
text: null
},
gridLineInterpolation: null
},
tooltip: {
enabled: false,
shared: true,
xDateFormat: '%e %b',
valueSuffix: ' Lt',
borderColor: 'null',
borderRadius: 10
},
plotOptions: {
areaspline: {
lineColor: '#c0c0c0',
marker: {
enabled: false,
fillColor: '#e0e0e0',
radius: 3,
lineWidth: 1,
lineColor: '#c0c0c0'
},
lineWidth: 1,
states: {
hover: {
marker: {
radius: 3,
lineWidth: 1
}
}
}
},
column: {
allowPointSelect: false,
cursor: 'pointer',
dataLabels: {
enabled: true,
inside: false,
overflow: 'none',
y: -10,
x: 0,
verticalAlign: 'middle',
padding: 0,
}
}
},
chart: {
events: {
drilldown: function(){
UpdateTitle('Sales of '+this)
},
drillup: function(){
UpdateTitle('Sales')
}
},
spacingBottom: 20,
type: 'column',
borderRadius: 2,
spacingTop: 0,
width: 1012,
marginLeft: 0,
pacingRight: 0,
marginBottom: 40,
marginRight: 0,
marginTop: 20,
height: 180,
spacingLeft: 0
},
title: {
margin: 10,
y: 15,
text: 'Sales',
x: 20,
align: 'left',
},
Exporting: {
scale: 1,
buttons: {
contextButton: {
enabled: false
}
},
enabled: false
},
legend: {
enabled: false,
symbolWidth: 12
},
series: [ {
index: 1,
type: 'column',
color: '#30bf09',
name: 'Sales',
data: [{
x: 1399410000000,
y: 16675,
drilldown: 'day01'
},{
x: 1399496400000,
y: 6906,
drilldown: 'day02'
},{
x: 1399582800000,
y: 5290,
drilldown: 'day03'
},{
x: 1399669200000,
y: 764,
drilldown: 'day04'
},{
x: 1399755600000,
y: 248,
drilldown: 'day05'
},{
x: 1399842000000,
y: 8585,
drilldown: 'day06'
},{
x: 1399928400000,
y: 5176,
drilldown: 'day07'
},{
x: 1400014800000,
y: 10836,
drilldown: 'day08'
},{
x: 1400101200000,
y: 13217,
drilldown: 'day09'
},{
x: 1400187600000,
y: 7213,
drilldown: 'day10'
},{
x: 1400274000000,
y: 711,
drilldown: 'day11'
},{
x: 1400360400000,
y: 1038,
drilldown: 'day12'
},{
x: 1400446800000,
y: 6612,
drilldown: 'day13'
},{
x: 1400533200000,
y: 14496,
drilldown: 'day14'
}]
},{
index: 0,
type: 'areaspline',
color: '#e0e0e0',
name: 'Planas',
data: [
[1399410000000, 2930],
[1399496400000, 2930],
[1399582800000, 2930],
[1399669200000, 0],
[1399755600000, 0],
[1399842000000, 2930],
[1399928400000, 2930],
[1400014800000, 2930],
[1400101200000, 2930],
[1400187600000, 2930],
[1400274000000, 0],
[1400360400000, 0],
[1400446800000, 2930],
[1400533200000, 2930]
]
}],
drilldown: {
activeAxisLabelStyle: {
textDecoration: 'none',
fontWeight: 'regular',
color: '7f7f7f'
},
activeDataLabelStyle: {
textDecoration: 'none',
fontWeight: 'semi-bold',
color: '4c4c4c'
},
drillUpButton: {
relativeTo: 'spacingBox',
position: {
align: 'right',
x: 0,
y: 0,
verticalAlign: 'top'
}
},
series: [{
id: 'day01',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Presta', 2000],
['Export', 600],
['ESET', 75],
['SoftMak', 75],
['Google', 750],
['Blancco', 0],
['Axence', 200],
['Kiti', 1500],
['...', 0],
['...', 0],
['Box', 550],
['Nuoma', 75]
]
},{
id: 'day02',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftM', 75],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ]
]
},{
id: 'day03',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day04',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day05',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day06',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day07',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day08',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day09',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day10',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day11',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day12',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day13',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75]
]
},{
id: 'day14',
xAxis: 1,
data: [
['ESET', 10000],
['OERP', 4000],
['Google', 2000],
['Export', 600],
['SoftMaker', 75],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ],
[ , ]
]}
]
}
})
var chart = $('#container').highcharts();
function UpdateTitle(argument1) {
chart.setTitle({text: argument1})
}
In a drilldown event you have access to clicked point: e.point. For example to get timestamp of clicked point use e.point.x. Now simply parse that timestamps to required format and it should work. See: http://jsfiddle.net/nJFZN/
drilldown: function (e) {
UpdateTitle('Sales of ' + e.point.x)
},