RallyChart Pie - Is there a way to consolidate data labels? - highcharts

I'm wondering if there is a way to consolidate data labels into one. Here's a simple example for context: if I had a pie chart with labels "Apple", "Banana", "Grapefruit", "Broccoli", "Lettuce"-- is there a way for me to group the data associated with "Broccoli" and "Lettuce" into a "Vegetables" label? I don't really even need to reference "Broccoli" and "Lettuce" afterwards, I would just need the "Vegetables" label that aggregates them into one label.
Any and all help would be great.
Thanks!

Here is an example of how to combine defects into "Open" and "Closed" categories based on their State attribute that has four AllowedValues:
Ext.define("MyDefectCalculator", {
extend: "Rally.data.lookback.calculator.TimeSeriesCalculator",
getMetrics: function () {
var metrics = [
{
field: "State",
as: "Open",
display: "column",
f: "filteredCount",
filterField: "State",
filterValues: ["Submitted","Open"]
},
{
field: "State",
as: "Closed",
display: "column",
f: "filteredCount",
filterField: "State",
filterValues: ["Fixed","Closed"]
}
];
return metrics;
}

Related

Shield UI Grid Hyperlink on a Column Value

I am trying to use the values in a given column as a hyperlink using Shield UI's Grid. There doesn't appear to be anything on making a value within a column a hyperlink in the documentation.
Does anyone have an idea how to make a hyperlink within the grid?
example:
File_001 (href="\somefolder\File_001.pdf")
File_002 (href="\somefolder\File_002.pdf")
etc...etc...
You can use the column format option to add custom HTML markup in your cells like this:
columns: [
{ field: "id", width: "70px", title: "ID" },
{ field: "name", title: "Person Name" },
{ field: "company", title: "Company Name" },
{
field: "email", title: "Email Address", width: "270px",
format: function(val) { return '' + val + ''; }
}
]

Mixed Chart Types using Chartkick/Highcharts on Rails

I'm trying to create a mixed column/line chart using Highcharts.
I've been trying to use the library functionality to set one of my data series to be of type "line". I have tried a few different approaches, but I can't seem to figure out how to pass the type parameter of a given series using the Highcharts API.
<%= column_chart( ChartData.new(#forecast).revenue_and_net_income, library: {
title: {
text: "Revenue and Net Income"
},
series: [{
1 => {
type: "line"
}
}],
} ) %>
Where my data come from the following method:
def revenue_and_net_income
data = [
{
name: "Revenue",
data: revenue_by_year
},
{
name: "Net Income",
data: net_income_by_year,
}
]
end
Not sure what I'm doing wrong? I only seem to be able to access the Highcharts API methods listed under 'Chart', none of the series options etc. seem to work. Can anyone point me in the right direction for how to successfully get this to work?
you can try this way.
<%= line_chart [
{
name: "Amount", type: "column", data: #cause.donations.map {
|t| [t.user.name, t.amount]
}
},
{
name: "Test", type: "line", data: #cause.donations.map {
|t| [t.user.name, t.amount]
}
}
],
prefix: "$",
adapter: "highcharts"
%>
just don't care line_chart, column_chart or anythings... ONLY custom type in data. OK

Exporting CSV from ui-grid with cell display rather than the source value

