setting the categories using ajax in highcharts - ajax

trying to create a chart heatmap using highcharts library, i am using blacklabel plugin to set multilevel categories for x and y axis.
here is the blacklabel demo link.
https://jsfiddle.net/BlackLabel/TFhd7/
if i hardcode the categories as per the demo, its working good, but i get the x axis categories, y axis categories and the data from the database. this is where i am facing issue.
my server side coding is c# with asp.net, and i am posting all ajax calls to request all the data.
can anyone help me with example how to set the multilevel categories dynamically with ajax call.

blacklabel demo link https://jsfiddle.net/BlackLabel/TFhd7/
at the above link, xaxis categories are hardcoded.
below is the snippet from the above link.
categories: [{
name: "Fruit",
categories: ["Apple", "Banana", "Orange"]
}, {
name: "Vegetable",
categories: ["Carrot", "Potato", "Tomato"]
}, {
name: "Fish",
categories: ["Cod", "Salmon", "Tuna"]
}]
now i am trying to generate similar kind of json format by connecting to the DB and sending to the Javascript thru c#.
as i said in my first post that i am facing issues in setting the categories when i get it from the DB, if i hardcode as per the example it works good.
so the solution i found is...
1) return data into json from c# .
jsonconvert.serializeobject(data)
2) parse the data into json format at the success function of ajax call.
JSON.parse(response)

Related

Using a filter on a dimension/metric in Google Analytics embedded api code

var dataChart = new gapi.analytics.googleCharts.DataChart({
query: {
metrics: 'ga:pageviews',
dimensions: 'ga:pageTitle',
filters: 'ga:pageTitle =~ %5ELecture\s.*',
'start-date': '30daysAgo',
'end-date': 'yesterday'
},
chart: {
container: 'chart-container',
type: 'COLUMN',
options: {
width: '100%'
}
}
});
Above is the code that google embed api gave me for a quick dashboard as shown in the "embed code api tutorial" on google's analytics website. This simple dashboard is enough for what I desire to be shown on my website, however, after fetching the data I have to filter some of it... Specifically, the "dimension". According to the following link, https://developers.google.com/analytics/devguides/reporting/core/v2/gdataReferenceDataFeed,
the syntax for filtering a metric or dimension is shown. However, this isn't not returning any chart onto my website, and so I believe the syntax to be wrong. When I remove the line of code beginning with "filters:", a chart is displayed according to the prescribed metrics and dimensions simply without any filter...
Where am I going wrong with the syntax for the filter?
I have tried many different possibilities, including URL encoded characters as opposed to ga's syntax... Any help is appreciated, thank you!

Angulajs dynamic form data with dynamic layout

I have a form which is built as a directive. I am providing the data for layout in my controller.
MyController.js
[{
"type":"selectbox",
"name":"name_one",
"label":"Name One"
}]
This data is then passed to my form_directive which then loads the template.
Then I am getting the actual data to be populated from an ajax call, inside MyController.js
eg:
$http.get('url/location').success(function(data) {
}).error(function(data) {
});
The data that is coming from the ajax will be like this:
[{
"id":"090986735",
"name":"option_1"
},{
"id":"78645679",
"name":"option_2"
}]
Now my question is how to bind this data to the selectbox?
Please note that there will be many such controls. But I have shown only one select box
Try to change the model of select.
https://docs.angularjs.org/api/ng/directive/select - the example with colors should be useful for you.

Update Google Charts Dashboard cell with HTML value

