fernman / angular-google-charts Goto Github PK
View Code? Open in Web Editor NEWA wrapper for the Google Charts library written in Angular.
License: Other
A wrapper for the Google Charts library written in Angular.
License: Other
I was wondering if someone could add a public function to the google-chart component that returns the wrapper object (the chart javascript object) so that I could be able to add dashboards and controls to my charts. To do that I need access to the chart object to bind to like in the example here:
https://developers.google.com/chart/interactive/docs/gallery/controls
dashboard.bind(donutRangeSlider, pieChart);
the pieChart object in the example is created the same way as the wrapper object in the component:
var pieChart = new google.visualization.ChartWrapper();
A function that returns the wrapper would allow all me to do all kinds of things the way they are done in the google documentation, without having to figure out how you got the library into the component.
thanks
Trying to figure out a way to save the resulting chart as an image, sorry for opening this as an issue - not sure where else to ask?
Hi
I am getting the values of [data] from an API. It renders fine in the first time. But when these values change, the chart does not redraw though [data] has updated. but the graph does not re render itself.
Is it possible to add my own events to the GoogleChartComponent? Or would it be possible to add an Input that takes an array of
interface ChartEventWithCallback { eventName: string, callback: Function }
of events that the GoogleChartComponent can register when it registers all other events? This might be a silly idea but I'm trying to add an observer to a chart that will observe the data points when the user zooms in on a certain section.
Are you planning upgrading to Angular 7 soon?
It seems as i cannot use the 'explorer' when on mobile? Cannot zoom or pan the chart. Dont know if it's the library but my bet its not? And If that's the case do this library support DateRangeFilter? It's for a continous linechart.
https://angular-vh5ijj.stackblitz.io/ The chart in ##question.
https://stackblitz.com/edit/angular-vh5ijj For the code.
#Helpwanted
Thank you for this project! I'm looking for example code for including and using ScriptLoaderService. It's not something I can find in this library.
I am trying to create a timeline chart in angular.
here is my code
app.component.html
<google-chart [data]="myData" [type]="type"></google-chart>
app.component.ts
@Component({`
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
title = "CodeSandbox";
myData = [
['Washington', new Date(1789, 3, 30), new Date(1797, 2, 4)],
['Adams', new Date(1797, 2, 4), new Date(1801, 2, 4)],
['Jefferson', new Date(1801, 2, 4), new Date(1809, 2, 4)]
];
type: string = 'TimelineChart';
}
It would be great to be able to get the chart to the full width of its parent element.
Currently width only supports numbers (converted to px) but it would be nice if one could pass %.
I get the following error: core.js:1673 ERROR TypeError: Cannot read property '__eventTarget' of null
I don;'t get these with charts from the core package, the OrgChart does however render correctly.
When I compile my Angular application with @angular/core 6.0.0 and angular-google-charts - the typescript compiler complains:
ERROR in node_modules/angular-google-charts/lib/google-charts.module.d.ts(5,44): error TS2315: Type 'ModuleWithProviders' is not generic
We are currently tied to version 6.0.0 of angular because of other dependencies. I was wondering it here is a way to get this component to work with version 6.0.0 of angular as well.
Thank you,
Mark
I'm using both Angular Google Maps https://angular-maps.com/ and angular-google-charts in my app. However, if google.maps gets loaded prior to google.charts, I get this error:
core.js:14597 ERROR TypeError: Cannot read property 'load' of undefined
at Observable._subscribe (angular-google-charts.js:87)
which is this line:
google.charts.load('45.2', config);
I believe that the source of the issue is here:
Object.defineProperty(ScriptLoaderService.prototype, "doneLoading", {
get: /**
* @return {?}
*/
function () {
if (typeof (google) !== 'undefined') {
return true;
}
return false;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ScriptLoaderService.prototype, "isLoading", {
get: /**
* @return {?}
*/
function () {
var _this = this;
if (typeof (google) === 'undefined') {
/** @type {?} */
var pageScripts = Array.from(document.getElementsByTagName('script'));
return pageScripts.findIndex(function (script) { return script.src === _this.scriptSource; }) >= 0;
}
return false;
},
enumerable: true,
configurable: true
});
where the test if (typeof (google) !== 'undefined') fails when google.maps is already loaded, which short-circuits the loading of google.charts.
My chart works fine if I avoid displaying a map prior to a chart. Is there a workaround?
Is necessary import this on my index.html ?
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script src="//www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
</script>
If I dont I get "google is not defined"
=> ERROR ReferenceError: google is not defined
I was wondering how you suggest to add the google object to an angular project so it can be access for making formatters or some of the more advanced chart operations (currently trying to figure out how to do a bar diff chart)
Thanks
Hi,
i am getting an error message saying " Geocoding Service: You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account For more information on authentication and Google Maps JavaScript API services please see: https://developers.google.com/maps/documentation/javascript/get-api-key"
in normal javascript , there is a provision to add "'mapsApiKey': 'AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'" in google.charts.load.. but here , where should it be added?
Hi FERNman,
Do you have a timeline on when the next publish to npm will be for the latest updates?
Thanks,
Alex
Hello,
I have a probleme witch i cant solve .. i try to add nodeClass : 'myClass' in my optionObject but the class is not loaded, but when i inspect node i see her in html but not any style applyed !! ..
Can't google chart component load class from my component .css file ?
Thank you
Angular 8 was release. Running ng update results in the following error
` ng update @angular/cli @angular/core
Your global Angular CLI version (7.3.8) is greater than your local
version (7.3.1). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Package "angular-google-charts" has an incompatible peer dependency to "@angular/core" (requires "^6.0.0-rc.0 || ^6.0.0" (extended), would install "8.0.0").
Package "angular-google-charts" has an incompatible peer dependency to "@angular/common" (requires "^6.0.0-rc.0 || ^6.0.0" (extended), would install "8.0.0").
Incompatible peer dependencies found. See above.`
Hi,
First of all, thank you for the project, the code it's pretty clear and it's easy to use. I've found a problem regarding the ready
event. If you put inside your component a event binding for the ready
event, the function associated to it does not execute. e.g. If you have this html
<google-chart
[type]="chartType" [data]="chartData" [options]="options"
[width]="width" [height]="height" (ready)="onReady()"></google-chart>
And you put a function such as:
onReady() {
console.log(height);
}
The code is not being executed when the chart is loaded.
Is there a way to solve this?
Thanks again for the library.
Regards
Trying to create a timeline or Gantt chart. (Thank you for the wrapper by the way)
home.component.ts
changingChart = {
title: 'Changing Chart',
type: 'timeline',
data: [
['Washington', new Date(1789, 3, 30), new Date(1797, 2, 4)],
['Adams', new Date(1797, 2, 4), new Date(1801, 2, 4)],
['Jefferson', new Date(1801, 2, 4), new Date(1809, 2, 4)]],
columnNames: [{ type: 'string', id: 'Term' }, { type: 'string', id: 'Name' }, { type: 'date', id: 'Start' }, { type: 'date', id: 'End' }],
options: {
animation: {
duration: 250,
easing: 'ease-in-out',
startup: true
}
}
}
home.component.html
<google-chart style="width: 100%" [type]="changingChart.type" [data]="changingChart.data" [columnNames]="changingChart.columnNames"
[options]="changingChart.options" [dynamicResize]="true"></google-chart>
I get an error on the console:
loader.js:222 GET https://www.gstatic.com/charts/45.2/js/jsapi_compiled_undefined_module.js net::ERR_ABORTED 404
Any thoughts?
I am sorry, but I keep having the 'google is not defined' error when I am using the "Formatter" object and I don't see how to load the script as you describe in the Readme.
Hi there,
So i'm trying to make a Timeline chart where the manager can see if the consultant is on a project or not.
The issue is that I can't change the color on each bar the right way, because I want the bar with projects in green and the bar without projects in red.
As you see, the consultant 2 has a project associated and it appears red instead of green, and when he doesn't have a project it appears green instead of red.
This is because I can't apply roles to the timeline chart, in others chart I tested and I could change the color as I wished, but in the timeline chart is other story.
So I have in options this:
chart.options = { colors: ["green", "red"] }
So the first value I insert will be green, the second (different from the 1st) red and the third will be green.
If I only needed two inserts (On Project and Without Project) this would work just fine, but I want (NameOfProject1, NameOfProject2, NameOfProject3, NameOfProjectN and Without Project)
I think it's a bug from this chart, but I want to make sure with you
Thanks for your help!
Best regards,
Fernando Caria
Hi,
So far I really like this project, it does exactly what it should do, and does it neatly.
As I'm developing an app for the Dutch crowd, it would be great to be able to set the locale for the charts. Google refers to it by 'language'. See their page about the language setting.
Have I maybe overlooked how to set this currently?
Regards
Hi,
i am getting an error message saying " Geocoding Service: You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account For more information on authentication and Google Maps JavaScript API services please see: https://developers.google.com/maps/documentation/javascript/get-api-key"
in normal javascript , there is a provision to add "'mapsApiKey': 'AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'" in google.charts.load.. but here , where should it be added?
Is there a way to re-render a chart without using the chart wrapper (because then I may as well not use this library?)
For instance, it renders fine the first time within a tab, but when I switch tabs and go back, the angular component is destroyed - when I re click the tab, it is initialized again but this time the chart does not load?
Thanks for the project!
I started using angular-google-charts before you had dynamic resize and added my own. I noticed the recently added implementation resizes on every window resize event which is fired a lot.
I did the the following at the parent container level but would be nice to have something like this at the component level:
ngAfterViewInit() {
fromEvent(window, 'resize')
.pipe(debounceTime(500))
.subscribe(() => {
this.chartComponents.forEach( c => {
c.wrapper.draw();
})
})
}
It could be very nice to be :)
I get a 404 error when the module tries to get the google script by the looks of it:
GET https://www.gstatic.com/charts/45.2/js/jsapi_compiled_undefined_module.js
Looks like there is a variable merging into the script name there which is undefined
, but there is no error handling to alert me to what is missing.
Could do with some guidance on what I have done wrong, and an enhancement here could be to check for undefined
and report it instead of allowing the GET to still fire.
Thanks for you help in advance!
When trying to set the data to it gives following error:
GET https://www.gstatic.com/charts/45.2/js/jsapi_compiled_undefined_module.js net::ERR_ABORTED 404
Even its random and sometimes its consistant.
Hi again, I am trying to figure out how to setup a multi series bar chart (multiple series of 3 bars) with annotations for each of the bars. I tried passing in the roles as an array like this:
roles: [
{ role: 'annotation' },
{ role: 'annotation' },
{ role: 'annotation' },
]
and columnNames like this:
columnNames: [ 'Name', 'Col1', 'Col2', 'Col3' ]
Then, my data does match the column ordering as if you concat columnNames and roles. But when the chart renders, the annotations are not in the right places. They appear to be showing up shifted down one group (bars are horizontal).
Is this the right way to do it with this package? Based on the examples in the google charts docs, It should be in order of column, annotation, column, annotation, etc...
But I don't see how to do that passing in with your columnNames and roles @input() 's
Am I missing something?
Looks as if this is "filtered" when setting the options. Anyway following the document does not show the vertical lines on the Line type
in google charts there is an option to provide column types as part of the data array.
google.visualization.DataTable parses it correctly. this is mainly important where you have dates that can be sent as a string "Date(1,1,2019)";
getDataTable function in goolge-chart-component prevents this.
is there a way to allow this?
Hi, great project and I love that I don't have to try and do this myself. I do have a question/request though. I looked at the script loader service and I see that you only include the corechart package and I was wondering if you are planning on adding the new material packages as well. It would be nice if I didn't have to do additional theming on the charts that already have the material themes in the newer packages like this example: https://google-developers.appspot.com/chart/interactive/docs/gallery/barchart#creating-material-bar-charts
thanks
Hi, @FERNman.
I tried to create a custom tooltip in a Timeline chart, but this chart not change the default tooltip.
Follow example of default tooltip:
The component has no errors.
I tested this same method in Bar chart and he works..
Example:
Not sure if this is an issue with the component or the library, but sometimes when I'm low on memory, and the chart is redrawn due to the data changing, I see the new chart below or next to the old chart before the old chart disappears. Any idea why that would happen and/or how I might fix it or hide it somehow?
import { ChartErrorEvent, ChartEvent, GoogleChartComponent } from 'projects/angular-google-charts/src/public_api'; errors with Cannot find module 'projects/angular-google-charts/src/public_api' as there is no projects folder in my project. What process sets up the projects folder with contents?
I'm not too sure on the specifics of web workers, just voicing a curiosity out loud. Cheers!
Hi,
I'm not 100% sure if this package is causing the issue but I seem to be losing zoom capability. After zooming once and resizing the window the chart doesn't allow for zooming anymore. It can still highlight the rectangle when dragging the mouse but doesn't do anything.
I've tried resizing the charts in pure javascript outside the project without the wrapper and the zoom isn't affected by resizing the window and redrawing the chart.
I've also tried reconstructing the redraw process with the wrapper like the updateChart function in this package and it still doesn't affect the zoom.
I made a custom component in our project that uses the GoogleChartComponent and dresses it up with some custom functionality that we need. Naturally, I thought this might be affecting it so I tried generating the chart by itself and it still affects the zoom so I'm pretty much out of ideas as to what might be messing with the zoom.
Any ideas as to what could be affecting this? Thanks!
Hello,
I get a loader.js:222 GET https://www.gstatic.com/charts/45.2/js/jsapi_compiled_undefined_module.js 404 () for some reason, please help!
Thank you
Hi,
I was trying to introduce formatter inside my code but when loading the application appears the following error:
vendor.js:56007 ERROR Error: Uncaught (in promise): ReferenceError: google is not defined
ReferenceError: google is not defined
at new SpecificInformationComponent (main.js:1640)
at createClass (vendor.js:63635)
at createDirectiveInstance (vendor.js:63520)
at createViewNodes (vendor.js:64740)
at callViewAction (vendor.js:65056)
at execComponentViewsAction (vendor.js:64975)
at createViewNodes (vendor.js:64768)
at createRootView (vendor.js:64654)
at callWithDebugContext (vendor.js:65685)
at Object.debugCreateRootView [as createRootView] (vendor.js:65172)
at new SpecificInformationComponent (main.js:1640)
at createClass (vendor.js:63635)
at createDirectiveInstance (vendor.js:63520)
at createViewNodes (vendor.js:64740)
at callViewAction (vendor.js:65056)
at execComponentViewsAction (vendor.js:64975)
at createViewNodes (vendor.js:64768)
at createRootView (vendor.js:64654)
at callWithDebugContext (vendor.js:65685)
at Object.debugCreateRootView [as createRootView] (vendor.js:65172)
at resolvePromise (polyfills.js:3136)
at resolvePromise (polyfills.js:3093)
at polyfills.js:3195
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2743)
at Object.onInvokeTask (vendor.js:58149)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2742)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (polyfills.js:2510)
at drainMicroTaskQueue (polyfills.js:2917)
The code I tried to introduce was:
myFormatter = [
{
formatter: new google.visualization.NumberFormat({ fractionDigits: 5 }),
colIndex: 1
}
];
I saw that there is an example project in the repository but I haven't found anything that says how to properly use objects imported from the chart js script. Do I miss any step?
Thank you for your time and for your effort to maintain the repository
Cheers!
demo.html
<google-chart [type]="type" [data]="data" [options]="options"></google-chart>
In demo.component.ts I have declared options variable with following values:
data = [
['State', 'Sales'],
['US-NY', 100],
['US-OR', 200],
['US-PA', 300],
['US-TX', 400],
['US-UT', 500]
];
options = {
region: 'US',
resolution: 'provinces',
defaultColor: '#3687ee'
}
By default GeoChart shows color gradient of 'defaultColor: '#3687ee', but after implementing it only shows same color (#3687ee) for every state 'data' and ' colorAxis' property also doesn't apply on chart.
Would be super useful
Hello, I hope you are well, I've found the library great so far for what I need but I'm having a problem now.
I'm using a chart in which the columns are [Date, number], you can see a screenshot of it here:
The thing is, I've added a formatter for the dates, so I can change how they look when you hover on a point, and this breaks the chart. This is the data that gets passed to the chart:
But the chart prints this error when I add the formatter:
I'm guessing it has something to do with it not being able to format the dates correctly?
I've also tried removing the first row of data which are the headers to see if that was it but the error persisted.
This is the html code for the chart:
<raw-chart [chartData]="rawCharts.Usd.smrCv" [dynamicResize]="true" [formatter]="formatter"></raw-chart>
If you could help me with this it would be great.
Thanks!
Best regards,
Tobías
I have created org chart using this angular 6 wrapper. I would like to do some changes based on click events.
(select)="onSelect($event) - this gives me only row and column. How can i get which item i have clicked?
I'm using angular-google-charts v0.1.4 with Angular 7, but npm is still complaining about angular-google-charts depending on angular core v6.
npm ERR! peer dep missing: @angular/core@^6.0.0-rc.0 || ^6.0.0, required by [email protected]
Is the peer dependency accurate?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.