-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: "legend" plugin is not defined - cannot use any of the default plugins? #521
Comments
@tyronedougherty the |
Ah I see. Are there any typescript definitions for the plugins? From what I can gather this project is a bit of a mix of typed and non typed files? |
Taucharts have a type definition in a separate file, it was written for Taucharts v1 and updated a little bit. There are no definitions written for separate plugins as modules, it can be used this way: import Taucharts from 'taucharts';
import 'taucharts/dist/plugins/tooltip';
const chart = new Taucharts.Chart({
// ...
plugins: [
Taucharts.api.plugins.get('tooltip')(),
],
}); So currently both ways of utilizing plugins work: using Taucharts registry and using modern ES2015 imports. To make type definition work for ES2015 imports and for usage as global objects it should be updated like this: declare namespace Taucharts {
namespace Plugins {
namespace Tooltip { }
function Tooltip(tooltipSettings?: {
fields?: string[];
escapeHtml?: boolean;
// ...
}): {
init: any;
destroy: any;
// ...
}
}
}
declare module 'taucharts' {
export = Taucharts;
}
declare module 'taucharts/dist/plugins/tooltip' {
export = Taucharts.Plugins.Tooltip;
} Here is an example of a type definition that works this way. JS bundler should also be configured to generate global namespaces in UMD definitions like So, I would suggest some changes to make it look less confusing:
|
I like this suggestion, as unfortunately in its current state I've had to cease working with TauCharts in our teams project given the difficulty of integration with a strictly enforced TypeScript environment. I don't have the time to perform this work, but if someone else were to get around to it someday I would be greatly appreciative! :) TauCharts in a javascript environment is very easy to use. |
After installing with NPM, and using the ES6 import of
tauCharts
like so:For some reason I cannot use any of the provided default plugins? It doesn't seem any of them are registered in the
dist/taucharts.js
file (which is defined as themain
inpackage.json
)? But they are possibly combined into thedist/taucharts.min.js
file (which cannot be imported if you're using TypeScript)?If I attempt to use one of the built in plugins (such as
legend
):I get the following error in the console:
Any solutions on how to fix this?
The text was updated successfully, but these errors were encountered: