I'm using highchart in an android app to display a dynamic chart that is updated every 3 secs and displayed over one day.
My chart is composed of two fixed data series displaying the limit that the monitored data should not exceed, and obviously the monitored data (power value)
All the power value from 00:05 to the moment the chart is loaded, are first displayed. And then, every 3 seconds, a value is added to this serie.
The problem is when I try to zoom to the end point of my power values. The power data line (and only this one) disappear when I zoom in. If I zoom out, the line reappears. But if I zoom on an area where the end point of my data power line is not displayed, everything goes right.
I tried to remove the two fixed serie (it adjust my chart height to the length of the power data line but whatever), and the same zoom problem appears. I can't zoom to the end point of my power data line but I can zoom anywhere else.
I also tried to use datagrouping, but the problem stay the same
Here is my code:
$(function() {
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: true
}
});
var dataPower = Android.getDayHistory((new Date()).getHours(), (new Date()).getMinutes(), (new Date()).getSeconds());
//var dataPower = [];
console.log(dataPower);
// Create the chart
$('#container').highcharts(
'StockChart',
{
chart : {
type : 'line',
backgroundColor : '#d6d7d4',
ignoreHiddenSeries: false,
zoomType : 'x',
marginRight : 10,
events : {
load : function() {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Android.getData((new Date()).getHours(),(new Date()).getMinutes(), (new Date()).getSeconds());
series.addPoint([ x, y ]);
Android.checkAlert((new Date()).getHours(),(new Date()).getMinutes(), (new Date()).getSeconds());
}, 3000);
}
},
},
rangeSelector : {
buttons : [ {
type : 'minute',
count : 2,
text : '2m'
}, {
type : 'minute',
count : 5,
text : '5m'
}, {
type : 'minute',
count : 30,
text : '30m'
}, {
type : 'hour',
count : 1,
text : '1h'
}, {
type : 'all',
text : 'All'
} ],
selected : 4,
inputEnabled : false,
},
xAxis : {
ordinal : false,
minRange : 36000
},
yAxis : {
title : {
text : 'Power (MW)'
},
max : 500,
plotBands : [ {
from : 0,
to : 100,
color : 'rgba(247, 247, 247, 0.3)'
}, {
from : 100,
to : 200,
color : 'rgba(215, 216, 212, 0.3)'
}, { // Light breeze
from : 200,
to : 300,
color : 'rgba(247, 247, 247, 0.3)'
}, { // Light breeze
from : 300,
to : 400,
color : 'rgba(215, 216, 212, 0.3)'
}, {
from : 400,
to : 500,
color : 'rgba(247, 247, 247, 0.3)'
} ]
},
plotOptions: {
spline: {
lineWidth: 2,
states: {
hover: {
enabled: true,
lineWidth: 3
}
},
marker: {
enabled: false,
states: {
hover: {
enabled : true,
radius: 5,
lineWidth: 1
}
}
}
}
},
title : {},
subtitle : {},
navigator : {
enabled : false
},
scrollbar : {
enabled : false
},
credits : {
enabled : false
},
series : [
{
name : 'Power',
data : eval('[' + dataPower + ']'),
pointStart : Date.UTC((new Date()).getFullYear(),
(new Date()).getMonth(), (new Date()).getDate()),
pointInterval : 3000,
},
{
data : [
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 0,
5, 0), 40 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 7,
0, 0), 40 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 7,
30, 0), 440 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 11,
57, 0), 440 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 12,
3, 0), 390 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 13,
57, 0), 390 ]
,
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 14,
3, 0), 440 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 17,
3, 0), 440 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 23,
55, 0), 40 ]
],
type : 'line',
color : "#d3a6ad",
enableMouseTracking : false
},
{
data : [
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 0,
5, 0), 60 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 7,
0, 0), 60 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 7,
30, 0), 460 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 11,
57, 0), 460 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 12,
3, 0), 410 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 13,
57, 0), 410 ]
,
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 14,
3, 0), 460 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 17,
3, 0), 460 ],
[
Date.UTC(
(new Date()).getFullYear(),
(new Date()).getMonth(),
(new Date()).getDate(), 23,
55, 0), 60 ]
],
type : 'line',
color : "#d3a6ad",
enableMouseTracking : false
} ]
});
});
});
Related
I've been trying pretty hard to add an onClick function on my clusters that zooms a bit on the map, but I can't figure out how to do so, and I can't find any help on the documentation.
I've been trying to work with controller.onCircleTappedand controller.onFeatureTapped but I don't understand how it's working, or how to link the callback to a particular cluster.
Thank you all!
Here's my current code:
`
Future<void> addGeojsonCluster() async {
var geojson = {
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "pois" } },
"features": [
for(var marker in markers){
"type" : "Feature", "properties" : {"id" : marker.title}, "geometry": {"type" : "Point", "coordinates" : [marker.longitude, marker.latitude] }
},
]
};
await controller.addSource(
"poi",
GeojsonSourceProperties(
data: geojson,
cluster: true,
clusterMaxZoom: 14, // Max zoom to cluster points on
clusterRadius:
50, // Radius of each cluster when clustering points (defaults to 50)
)
);
await controller.addLayer(
"poi",
"poi-circles",
const CircleLayerProperties(
circleColor: [
Expressions.step,
[Expressions.get, 'point_count'],
'#51bbd6', //blue
100,
'#f1f075', //yellow
750,
'#f28cb1' //pink
],
circleRadius: [
Expressions.step,
[Expressions.get, 'point_count'],
20,
100,
30,
750,
40
]),
);
await controller.addSymbolLayer(
"poi",
"unclustered-point",
const SymbolLayerProperties(
textField: [Expressions.get, "id"],
textHaloWidth: 1,
textSize: 12.5,
textHaloColor: '#ffffff',
textOffset: [
Expressions.literal,
[0, 2]
],
iconImage: "images/mapbox_circle_marker.png",
iconSize: 2,
iconAllowOverlap: true,
textAllowOverlap: true,
textColor: '#000000',
textHaloBlur: 1,
),
filter: [
'!',
['has', 'point_count']
],
enableInteraction: true,
);
await controller.addLayer(
"poi",
"poi-count",
const SymbolLayerProperties(
textField: [Expressions.get, 'point_count_abbreviated'],
textFont: ['DIN Offc Pro Medium', 'Arial Unicode MS Bold'],
textSize: 12,
));
}
`
You need to register a OnTapListener on the whole map and query all the features on the map.
MapWidget(
onTapListener: _clickMap,
)
And in _clickMap you query for everything displayed on the map and decide depending on the return what to do. Here I zoom in to the next cluster step. Keep in mind, that there is currently a confirmed bug in the sdk. OnTapListener is not return ScreenCoordinates but geographical coordinates. So you need to convert them first with pixelForCoordinate.
void _clickMap(ScreenCoordinate coordinate) async {
ScreenCoordinate coordin = await mapboxMap!.pixelForCoordinate({
"coordinates": [coordinate.y, coordinate.x]
});
List<QueriedFeature?> features = await mapboxMap!.queryRenderedFeatures(
RenderedQueryGeometry(
type: Type.SCREEN_COORDINATE, value: json.encode(coordin.encode())),
RenderedQueryOptions(
layerIds: ['clusters', "unclustered-point"], filter: null));
if (features.isNotEmpty) {
if ((features[0]!.feature["properties"] as Map)['cluster'] != null) {
FeatureExtensionValue cluster = await mapboxMap!
.getGeoJsonClusterExpansionZoom(
'earthquakes', features[0]!.feature);
mapboxMap?.easeTo(
CameraOptions(
center: Point(
coordinates: Position(
(features[0]!.feature['geometry'] as Map)["coordinates"][0],
(features[0]!.feature['geometry'] as Map)["coordinates"][1],
)).toJson(),
zoom: double.parse(cluster.value!),
bearing: 0,
pitch: 0),
MapAnimationOptions(duration: 500, startDelay: 0));
}}}
Hope that helps :)
I am developing an react-native app that gets the weight value of a scale(MI SCALE2) that supports Bluetooth.(I have no knowledge of bluetooth.)
// version
"react-native": "0.66.1",
"react-native-ble-plx": "https://github.com/below/react-native-ble-plx",
I was able to get these values when I got on the scale.
# feature
{"data": [33, 0, 0, 0], "type": "Buffer"}
# Weight
{"data": [2, 156, 74, 178, 7, 1, 7, 22, 33, 1], "type": "Buffer"}
{"data": [2, 156, 74, 178, 7, 1, 7, 22, 33, 1], "type": "Buffer"}
{"data": [2, 156, 74, 178, 7, 1, 7, 22, 33, 1], "type": "Buffer"}
{"data": [2, 156, 74, 178, 7, 1, 7, 22, 33, 2], "type": "Buffer"}
{"data": [2, 156, 74, 178, 7, 1, 7, 22, 33, 2], "type": "Buffer"}
{"data": [34, 156, 74, 178, 7, 1, 7, 22, 33, 2], "type": "Buffer"}
{"data": [162, 156, 74, 178, 7, 1, 7, 22, 33, 6], "type": "Buffer"}
After reading the Q&A in several places, I know that it is necessary to combine the value of the feature with the value of the weight array.
I want to know how to get the weight value from my result like "94.9kg, 95.5kg, ..."
Below is the code I wrote.
manager.startDeviceScan(null, null, (error, device) => {
if (error) {
console.log('error : ' + error);
return;
}
console.log(device.name);
if (device.name === 'MI SCALE2') {
console.log('detected!!');
manager.stopDeviceScan();
device
.connect()
.then(device => {
return device.discoverAllServicesAndCharacteristics();
})
.then(device => {
return device.services();
})
.then(services => {
const result = services.filter(id => id.uuid.indexOf('181d') != -1); // 181d is Weight Scale -> org.bluetooth.service.weight_scale;
return result[0].characteristics();
})
.then(characters => {
const resultDateObject = characters.filter(
data => data.uuid.indexOf('2a2b') != -1, // 2a2b is Current Time -> org.bluetooth.characteristic.current_time;
);
const resultWeightFeature = characters.filter(
data => data.uuid.indexOf('2a9e') != -1, // 2a9e is Weight Scale Feature -> org.bluetooth.characteristic.weight_scale_feature
);
const resultWeight = characters.filter(
data => data.uuid.indexOf('2a9d') != -1, // 2a9d is Weight Measurement -> org.bluetooth.characteristic.weight_measurement;
);
const resultPosition2D = characters.filter(
data => data.uuid.indexOf('2a2f') != -1, // 2a2f is Position 2D -> org.bluetooth.characteristic.position_2d;
);
// const DeviceID = resultWeightFeature[0].deviceID;
// const ServiceUUID = resultWeightFeature[0].serviceUUID;
// const DateCharacterUUID = resultDateObject[0].uuid;
// const WeightFeatureCharacterUUID = resultWeightFeature[0].uuid;
// const WeightCharacterUUID = resultWeight[0].uuid;
// const PositionCharacterUUID = resultPosition2D[0].uuid;
resultWeight[0].monitor((error, characteristic) => {
if (error) {
console.log('error:::::', error);
return;
}
let your_bytes = Buffer.from(characteristic.value, "base64");
console.log(your_bytes);
})
return resultWeightFeature[0].read();
}).then(feature => {
let feature_bytes = Buffer.from(feature.value, "base64");
console.log('feature.value');
console.log(feature_bytes);
})
}
});
As far as I understand your Code, your weight scale makes use of Bluetooth Weight Scale Profile and Weight Scale Service.
The data you find in the corresponding characteristics needs to be interpreted as described in Personal Health Devices Transcoding
Edit:
You can find more information on the data structure here:
GATT Specification Supplement 5
example:
Feature([33,0,0,0]) => 0x00000011 => ...00 0010 0001 =>
value
description
1
Time Stamp Supported: True
0
Multiple Users Supported: False
0
BMI Supported: False
0100
Weight Measurement Resolution: Resolution of 0.05 kg or 0.1 lb
000
Height Measurement Resolution: Not specified
Weight = [34, 156, 74, 178, 7, 1, 7, 22, 33, 2]
=> 0x22 0x9c 0x4a 0xb2 0x07 0x01 0x07 0x16 0x21 0x02
First byte is a flags field => 0x22 => 0010 0010
value
description
0
Measurement Units: SI
1
Time Stamp present: True
0
User ID present: False
0
BMI and Height present: False
0010
Reserved for Future Use
Weight in kilograms with resolution 0.005 (uint16) => 0x4a9c => 95,5 kg
Time Stamp 0xb2 0x07 0x01 0x07 0x16 0x21 0x02
year(uint16) => 0x07b2 => 1970
month(uint8) => 0x01 => 1
day(uint8) => 0x07 => 7
hours(uint8) => 0x16 => 22
minutes(uint8) => 0x21 => 33
seconds(uint8) => 0x02 => 2
date 1970-01-07T22:33:02
I want to fetch the data from data_format_value. it return last value only. i don't know where is the error occur. i want fetch all the data_format_value.
{
"org_id": 1
"test_instance_id": 237,
"section_attributes": [
{
"section_id": 1,
"section_name": "Section-A",
"section_status": "Started",
"item_count": 5
}
],
"itemset_sections": [
{
"section_id": 1,
"section_name": "Section-A",
"timer": 30,
"section_items": [
{
"item_id": 190,
"item_type": 1,
"is_directive": 0,
"directive_content": {},
"hints": "scientists",
"item": [
{
"data_id": 877,
"data_format_id": 1,
"data_format_value": "Why haven't Indian scientists made such headway in any field after independence ?",
"item_df_sequence": 1,
"data_identifier": null
},
{
"data_id": 878,
"data_format_id": 1,
"data_format_value": "Indian scientists are not provided with up to date laboratory facilities.",
"item_df_sequence": 2,
"data_identifier": null
},
{
"data_id": 879,
"data_format_id": 1,
"data_format_value": "Indian scientists regard that knowledge of western science advances is enough for a nation to advance.",
"item_df_sequence": 3,
"data_identifier": null
}
],
"answer_choices": [
{
"correct_answer": false,
"answer_choice_id": 4,
"choice_elements": [
{
"data_id": 883,
"data_format_id": 1,
"data_format_value": "data given in both statements I and II together are not sufficient to answer the question. ",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 1
},
{
"correct_answer": false,
"answer_choice_id": 2,
"choice_elements": [
{
"data_id": 881,
"data_format_id": 1,
"data_format_value": "data in statement II alone are sufficient to answer the question.",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 2
},
{
"correct_answer": true,
"answer_choice_id": 1,
"choice_elements": [
{
"data_id": 880,
"data_format_id": 1,
"data_format_value": "data in statement I alone are sufficient to answer the question.",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 3
},
{
"correct_answer": false,
"answer_choice_id": 3,
"choice_elements": [
{
"data_id": 882,
"data_format_id": 1,
"data_format_value": "data either in statement I alone or in statement II alone are sufficient to answer the question.",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 4
}
],
"Answer_Choice_Type": "Single Answer",
"score_type": "Item Lvl Score",
"ItemSet_Item_Key": 273,
"yet_to_visit": 0,
"filterCategory": "red",
"mark_for_review": 0,
"not_answered": 1,
"answered": 0,
"answered_marked_for_review": 0,
"seq_no": 1,
"hints_shown": "n",
"user_selected_option": []
},
{
"item_id": 193,
"item_type": 1,
"is_directive": 0,
"directive_content": {},
"hints": "synthesised",
"item": [
{
"data_id": 897,
"data_format_id": 1,
"data_format_value": "Which of the following is the newest element to be discovered and synthesised?",
"item_df_sequence": 1,
"data_identifier": null
},
{
"data_id": 4,
"data_format_id": 11,
"data_format_value": "https://awspikaresources.s3.ap-south-1.amazonaws.com/TenantsDetails/Tech4india2018-06-16/TenantFilesContent/Videos/61e0158cde97a6f2e3a9f3a7c5d81ccf1530684346.mp4",
"item_df_sequence": 2,
"data_identifier": null
}
],
"answer_choices": [
{
"correct_answer": false,
"answer_choice_id": 1,
"choice_elements": [
{
"data_id": 898,
"data_format_id": 1,
"data_format_value": "Flerovium (114)",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 1
},
{
"correct_answer": true,
"answer_choice_id": 4,
"choice_elements": [
{
"data_id": 901,
"data_format_id": 1,
"data_format_value": "Ununseptium (117)",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 2
},
{
"correct_answer": false,
"answer_choice_id": 2,
"choice_elements": [
{
"data_id": 899,
"data_format_id": 1,
"data_format_value": "Ununpentium (115)",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 3
},
{
"correct_answer": false,
"answer_choice_id": 3,
"choice_elements": [
{
"data_id": 900,
"data_format_id": 1,
"data_format_value": "Livermorium (116)",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 4
}
],
"Answer_Choice_Type": "Single Answer",
"score_type": "Item Lvl Score",
"ItemSet_Item_Key": 275,
"yet_to_visit": 1,
"filterCategory": "gray",
"mark_for_review": 0,
"not_answered": 0,
"answered": 0,
"answered_marked_for_review": 0,
"seq_no": 3,
"hints_shown": "n",
"user_selected_option": []
},
{
"item_id": 195,
"item_type": 2,
"is_directive": 0,
"directive_content": {},
"hints": "anti-tetanus ",
"item": [
{
"data_id": 904,
"data_format_id": 1,
"data_format_value": "Blueberries cost more than strawberries",
"item_df_sequence": 1,
"data_identifier": null
},
{
"data_id": 905,
"data_format_id": 1,
"data_format_value": "Blueberries cost less than raspberries.",
"item_df_sequence": 2,
"data_identifier": null
},
{
"data_id": 906,
"data_format_id": 1,
"data_format_value": "Raspberries cost more than strawberries and blueberries",
"item_df_sequence": 3,
"data_identifier": null
},
{
"data_id": 907,
"data_format_id": 1,
"data_format_value": "If the first two statements are true, the third statement is",
"item_df_sequence": 4,
"data_identifier": null
}
],
"answer_choices": [
{
"data_id": 8,
"data_format_id": 1,
"data_format_value": "True",
"answer_choice_id": 1,
"item_df_sequence": 1,
"data_identifier": null,
"correct_answer": true,
"choosed_answer": false,
"seq_id": 1
},
{
"data_id": 9,
"data_format_id": 1,
"data_format_value": "False",
"answer_choice_id": 2,
"item_df_sequence": 2,
"data_identifier": null,
"correct_answer": false,
"choosed_answer": false,
"seq_id": 2
}
],
"Answer_Choice_Type": "Single Answer",
"score_type": "Item Lvl Score",
"ItemSet_Item_Key": 277,
"yet_to_visit": 1,
"filterCategory": "gray",
"mark_for_review": 0,
"not_answered": 0,
"answered": 0,
"answered_marked_for_review": 0,
"seq_no": 4,
"hints_shown": "n",
"user_selected_option": []
},
{
"item_id": 191,
"item_type": 1,
"is_directive": 0,
"directive_content": {},
"hints": "segment",
"item": [
{
"data_id": 884,
"data_format_id": 1,
"data_format_value": "Suppose we have an image given below",
"item_df_sequence": 1,
"data_identifier": null
},
{
"data_id": 7,
"data_format_id": 6,
"data_format_value": "https://awspikaresources.s3.ap-south-1.amazonaws.com/TenantsDetails/Tech4india2018-06-16/TenantFilesContent/Images/87a95c70ae73d23f351b50cddcf459641530684578.jpeg",
"item_df_sequence": 2,
"data_identifier": null
},
{
"data_id": 885,
"data_format_id": 1,
"data_format_value": "Our task is to segment the objects in the image. A simple way to do this is to represent the image in terms of the intensity of pixels and the cluster them according to the values. On doing this, we got this type of structure",
"item_df_sequence": 3,
"data_identifier": null
},
{
"data_id": 8,
"data_format_id": 6,
"data_format_value": "https://awspikaresources.s3.ap-south-1.amazonaws.com/TenantsDetails/Tech4india2018-06-16/TenantFilesContent/Images/04c5c1be6bbfd4f44773e4c68b84c05d1530684594.jpeg",
"item_df_sequence": 4,
"data_identifier": null
},
{
"data_id": 886,
"data_format_id": 1,
"data_format_value": "Suppose we choose k-means clustering to solve the problem, what would be the appropriate value of k from just a visual inspection of the intensity graph?",
"item_df_sequence": 5,
"data_identifier": null
}
],
"answer_choices": [
{
"correct_answer": true,
"answer_choice_id": 3,
"choice_elements": [
{
"data_id": 889,
"data_format_id": 1,
"data_format_value": "3",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 1
},
{
"correct_answer": false,
"answer_choice_id": 1,
"choice_elements": [
{
"data_id": 887,
"data_format_id": 1,
"data_format_value": "1",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 2
},
{
"correct_answer": false,
"answer_choice_id": 2,
"choice_elements": [
{
"data_id": 888,
"data_format_id": 1,
"data_format_value": "2",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 3
},
{
"correct_answer": false,
"answer_choice_id": 4,
"choice_elements": [
{
"data_id": 890,
"data_format_id": 1,
"data_format_value": "4",
"item_df_sequence": 1,
"data_identifier": null
}
],
"choosed_answer": false,
"seq_id": 4
}
],
"Answer_Choice_Type": "Single Answer",
"score_type": "Item Lvl Score",
"ItemSet_Item_Key": 274,
"yet_to_visit": 1,
"filterCategory": "gray",
"mark_for_review": 0,
"not_answered": 0,
"answered": 0,
"answered_marked_for_review": 0,
"seq_no": 5,
"hints_shown": "n",
"user_selected_option": []
}
]
}
]
}
i created pojo also.
my android code given blow. Here i attached my android functions with out pojo. the data print in logcat it not show in the textview
private void fetchTestData() {
JsonObject gsonObject = new JsonObject();
JsonObject paramObject = new JsonObject();
JsonObject current_section = new JsonObject();
paramObject.addProperty("test_id", 30);
paramObject.addProperty("user_id", 23);
paramObject.addProperty("org_id", 1);
paramObject.addProperty("schedule_id", 80);
paramObject.addProperty("next_section_id","");
paramObject.addProperty("group_id", "null");
paramObject.addProperty("current_section", String.valueOf(current_section));
JsonParser jsonParser = new JsonParser();
gsonObject = (JsonObject) jsonParser.parse(paramObject.toString());
retrofit2.Call<Test_Responce> userCall = api_interface.exampleresponce(gsonObject);
userCall.enqueue(new Callback<Test_Responce>() {
#Override
public void onResponse(retrofit2.Call<Test_Responce> call, Response<Test_Responce> response) {
if (response.isSuccessful()){
qnoPalette.clear();
countTimer = response.body().getTimer();
List<ItemsetSection> getItemsetSection = response.body().getItemsetSections();
getSectionAttribute = response.body().getSectionAttributes();
//get Itemset Section
for (int i = 0;i<getItemsetSection.size();i++){
List<SectionItem> getSection = getItemsetSection.get(i).getSectionItems();
for (int j = 0;j<getSection.size();j++){
getItem = getSection.get(j).getItem();
for (int k=0;k<getItem.size();k++){
Const.QuestionSize = getItem.size();
strQuestion.add(getItem.get(k).getDataFormatValue());
}
}
}
for (int i =0; i<getSectionAttribute.size();i++){
txtQuestionPage.setText(Const.currentpage+"/"+getSectionAttribute.get(i).getItemCount());
sectionItem.add( getSectionAttribute.get(i).getSectionName());
Valuesfromserver();
}
Toast.makeText(getApplicationContext(),"success",Toast.LENGTH_SHORT).show();
startCountDownTimer();
}else {
Toast.makeText(getApplicationContext(),"else",Toast.LENGTH_SHORT).show();
}
}
#Override
public void onFailure(retrofit2.Call<Test_Responce> call, Throwable t) {
Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
Log.e("error:",t.getMessage())
; }
});
}
btnQuestion.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
paletteLayout.setVisibility(View.GONE);
txtInst.setVisibility(View.GONE);
for(int i =0;i<strQuestion.size();i++{
textView.setText(strQuestion.get(i);
}
Log.e("questions", String.valueOf(strQuestion));
}
});
it return last question only
Thanks
problem raised in for loop.
i hope this code is useful to you.
for (int i = 0; i <getSection.size();i++){
getItem = getSection.get(i).getItem();
for (int j = 0; j<getItem.size();j++){
Const.QuestionSize = getItem.size();
palette_model = new Palette_Model(getItem.get(j).getDataFormatValue(),
getItem.get(j).getDataFormatId());
strQuestion.add(palette_model);
}
Log.e("val", String.valueOf(strQuestion));
qa.add(String.valueOf(strQuestion));
strQuestion.clear();
}
I have got a following json,
[
"GetStatutoryMappingsSuccess",
{
"statutory_mappings": {
"5": {
"geography_ids": [
2,
1
],
"approval_status": 0,
"approval_status_text": "Pending",
"compliance_names": [
{
"url": null,
"compliance_name": "Every Month Task"
}
],
"statutory_nature_name": "Central",
"country_id": 1,
"domain_name": "Labour Law",
"industry_names": "Factory, Office",
"is_active": true,
"statutory_nature_id": 2,
"statutory_ids": [
2
],
"country_name": "iNDIA",
"industry_ids": [
1,
2
],
"geography_mappings": [
"iNDIA >> North Region",
"iNDIA >> South Region"
],
"compliances": [
{
"description": "sDSFDSf",
"is_active": true,
"repeats_type_id": 2,
"statutory_provision": "Provision",
"compliance_task": "Every Month Task",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 2,
"repeats_every": 1,
"statutory_dates": [
{
"statutory_month": 1,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 2,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 3,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 4,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 5,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 6,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 7,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 8,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 9,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 10,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 11,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
},
{
"statutory_month": 12,
"statutory_date": 10,
"trigger_before_days": 10,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 12
}
],
"statutory_mappings": [
"POG Act>>State Rule All"
],
"domain_id": 2
},
"6": {
"geography_ids": [
17,
16
],
"approval_status": 0,
"approval_status_text": "Pending",
"compliance_names": [
{
"url": null,
"compliance_name": "One Time Task"
},
{
"url": null,
"compliance_name": "Daily Task"
},
{
"url": null,
"compliance_name": "Monthly Task"
}
],
"statutory_nature_name": "Central",
"country_id": 3,
"domain_name": "Labour Law",
"industry_names": "Factory, Office",
"is_active": true,
"statutory_nature_id": 2,
"statutory_ids": [
3
],
"country_name": "Singapore",
"industry_ids": [
1,
2
],
"geography_mappings": [
"Singapore >> North Region",
"Singapore >> South Region"
],
"compliances": [
{
"description": "FDSFDS",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "Central Rule",
"compliance_task": "One Time Task",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 1,
"repeats_every": null,
"statutory_dates": [
{
"statutory_month": 1,
"statutory_date": 10,
"trigger_before_days": 25,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 13
},
{
"description": "SDFDSF",
"is_active": true,
"repeats_type_id": 1,
"statutory_provision": "Central Rule",
"compliance_task": "Daily Task",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 2,
"repeats_every": 2,
"statutory_dates": [
{
"statutory_month": null,
"statutory_date": null,
"trigger_before_days": 25,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 14
},
{
"description": "DSDSD",
"is_active": true,
"repeats_type_id": 2,
"statutory_provision": "Central Rule",
"compliance_task": "Monthly Task",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 2,
"repeats_every": 1,
"statutory_dates": [
{
"statutory_month": null,
"statutory_date": 3,
"trigger_before_days": 30,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 15
}
],
"statutory_mappings": [
"SOG Act"
],
"domain_id": 2
},
"7": {
"geography_ids": [
2
],
"approval_status": 0,
"approval_status_text": "Pending",
"compliance_names": [
{
"url": null,
"compliance_name": "… … … ……… …dfg dfg ⁜ ⁜ ⁜ sdfsdsf sf sdfsd sdf sff⁙ ⁙ ⁙ ⁙ ⁙"
},
{
"url": null,
"compliance_name": "⁕⁖ ⁗⁘ ⁙⁚ ⁛ ⁜gdfg ⁝ ⁞ ⁰⁵ ⁿ ⁑ ⁒ ⁓ ⁋ df sdf sdfdgf dfg dg"
},
{
"url": null,
"compliance_name": "```````````````"
}
],
"statutory_nature_name": "Central",
"country_id": 1,
"domain_name": "Labour Law",
"industry_names": "Factory",
"is_active": true,
"statutory_nature_id": 2,
"statutory_ids": [
2
],
"country_name": "iNDIA",
"industry_ids": [
1
],
"geography_mappings": [
"iNDIA >> North Region"
],
"compliances": [
{
"description": "Application for registration and grant of renewal of licen dfgce for the year … …… …… ⁜ ⁜",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "sadsad",
"compliance_task": "… … … ……… …dfg dfg ⁜ ⁜ ⁜ sdfsdsf sf sdfsd sdf sff⁙ ⁙ ⁙ ⁙ ⁙",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 1,
"repeats_every": null,
"statutory_dates": [
{
"statutory_month": 1,
"statutory_date": 4,
"trigger_before_days": null,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 16
},
{
"description": "sdfsdfdsf",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "dssfdsf",
"compliance_task": "⁕⁖ ⁗⁘ ⁙⁚ ⁛ ⁜gdfg ⁝ ⁞ ⁰⁵ ⁿ ⁑ ⁒ ⁓ ⁋ df sdf sdfdgf dfg dg",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 1,
"repeats_every": null,
"statutory_dates": [
{
"statutory_month": null,
"statutory_date": null,
"trigger_before_days": null,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 17
},
{
"description": "fghfg",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "gfghfg",
"compliance_task": "```````````````",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 1,
"repeats_every": null,
"statutory_dates": [
{
"statutory_month": null,
"statutory_date": null,
"trigger_before_days": null,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 18
}
],
"statutory_mappings": [
"POG Act>>State Rule All"
],
"domain_id": 2
},
"10": {
"geography_ids": [
1
],
"approval_status": 0,
"approval_status_text": "Pending",
"compliance_names": [
{
"url": null,
"compliance_name": "One Time Task"
},
{
"url": null,
"compliance_name": "One Time Tasss replicate"
}
],
"statutory_nature_name": "Central",
"country_id": 1,
"domain_name": "Labour Law",
"industry_names": "Factory",
"is_active": true,
"statutory_nature_id": 2,
"statutory_ids": [
7
],
"country_name": "iNDIA",
"industry_ids": [
1
],
"geography_mappings": [
"iNDIA >> South Region"
],
"compliances": [
{
"description": "DSFSDFDS",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "Central Rule",
"compliance_task": "One Time Task",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 1,
"repeats_every": null,
"statutory_dates": [
{
"statutory_month": 4,
"statutory_date": 12,
"trigger_before_days": 25,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 21
},
{
"description": "sdfds",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "Central Rule",
"compliance_task": "One Time Tasss replicate",
"format_file_list": null,
"duration": null,
"document_name": null,
"penal_consequences": "",
"duration_type_id": null,
"frequency_id": 1,
"repeats_every": null,
"statutory_dates": [
{
"statutory_month": 5,
"statutory_date": 4,
"trigger_before_days": 30,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 22
}
],
"statutory_mappings": [
"ESI Act>>Rule 1A"
],
"domain_id": 2
},
"11": {
"geography_ids": [
1
],
"approval_status": 0,
"approval_status_text": "Pending",
"compliance_names": [
{
"url": "compliance_format/statutory-mapping-table-reference-c4f43cb06e24410fbed1f4d96a3afff8.xls",
"compliance_name": "Docu - One Time Task"
},
{
"url": "compliance_format/md5-decrypt-508ffc6b93de45828b38abc9ce21ee18.py",
"compliance_name": "DOC - On Occurance Task"
}
],
"statutory_nature_name": "Central",
"country_id": 1,
"domain_name": "Labour Law",
"industry_names": "Factory",
"is_active": true,
"statutory_nature_id": 2,
"statutory_ids": [
7
],
"country_name": "iNDIA",
"industry_ids": [
1
],
"geography_mappings": [
"iNDIA >> South Region"
],
"compliances": [
{
"description": "DSDSF",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "Doc",
"compliance_task": "One Time Task",
"format_file_list": [
{
"file_content": "compliance_format/statutory-mapping-table-reference-c4f43cb06e24410fbed1f4d96a3afff8.xls",
"file_name": "statutory-mapping-table-reference-c4f43cb06e24410fbed1f4d96a3afff8.xls",
"file_size": 11264
}
],
"duration": null,
"document_name": "Docu",
"penal_consequences": "sdfdsf",
"duration_type_id": null,
"frequency_id": 1,
"repeats_every": null,
"statutory_dates": [
{
"statutory_month": null,
"statutory_date": null,
"trigger_before_days": null,
"repeat_by": "dayofmonth"
}
],
"compliance_id": 25
},
{
"description": "sddsfdsf",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "Doc",
"compliance_task": "On Occurance Task",
"format_file_list": [
{
"file_content": "compliance_format/md5-decrypt-508ffc6b93de45828b38abc9ce21ee18.py",
"file_name": "md5-decrypt-508ffc6b93de45828b38abc9ce21ee18.py",
"file_size": 739
}
],
"duration": 7,
"document_name": "DOC",
"penal_consequences": "",
"duration_type_id": 2,
"frequency_id": 4,
"repeats_every": null,
"statutory_dates": [],
"compliance_id": 23
}
],
"statutory_mappings": [
"ESI Act>>Rule 1A"
],
"domain_id": 2
},
"12": {
"geography_ids": [
1
],
"approval_status": 0,
"approval_status_text": "Pending",
"compliance_names": [
{
"url": "compliance_format/mobile-api-50d3dfd554664da1bc65935202bf63b6.txt",
"compliance_name": "Doc - Doc"
}
],
"statutory_nature_name": "Central",
"country_id": 1,
"domain_name": "Labour Law",
"industry_names": "Factory",
"is_active": true,
"statutory_nature_id": 2,
"statutory_ids": [
7
],
"country_name": "iNDIA",
"industry_ids": [
1
],
"geography_mappings": [
"iNDIA >> South Region"
],
"compliances": [
{
"description": "Doc",
"is_active": true,
"repeats_type_id": null,
"statutory_provision": "Rule IA",
"compliance_task": "Doc",
"format_file_list": [
{
"file_content": "compliance_format/mobile-api-50d3dfd554664da1bc65935202bf63b6.txt",
"file_name": "mobile-api-50d3dfd554664da1bc65935202bf63b6.txt",
"file_size": 6733
}
],
"duration": 1,
"document_name": "Doc",
"penal_consequences": "sdfd",
"duration_type_id": 1,
"frequency_id": 4,
"repeats_every": null,
"statutory_dates": [],
"compliance_id": 24
}
],
"statutory_mappings": [
"ESI Act>>Rule 1A"
],
"domain_id": 2
}
}
}
]
Im trying to parse it as follows,
for (int i = 0; i < response.length(); i++) {
try {
// Toast.makeText(getActivity(), response.toString(), Toast.LENGTH_SHORT).show();
JSONObject value = response.getJSONObject(i);
JSONObject statutory_mappings = value.getJSONObject("statutory_mappings");
Iterator<String> keys = statutory_mappings.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
JSONObject statMap = statutory_mappings.getJSONObject(key);
//iterate geography id's in case if there comes any necessity
JSONArray geography_ids = statMap.getJSONArray("geography_ids");
JSONObject approval_status = statMap.getJSONObject("approval_status");
String approval_status_text = statMap.getString("approval_status_text");
JSONArray compliance_names = statMap.getJSONArray("compliance_names");
String statutory_nature_name = statMap.getString("statutory_nature_name");
String country_id = statMap.getString("country_id");
String domain_name = statMap.getString("domain_name");
String industry_names = statMap.getString("industry_names");
String is_active = statMap.getString("is_active");
String statutory_nature_id = statMap.getString("statutory_nature_id");
JSONArray statutory_ids = statMap.getJSONArray("statutory_ids");
String country_name = statMap.getString("country_name");
JSONArray industry_ids = statMap.getJSONArray("industry_ids");
JSONArray geography_mappings = statMap.getJSONArray("geography_mappings");
JSONArray compliances = statMap.getJSONArray("compliances");
String compliance_id = statMap.getString("compliance_id");
JSONArray inner_statutory_mappings = statMap.getJSONArray("statutory_mappings");
String domain_id = statMap.getString("domain_id");
String logs = geography_ids + ""+ approval_status + " "+approval_status_text + " "+ compliance_names + " "+ statutory_nature_name + " "+country_id + " "+domain_name + " "+ industry_names + " "+is_active + " "+statutory_ids + " "+statutory_nature_id + " "+ country_name + " "+industry_ids + " "+ geography_mappings + " "+compliances + " "+compliance_id + " "+inner_statutory_mappings + " "+domain_id;
Toast.makeText(getActivity(),geography_ids.toString(),Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
The problem is that Im not be able to parse it. It prints geography_ids but not approval status and other values. Why is that so? Am I missing any logic?
Problem 1
Your json has this format:
[
"GetStatutoryMappingsSuccess",
{...}
]
So when you try to itterate over this array you will get 1 Exeption:
org.json.JSONException: JSONArray[0] is not a JSONObject. because 1-st element is not a JsonObject but a String. That is why you'd better just use JSONObject value = new JSONArray(json).getJSONObject(1); instead of for loop
Problem 2
Inside 2-nd object you have
{
"statutory_mappings": {
"5": {
"approval_status": 0,
...
}
}
}
And your parsing code should work, but "approval_status" is integer , so instead of
JSONObject approval_status = statMap.getJSONObject("approval_status");
should be:
int approval_status = statMap.getInt("approval_status");
// Same problem for:
int country_id = statMap.getInt("country_id");
boolean is_active = statMap.getBoolean("is_active");
int statutory_nature_id = statMap.getInt("statutory_nature_id");
int domain_id = statMap.getInt("domain_id");
Problem 3
There is also problem with compliance_id and json looks like this
"compliances": [
{
// ... some fields here
"compliance_id": 13
},
{
// ... some fields here
"compliance_id": 14
},
...
]
So there is no point to print compliances in your log string and if you really want to get compliance_id of aach element in array you have to itterate over them like this
JSONArray compliancesArr = statMap.getJSONArray("compliances");
for(int i = 0; i < compliancesArr.length();i++){
JSONObject compliancesObj = compliancesArr.getJSONObject(i);
int compliance_id = compliancesObj.getInt("compliance_id");
}
PS. Gson or Jackson will make your parsing code much easier.
I have a jquery flot with filtering buttons below the graphic , which enable user to show the values on a weekly manner, or daily manner and so on.
The problem happens when the user clicks a filtering button, suddenly another flot chart above the first chart is created and it stays there till I leave the page and come back to the page.
I have the following code to show a graph as soon as user gets to the page ;
And the filtering button calls a function that has the same piece of code but with a different tick size (with week for example).
PS: I'm using Phonegap that prepares the app for the normal Android webview. The engine used depends on the Android version.
WebKit versions; Ref
Android 4.2.2 534.30 ( Another flot chart is created)
Android 4.4.x 537.36 ( Works as expected )
Code:
var plot = $.plot("#placeholder", [{
data: dAlle
}], {
series: {
lines: {
show: true
},
points: {
show: true
}
},
grid: {
hoverable: true,
clickable: true,
markings: [{
yaxis: {
from: 0,
to: 12
},
color: "#F2CDEA"
}, {
yaxis: {
from: rangeMin,
to: rangeMax
},
color: "#D7EEE1"
}]
},
xaxis: {
mode: "time",
minTickSize: [1, "month"],
/*min: theVeryFirstPoint,
max: theVeryLastPoint*/
},
yaxis: {
min: 0,
max: 12
}
});
The weird thing is that same logic works for Android with LG G2 API level 19 (4.4.2), but when I install the app into Samsung S2 with API Level 16 (4.2.2) , this problem occurs. Is there any way of preventing it from occuring?
CSS + JS imports are as follows ;
<link rel="stylesheet" href="css/jquery.mobile-1.4.2.min.css">
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" href="css/jqm-icon-pack-fa.css" />
<script type="text/javascript" src="cordova.js"></script>
<script src="js/jquery-1.11.2.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<link href="css/examples.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript" src="js/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="js/flot/jquery.flot.threshold.js"></script>
<script language="javascript" type="text/javascript" src="js/flot/jquery.flot.time.js"></script>
<script language="javascript" type="text/javascript" src="js/flot/jquery.flot.areamarkings.js"></script>
Filter function that is called ;
$("#a-uke").click(function() {
console.log("a dag filtering will be applied...");
var newDataSer = window.localStorage.getItem("storedData");
if (newDataSer != null) {
newDataSer = JSON.parse(newDataSer);
// Just convert into a new array object for the FIRST time
//if (dagButtonClicked == false) {
$.each(newDataSer, function(index, datapoint) {
datapoint[2] = datapoint[0];
datapoint[0] = (new Date(datapoint[0])).getHours();
console.log("hours created : " + datapoint[0]);
dagButtonClicked = true;
});
//}
if (newDataSer != null && newDataSer.length > 0) {
newDataSer.sort(function(x, y) {
console.log("sorting..");
return x[0] - y[0];
})
}
} else
newDataSer = [];
$.plot("#placeholder", [newDataSer], {
series: {
lines: {
show: true
},
points: {
show: true
}
},
grid: {
hoverable: true,
clickable: true,
areaMarkings: [{
points: [
[7, 12],
[24, 12],
[24, 0],
[7, 0]
],
lineWidth: 0,
fillColor: "#F2CDEA"
}, {
points: [
[7, rangeBr1],
[7, rangeBr2],
[10, rangeBr2],
[10, rangeBr1]
], // Green for breakfast
lineWidth: 0,
fillColor: "#D7EEE1"
}, {
points: [
[7, rangeBr2],
[7, rangeBr3],
[10, rangeBr3],
[10, rangeBr2]
], // Gradient1 Top for breakfast
lineWidth: 0,
fillColor: "#DFE4E3"
}, {
points: [
[7, rangeBr3],
[7, rangeBr4],
[10, rangeBr4],
[10, rangeBr3]
], // Gradient2 Top for breakfast
lineWidth: 0,
fillColor: "#E7DAE6"
}, {
points: [
[7, rangeBrBot2],
[7, rangeBrBot3],
[10, rangeBrBot3],
[10, rangeBrBot2]
], // Gradient1 Bottom for breakfast
lineWidth: 0,
fillColor: "#DFE4E3"
}, {
points: [
[7, rangeBrBot1],
[7, rangeBrBot2],
[10, rangeBrBot2],
[10, rangeBrBot1]
], // Gradient2 Bottom for breakfast
lineWidth: 0,
fillColor: "#E7DAE6"
}, {
points: [
[10, rangeMin],
[10, rangeMaxGrad],
[24, rangeMaxGrad],
[24, rangeMin]
], // Green for the rest
lineWidth: 0,
fillColor: "#D7EEE1"
}, {
points: [
[10, rangeMaxGrad],
[10, rangeMaxGrad2],
[24, rangeMaxGrad2],
[24, rangeMaxGrad]
], // Gradient1 top for the rest
lineWidth: 0,
fillColor: "#DFE4E3"
}, {
points: [
[10, rangeMaxGrad2],
[10, rangeMaxGrad3],
[24, rangeMaxGrad3],
[24, rangeMaxGrad2]
], // Gradient2 top for the rest
lineWidth: 0,
fillColor: "#E7DAE6"
}, {
points: [
[10, rangeMinGrad2],
[10, rangeMin],
[24, rangeMin],
[24, rangeMinGrad2]
], // Gradient1 bottom for the rest
lineWidth: 0,
fillColor: "#DFE4E3"
}, {
points: [
[10, rangeMinGrad3],
[10, rangeMinGrad2],
[24, rangeMinGrad2],
[24, rangeMinGrad3]
], // Gradient2 bottom for the rest
lineWidth: 0,
fillColor: "#E7DAE6"
}]
},
xaxis: {
tickFormatter: getAmPmHour,
min: 7,
max: 24
},
yaxis: {
min: 0,
max: 12
}
});
});
Not sure what is causing that bug, but there are two possible solutions you can try:
1) You can clear the old plot before creating the new one:
$('#placeholder').empty();
$.plot("#placeholder", [newDataSer], { /* your new options */ });
2) You can use the existing plot instead of creating a new one (which is the recommended way):
plot.setData([newDataSer]);
plot.getOptions().grid.areaMarkings = [ /* your new markings / options */ ];
plot.getOptions().xaxis = { /* your new options */ };
plot.setupGrid();
plot.draw();