anchorText not allowed in markerCluster - google-maps-api-3

So I'm using a custom icon for my clusters, and this causes the text to be off center. No problem, right? just use the anchorText? Well, there are problems.
let anchor: Array<number> = [9,3];
let styles = [{
url: "../../assets/img/mapIcons/clusterDot.svg",
width: 50,
height:50,
textSize:25,
textColor:"white",
anchorText: anchor,
}];
this.markerClusterer = new MarkerClusterer(this.map, this.markers, mcOptions);
So the problem is, if I use the new naming of 'AnchorText', I will get the following error (however, it will properly center my text)
Argument of type '{ maxZoom: number; styles: { url: string; width: number; height: number; textSize: number; textColor: string; anchorText: number[]; }[]; }' is not assignable to parameter of type 'MarkerClustererOptions'.
Types of property 'styles' are incompatible.
Type '{ url: string; width: number; height: number; textSize: number; textColor: string; anchorText: number[]; }[]' is not assignable to type
This error won't stop angular for displaying it properly (but I can't check in an error as it won't pass the build test)
Now, if I change it to 'anchor' (apparently the old name of the object) it will remove the error, but it won't actually center the text.
I'm using the latest version: "#googlemaps/markerclustererplus": "^1.0.3"
What is the proper way I should be doing this?
Thanks

So even though nobody shows using this in all the examples online, I did find this in the bitBucket. .WithDefaultStyles allows you to properly set the anchorText.
let styles = [
MarkerClusterer.withDefaultStyle({
url: "../../assets/img/mapIcons/clusterDot.svg",
width: 56,
height:56,
textSize:25,
textColor:"white",
anchorText: [-4, 0]
})]
let mcOptions = {
maxZoom:21,
styles:styles
};
this.markerClusterer = new MarkerClusterer(this.map, this.markers, mcOptions);

Related

ExtJS 7.x Modern Grid Selection Bug On Layout Animation