I have a Google Charts Dashboard instance bound to a ChartWrapper instance that has allowHtml: true, and a DataTable instance that we get from a query response:
...
data = response.getDataTable();
data.setTableProperty("allowHtml", true);
...
dashboard = new google.visualization.Dashboard(document.getElementById('dashboard'));
table = new google.visualization.ChartWrapper({
'chartType': 'Table',
'dataTable' : data,
'containerId': 'table',
'options' : {'allowHtml': true, 'showRowNumber': true} //,
});
...
dashboard.bind(filters, table);
dashboard.draw(data);
This enables the drawing of HTML fine. We return plenty of html via the response and it gets drawn to the DOM fine.
The problem comes in when we try to update a value in the chart via the DataTable object ("data" in the above code snippet). When we try to update the values of a cell using the DataTable.setCell() function call with an HTML string, the updated cell just shows the raw HTML and does not format the cell as HTML.
data.setCell(row_index, column_index, response.html);
dashboard.draw(data);
We've set both the ChartWrapper and DataTable options to allowHtml = true, and there doesn't seem to be a way to set the allowHtml property for the Dashboard.
Does anyone have any insight into this? Could it be something wrong with how the objects are bound to one another? According to Google Charts:
A ChartWrapper class is used to wrap your chart and handle all
loading, drawing, and Datasource querying for your chart.
Am I supposed to be using a different API for updating the value? I've tried setting column properties, setting table properties, etc to all be allowHtml = true but nothing I've tried has enabled me to update a table with HTML. It always shows the raw HTML string
Facepalm
Okay it turns out our serverside code at one point was encoding the HTML string via Django's render_to_string() function, so that things like "<" were being converted to <.
They showed up in the Google Charts as the right values, that is the < value rendered as "<" in the DOM. Once I took out the render_to_string call, everything worked fine.

How to make a column non-editable in Kendu UI Grid With Row template?

http://jsfiddle.net/valchev/s7ZCV/15/,
the above link is the simple example of Kendo grid with row template.All I wanted to do is make a specific column non-editable. the usual way is just define a model and further inside fields add editable False to the required field. i just wanted to know is there any other way to make a column editable as false because i dont want to add one more model in kendo as I am using models in entity level and Jay-data Level.
var dataSource = new kendo.data.DataSource({
data: records,
schema: {
model: {
id: "foo",
fields: {
foo: {type: "number"},
CostCategoryAbv: {type: "string",editable:false}, // i dont want this
VendorName: {type: "string"}
}
}
}
});
I've been doing a lot of work with the Kendo Grid using MVC. I've been getting around this by using a custom popup editor. The editor only allows the user to modify the fields that I want them to. Another way of getting around this is by changing the controller so that any user edit does not modify the field when the data source is updated. I know that the code provided is not using C# or MVC, but I hope this helps. I think you may be able to modify the save method so that it only saves select fields.

Issues with angular $watch and retrieving data from database

I'm a novice programming trying to put together a web application with Angular, node.js, and the graph database neo4j.
I would like to load content from my database dynamically based on the user selecting (or rejecting) terms (clicking buttons). Every time a button is clicked the relevant term is added to an array (either exclude or include). The idea is a new call to the database would be made each time a new term is selected.
I'm stuck right now on how to go about making calls to the database to retrieve the content. I'm trying to watch the arrays for changes using $watch. Something is going wrong and I'm having issues troubleshooting the problem.
Here is the controller code:
angular.module('myApp.controllers', []).
controller('content',function($scope,$http, queryTerms, $watch){
//watch arrays of terms for changes and fetch results based on what is selected
$watch(function() { return angular.toJson( [ queryTerms.includedTerms, queryTerms.excludedTerms ] ) },
function() {
$http({
method:'get',
url:'/query/getContent',
params: {includeTerms:queryTerms.includedTerms , excludeTerms:queryTerms.excludedTerms}
}).
success(function(data){
//feed content data to display for viewing
}).
error(function(data){
$scope.test = "Error :("
});
});
});
I'm getting the following error when I use $watch:
Error: Unknown provider: $watchProvider <- $watch
Is this a terrible stupid way to go about this in general? Any advice would be greatly appreciated- I'm learning as I'm going and so far the advice I've gotten on here has be amazing. Thanks!
Use $scope.$watch instead.
controller('content', function ($scope, $http, queryTerms) {
$scope.$watch(function () {
return angular.toJson([queryTerms.includedTerms, queryTerms.excludedTerms])
},...

Resources