I have a table done with ui-grid and this table has a column with cellFilter definition like this:
{ field: 'company', cellFilter: 'mapCompany:row.grid.appScope.companyCatalog' }
My gridMenu custom item is configured like this:
gridMenuCustomItems: [
{
title:'Custom Export',
action: function ($event) {
var exportData = uiGridExporterService.getData(this.grid, uiGridExporterConstants.ALL, uiGridExporterConstants.ALL, true);
var csvContent = uiGridExporterService.formatAsCsv([], exportData, this.grid.options.exporterCsvColumnSeparator);
uiGridExporterService.downloadFile (this.grid.options.exporterCsvFilename, csvContent, this.grid.options.exporterOlderExcelCompatibility);
},
order:0
}
]
The table is displayed correctly, but when I try to export to CSV, the Company column is exported with empty value. Here is my Plunkr.
Any suggestion will be appretiated
References
I did some research and according to ui-grid Issue #4948 it works good when the Company column is filled with an static catalog. Here is a Plunkr demostrating that.
As you mentioned, there is an export issue when the values in the column are not static, so I forked your plunker with a solution that creates the company mapping for each data object and adds it as a key-value once you get the company catalog back:
$http.get('https://api.github.com/users/hadley/orgs')
.success(function(data) {
$scope.companyCatalog = data;
angular.forEach($scope.gridOptions.data, function(item) {
var compMap = uiGridFactory.getMapCompany(item.company, $scope.companyCatalog);
item.mappedCo = compMap;
});
});
I've kept the original company column but made it invisible (rather than overwriting it), so it exports with the rest of the data in the csv. New column defs:
columnDefs: [
{ field: 'name' },
{ field: 'mappedCo', name: 'Company'},
{ field: 'company', visible: false }
]
Also, in the case that you were getting your data from a server, you would have to ensure that the data and the catalog returned before you run the mapping function. This solution may not work in your particular use case; I don't know.
I found a solution to the CSV export to be able to display the cell display value.
My mistake was using row.grid instead of this.grid at the mapCompany cell filter:
columnDefs: [
{ field: 'name' },
{ field: 'company', cellFilter: 'mapCompany:row.grid.appScope.companyCatalog' }
],
The right way to use it is using this:
columnDefs: [
{ field: 'name' },
{ field: 'company', cellFilter: 'mapCompany:this.grid.appScope.companyCatalog' }
],
Here is my Plunkr.

programatically set custom data to select2

How can I set custom data to a select2 v.4 per javascript? I understand that you can set the id and text value by inserting an option tag but that does not cover all the other data I want to have there in addition, e.g. [{"id":"17","text":"22.09.2015 15:45:05","branchList":["20","1","3","4","5"]}]
I use this code to set up the control, which works perfect:
$('#image_id').select2({
placeholder: "Search image ...",
minimumInputLength: 0,
allowClear: true,
dropdownAutoWidth: true,
theme: "bootstrap",
ajax: {
url: "ajax/select2_image_search.php",
delay: 250,
dataType: 'json',
data: function (params) {
return {
keywords: params.term
};
},
processResults: function (data, page) {
return {
results: data
};
}
},
});
when I then use this code, I can extract not only id and text but also custom data like branchList:
var bList = $('#image_id').select2("data")[0]["branchList"];
this works well too, but how can I set the additional info programatically per script with e.g. this data [{"id":"18","text":"23.09.2015 15:45:05","branchList":["22","5","7","32","1"]}] so that I can retrieve the additional info lateron per javascript?
Thanks a lot for your help :)
Simplest way is put your custom data to id with JSON.stringify(). Maybe it is not good way but it works for me.
So your code transforms to:
[ {
"id" : JSON.stringify({
"id" : "18",
"branchList" : [ "22", "5", "7", "32", "1" ]
}),
"text" : "23.09.2015 15:45:05"
} ]
And you can later extract your data back by JSON.parse(selector.selectedOptions[0].value).

KendoUI datasource: parseInt of filter value

I need to filter a Kendo datasource through the following filter item object:
filters: [
{
field: "FIELD",
operator: "lt",
value: "080"
}
]
That means, because of the way data are transmitted, I am trying to test a case like: "013" < "080".
But it does not work out of the box.
Is there a way to define a filter with something like a "parseInt" on the tested values?
Thank you!
Try defining FIELD as a number in model:
schema : {
model: {
fields: {
FIELD : { type: "number" }
}
}
},
If you do so, then FIELD is displayed as 13, 80,... If you want to display FIELD with leading 0, use the following in the column definition of the grid.
{ field: "FIELD", title: "Field", format: "{0:000}" }
Doing this FIELD is considered as a number even that it is displayed as 013, 080...
You should have something like:
var dataSource = new kendo.data.DataSource({
data : entries,
batch : true,
schema : {
model: {
fields: {
FIELD: { type: "number" }
}
}
}
});
var grid = $("#grid").kendoGrid({
dataSource: dataSource,
columns : [
{ field: "FIELD", title: "Field", format: "{0:000}" }
],
filterable: true
}).data("kendoGrid");
If you want to try it, see it in JSFiddle here
EDIT: Updated code for using format instead of template as Mateo Piazza suggested

Resources