How to fix it? I found a bug on layout card animation using grid component;
What happens?
When you configure the layout for the "card" type and animation for "slide", "cover" etc... the line selection (record) stops working, when hovering over the record and clicking, the css of check gives bug.
When you change the layout to "card" simply, the grid selection works normally.
I'm using Windows 10, Edge browser;
See the bug on Sencha Fiddle
It is only the grid, dataview does not appear to have the same problem.
Not getting the error on firefox.
Also only with Material theme because it is related to Fashion. I could not figure out how to import Fashion in the sencha fiddle so I could not add to your fiddle.
I found that if you unchecked ANY color in chrome devtools the problem goes away for one animation. So i messed around with resetting the colors and that seems to work. You have to change a color wait 10 milliseconds and change it back. You can change ANY color. I am changing the hovered-background-color but it can be anyone of the predefined colors. I change it just one shade and it is only for 10 milliseconds. It will only work with colors in the format of #11111.
I have not figured out what is causing the problem but I have a huge hack of a work around. I am sure this can be improved... also did not test much at all. Feel free to post any improvements, or if you figure out the underlying problem.
items: [{
xtype: "grid",
ui: 'default',
listeners: {
show: function() {
let cssVariables = Fashion.css.getVariables();
let oldColor = cssVariables['hovered-background-color'];
newColor = parseInt(oldColor, 16);
newColor = '#' + (((newColor & 0x0000FF) + 1) | ((((newColor >> 8) & 0x00FF) + 1) << 8) | (((newColor >> 16) + 1) << 16)).toString(16);
cssVariables['hovered-background-color'] = newColor;
Fashion.css.setVariables(cssVariables);
Ext.defer(function() {
cssVariables['hovered-background-color'] = oldColor;
Fashion.css.setVariables(cssVariables);
}, 10);
}
},
title: 'Simpsons',
store: {
fields: ['name', 'email', 'phone'],
data: [
{ 'name': 'Lisa', "email":"lisa#simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart#simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home#simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge#simpsons.com", "phone":"555-222-1254" }
]
},
columns: [
{ text: 'Name', dataIndex: 'name', width: 200 },
{ text: 'Email', dataIndex: 'email', width: 250 },
{ text: 'Phone', dataIndex: 'phone', width: 120, flex: 1 }
]
}, {

How to connect Firebase in Chart.js?

I'm using Ionic and I have a CRUD that creates a list of name "Item":
item.models.ts:
export interface Item {
key?: string;
data: string;
humor: string;
mania: string;
numero: string;
medicamento?: string;
dormidas?: string;
menstrual?: boolean;
evento?: string;
impacto?: number;
outras?: string;
}
See how the data is stored in firebase:
So, how to connect the list data created in my chart done in Chart.js?
I can create a static graph only, I would like the graphic to be dynamic and with the data stored in Firebase. On the X axis I want to put the variable "data" and on the Y axis the variable "numero".
.HTML CODE:
<div class="row">
<div class="col-md-6">
<div style="display: block;">
<canvas baseChart width="600" height="400"
[datasets]="lineChartData"
[labels]="lineChartLabels"
[options]="lineChartOptions"
[colors]="lineChartColors"
[legend]="lineChartLegend"
[chartType]="lineChartType">
</canvas>
</div>
</div>
.TS CODE:
import { Item } from '../../models/item/item.models';
public lineChartData:Array<any> = [
{data: [-34, -78, 45, 65], label: 'Humor'}
];
public lineChartLabels:Array<any> = ['19/jun', '20/jun', '21/jun', '22/jun' ];
public lineChartColors:Array<any> = [
{ // grey
backgroundColor: 'rgba(148,159,177,0.2)',
borderColor: 'rgba(148,159,177,1)',
pointBackgroundColor: 'rgba(148,159,177,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(148,159,177,0.8)'
}
];
public lineChartLegend:boolean = true;
public lineChartType:string = 'line';
Could someone please help me connect Firebase to my chart?
I have not found any material on the subject.
If possible, I would like to see a practical example.
Ionic 3 is based off Angular 2/4/5.
There is a library that you can use to connect to Firebase called AngularFire2.
Here's the documentation:
https://github.com/angular/angularfire2
As far as the chart is concerned, you can get the data retrieved from the firebase. (Usually you have to loop through the array of retrieved Firebase data and clear the lineChartData[0].data element and assign the retrieved data into the element. Afterwards, two-way binding in Angular will do its magic.

Polymer google-chart table css

I'm trying to insert css in my google-chart table.
My code
var cssClassNames = {'headerRow': 'cssHeaderRow',
'tableRow': 'cssTableRow',
'oddTableRow': 'cssOddTableRow',
'selectedTableRow': 'cssSelectedTableRow',
'hoverTableRow': 'cssHoverTableRow',
'headerCell': 'cssHeaderCell',
'tableCell': 'cssTableCell',
'rowNumberCell': 'cssRowNumberCell'
};
var options = {page: 'enable', pageSize:20, height:'100%',
sort:'enable', showRowNumber: true, width: '100%',
showRowNumber: true,
alternatingRowStyle:true, allowHtml: true,
cssClassNames: cssClassNames}
this.$.chart_class.options = options;
But it's not working.
I have added
this.$.chart_class.set('options', options);
and
this.$.chart_class.redraw();
I need to style the pagination too.
Please provide full code and what exactly you need but if you have already chart exist and you need styling of chart then you may use element's styling :
<template>
<style>
google-chart {
height: 300px;
width: 50em;
......
}
.....
</style>
<google-chart
type="{{type}}"
options="{{options}}"
cols="{{cols}}"
rows="{{rows}}">
</google-chart>
In case if you need to specify google-chart property dynamically than specify cols and rows, besides your options are not formatted as into element description. But simply you may use and define properties dynamically:
At the property declaration, you may define this properties and options. Or in a function with the button or somehow with calling this function:
defininingChartVariables(){
var type = "pie" // See the possible types below link.
var cols = [<specify an array for cols>];
var rows = [<specify an array for rows>];
var options = {title: "Chart title goes here",
hAxis: {title: "Categories"},
vAxis: {title: "Values", minValue: 0, maxValue: 2},
legend: "none" };
this.set('type',type);
this.set('cols',cols);
this.set('rows',rows);
this.set('optiosn',options);
}
see the possible types

dojo 1.8 data grid populated from query not rendering

I want to create datagrid which is populated based on the query made to server
the code i have is
require(["dojo/dom", "dojo/_base/array", "dojo/dom-construct", "dojo/domReady!", "dojox/grid/DataGrid", "dojo/data/ObjectStore"],
function (DataGrid, ObjectStore, dom) {
var formQuery;
require(["dojo/dom-form"], function (domForm) {
formQuery = domForm.toQuery("form-filter");
});
var query = url + '?' + formQuery;
console.log(query);
var myStore;
require(["dojo/store/JsonRest"], function (JsonRest) {
myStore = new JsonRest({target: query});
});
grid = new DataGrid({
store: dataStore = new ObjectStore({objectStore: myStore}),
structure: [
{name: "ID", field: "id", width: "25%"},
{name: "Task-predmet", field: "subject", width: "25%"},
{name: "Dodavatel", field: "contractorCompany", width: "10%"},
{name: "Stav", field: "status", width: "10%"},
{name: "Termin", field: "deadline", width: "10%"},
{name: "Vytvorene", field: "created", width: "10%"}
]
}, "result-table-contractor-tasks-filter"); // make sure you have a target HTML element with this id
grid.startup();
the query is
http://localhost:8080/path?deadlineFrom=2015-11-15&deadlineTill=2016-11-15&createdFrom=2015-11-15&createdTill=2016-11-15
and it returns this
{"code":200,"status":"success","data":[{"id":1,"contractorCompany":"Best","status":"OTV","deadline":"Nov 4, 2016","subject":"","created":"Nov 3, 2016 1:11:22 PM"},{"id":3,"contractorCompany":"Best","status":"OTV","deadline":"Nov 14, 2016","subject":"a","created":"Nov 14, 2016 2:37:15 PM"}]}
but the datagrid is not rendering and i have no idea why. can you please help me? i'm using dojo 1.8
Because dojox modules are experimental, and the grid is deprecated, might I recommend using SitePen's current dgrid? It is being actively developed, and has an accompanying library dstore that includes a 'Request' data store which is made for exactly this purpose.
Otherwise, if you're still interested in using the dojox/DataGrid, check out this article: https://www.sitepen.com/blog/2008/11/21/effective-use-of-jsonreststore-referencing-lazy-loading-and-more/

CSS file not being included?

You might want to read the [update] first, as the nature of the problem has changed.
I am trying to add charting to an AngularJs app. I get the following error
angular.js:13236 Error: Please set height and width for the chart element
at validateHeightAndWidth (https://rawgit.com/chinmaymk/angular-charts/bower/dist/angular-charts.js:138:15)
at link (https://rawgit.com/chinmaymk/angular-charts/bower/dist/angular-charts.js:106:7)
at http://localhost/plafotrm_2/js/angular/angular.js:9486:44
at invokeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:9492:9)
at nodeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8978:11)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8226:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13) <div id="chart1" ac-chart="chartType" ac-data="chartData" ac-config="chartConfig" class="ng-isolate-scope">
However, in my index.html, I <link rel="stylesheet" href="css/charts.css" /> and in css/charts.css, I
.chartStyle
{
width: 500px;
height: 500px;
}
and the chart is supposed to go into
<div
data-ac-chart="bar"
data-ac-data="chartData"
data-ac-config="chartConfig"
class="chartStyle" >
</div>
It all looks fine to me, and I copied from a Plunk.
I am sure that I am pulling in the correct CSS File, because if I rename it, I get an error in the developer console. But even with no error about the CSS file, I get the error shown above.
Any ideas, anyone?
[Update]
After applying #SteveCampbell 's comment and answer, there are now no errors in the developer console - alas, there is also no chart on the page :-(
The HTML looks like this
<div data-ac-chart="'bar'" data-ac-data="chartData" data-ac-config="chartConfig" class="chartStyle ng-isolate-scope"></div>
no height or width, so that waitForHeightAndWidth : true is only masking the problem :-(
I think I need to read the docs ...
I have this in the controller ...
$scope.chartConfig = {
title: 'Products',
tooltips: true,
labels: false,
waitForHeightAndWidth : true,
mouseover: function() {},
mouseout: function() {},
click: function() {},
legend: {
display: true,
//could be 'left, right'
position: 'right'
}
};
$scope.chaartData = {
series: ['Sales', 'Income', 'Expense', 'Laptops', 'Keyboards'],
data: [{
x: "Laptops",
y: [100, 500, 0],
tooltip: "this is tooltip"
}, {
x: "Desktops",
y: [300, 100, 100]
}, {
x: "Mobiles",
y: [351]
}, {
x: "Tablets",
y: [54, 0, 879]
}]
};
The issue is not related to CSS. Probably it occurs because the chart element is not initially visible on the first digest cycle, and thus it gets an error when trying to determine the height and width.
The readme on https://github.com/chinmaymk/angular-charts implies that you can set config.waitForHeightAndWidth to true to avoid this problem.

Resources