Export an AM Stock chart - amcharts

Is there a way to enable exporting for a Stockchart? I know it is doable for a normal chart, but for a stock chart, I am getting undefined when try to enable the export mode,
I have tried: chart.export.enabled=true; and chart.amExport.enabled = true; and
var amExport = new AmCharts.AmExport();
amExport.enabled = true;
chart.export=amExport;
but all failed.
Thanks

Try to use the new initialization style of amCharts. See my answer to a question related to this.It seems like the old approach you tried is not working anymore. (At least my few tests were not running)To enable the export use this in the initialization code:
export: {
enabled: true,
position: "bottom-right"
}
And don't forget to include the needed export plugin!
A tutorial can be found here.
Take a look at this fiddle.
Update:
Ok, so this took me a bit, but i found a way, how you can the export feature dynamically. (With JS or JSON initialization)
chart.export = {
enabled: true,
position: "bottom-right"
}
chart.initHC = false;
chart.validateNow();
The key is to set initHC to false, because else it wont load the handler for the plugin. Then just validate again, add some pixie dust and tadaa - it works.

In addition to the above response to include the correct plugins, please ensure you are using html color codes such as "#FF0000" instead of "red" which is supported by earlier am chart export versions if you specify your own colors in the graph (graph.useDataSetColors = false) and valueaxis.
Export works fine whether you use the new JSON or the old style (I am still using the old style new AmCharts.AmStockChart() and $scope.chart.write("chartdiv");

Related

How to change group of CSS items in jqGrid

I want to change group of CSS items in jqGrid. Documentation is saying
Of course if we want to change not only one CSS item from a group, but two or more we can use jQuery extend to do this:
var my_col_definition = {
icon_move : 'ui-icon-arrow-1',
icon_menu : "ui-icon-pencil"
}
$.extend( $.jgrid.styleUI.jQueryUI.colmenu , my_col_definition );
And this is working partially. But I want to override all icons in my Bootstrap with next code:
$.extend($.jgrid.styleUI.Bootstrap, {
common: {
icon_base: "fa"
},
inlinedit: {
icon_edit_nav: "fa-edit"
},
navigator: {
icon_edit_nav: "fa-edit"
},
// ...
});
and my grid stops working and does not respond to any commands. There are no errors in console.
Do anybody know how to fix the problem in an elegant way and do not override every group separately?
It is unknown which versions of Guriddo jqGrid and Bootstrap are used.
I see you try to use the fontAwesome.
With the last release you can use fontAwesome with ths following settings:
<script>
$.jgrid.defaults.styleUI = 'Bootstrap4';
$.jgrid.defaults.iconSet = "fontAwesome";
</script>
And point to the needed css files as described in this documentation
You can change the icons the way you do in your code without problems - I have tested this and it works.
In any case, please prepare a simple demo which reproduces the problem, so that we can look into it.

Ckeditor plugin configuration not working

I have tried to add justify plugin to be able to align text right, left or centre. But after following the instructions in the documentation (http://apostrophecms.org/docs/tutorials/howtos/ckeditor.html), I wonder if the plugin should be located in a specific folder (mine is at public/modules/apostrophe-areas/js/ckeditorPlugins/justify/), as it disappears when the site is loaded, but if I include it in some other folder such as public/plugins/justify still doesn't work.
This is my code just in case: (located at lib/modules/apostrophe-areas/public/js/user.js)
apos.define('apostrophe-areas', {
construct: function(self, options) {
// Use the super pattern - don't forget to call the original method
var superEnableCkeditor = self.enableCkeditor;
self.enableCkeditor = function() {
superEnableCkeditor();
// Now do as we please
CKEDITOR.plugins.addExternal('justify', '/modules/apostrophe-areas/js/ckeditorPlugins/justify/', 'plugin.js');
};
}
});
Also, it would be nice to know how the plugin should be called at the Toolbar settings for editable widgets.
Thanks!
The URL you need is:
/modules/my-apostrophe-areas/js/ckeditorPlugins/justify/
The my- prefix is automatically prepended so that the public folders of both the original apostrophe-areas module and your project-level extension of it can have a distinct URL. Otherwise there would be no way for both to access their user.js, for instance.
I'll add this note to the HOWTO in question, which currently handwaves the issue by stubbing in a made-up URL.
As for how the plugin should be called, use the toolbar control name exported by that plugin — that part is a ckeditor question, not really an Apostrophe one. But looking at the source code of that plugin they are probably JustifyLeft, JustifyCenter, JustifyRight and JustifyBlock.
It turns out that it's not enough to simply call CKEDITOR.plugins.addExternal inside apostophe-areas. You also need to override self.beforeCkeditorInline of the apostrophe-rich-text-widgets-editor module and explicitly call self.config.extraPlugins = 'your_plugin_name';.
Here's what I ended up with:
In lib/modules/apostrophe-areas/public/js/user.js:
apos.define('apostrophe-areas', {
construct: function(self, options) {
// Use the super pattern - don't forget to call the original method
var superEnableCkeditor = self.enableCkeditor;
self.enableCkeditor = function() {
superEnableCkeditor();
// Now do as we please
CKEDITOR.plugins.addExternal('justify', '/modules/my-apostrophe-areas/js/ckeditorPlugins/justify/', 'plugin.js');
};
}
});
then in in lib/modules/apostrophe-rich-text-widgets/public/js/editor.js:
apos.define('apostrophe-rich-text-widgets-editor', {
construct: function(self, options) {
self.beforeCkeditorInline = function() {
self.config.extraPlugins = 'justify';
};
}
});
For some reason doing CKEDITOR.config.extraPlugins = 'justify' inside apostrophe-areas does not work, probably due to the way how CKEDITOR is initialized;
One more thing: this particular plug-in (justify, that is) does not seem to follow the button definition logic. It has button icons defined as images, whereas CKEditor 4.6 used in Apostrophe CMS 2.3 uses font-awesome to display icons. It means that the icons that ship with the justify module won't be displayed and you'll have to write your own css for each button individually.
There is another issue which you'll probably face when you finally enable the justify buttons. The built-in html sanitizer will be strip off the styles justify adds to align the content.
Apostrophe CMS seems to be using sanitize-html to sanitize the input, so changing CKEditor settings won't have any effect. To solve the issue, add the following to your app.js:
'apostrophe-rich-text-widgets': {
// The standard list copied from the module, plus sup and sub
sanitizeHtml: {
allowedAttributes: {
a: ['href', 'name', 'target'],
img: ['src'],
'*': ['style'] //this will make sure the style attribute is not stripped off
}
}
}
Thank you both for your help. After following both approaches of: locating the plugin at my-apostrophe-areas folder as well as editing editor.js on the apostrophe-rich-text widget (the sanitize.html file was already using that configuration), I got the plugin working. However, I was still having the issue with the icons.
I fixed that adding the Font Awesome icons that correspond to align-justify, align-right, align-left and align-center at the end of public/modules/apostrophe-areas/js/vendor/ckeditor/skins/apostrophe/editor.less

Epiceditor preview not working in Codeigniter

I've been playing with this for a couple days now to no avail. I've googled just about every descriptive phrase I can think of and nothing useful has turned up.
I have installed Epiceditor in Codeigniter and I have gotten it to the point that the preview button and full screen buttons 'work' and the css is properly working. The issue is that the preview text(in both the preview button and the full screen side-by-side) does not show the proper formatting (bold, italic, etc.). There are no console errors and I'm out of ideas at this point.
Code:
require(['epiceditor'], function() {
var opts = {
textarea: 'page_text',
basePath: '/css/epiceditor',
autogrow: true
}
var editor = new EpicEditor(opts).load();
});
I had the same issue as you when using EpicEditor with requirejs. It seems that the epiceditor script includes marked at the bottom and it is this that is being injected when require the script. Try this:
require(['epiceditor'], function(marked) {
var opts = {
textarea: 'page_text',
basePath: '/css/epiceditor',
autogrow: true,
parser: marked
}
var editor = new EpicEditor(opts).load();
});

ckeditor how to allow for .insertHtml("<customTag myAttr='value'"></customTag>")

var currentDialog = CKEDITOR.dialog.getCurrent();
currentDialog._.editor.insertHtml("<customTag myAttr='var'></customTag>");
Throws an error, TypeError: Cannot read property 'isBlock' of undefined
If I try .insertHtml("<span>hello</span>") it works just fine.
How can I change ckeditor to allow me to specify my own custom html tags via .insertHtml()? I'd love to just change it to be something like <span class='custom'... or something like that, but I'm having to deal with legacy CMS articles. Using latest ckeditor. Thanks.
You need to modify CKEDITOR.dtd object so editor will know this tag and correctly parse HTML and process DOM:
CKEDITOR.dtd.customtag = { em:1 }; // List of tag names it can contain.
CKEDITOR.dtd.$block.customtag = 1; // Choose $block or $inline.
CKEDITOR.dtd.body.customtag = 1; // Body may contain customtag.
You need to allow for this tag and its styles/attrs/classes in Advanced Content Filter:
editor.filter.allow( 'customtag[myattr]', 'myfeature' );
Unfortunately, due to some caching, in certain situations you cannot modify DTD object after CKEditor is loaded - you need to modify it when it is created. So to do that:
Clone the CKEditor repository or CKEditor presets repository.
Modify core/dtd.js code.
And build your minified package following instructions in README.md - the only requirements are Java (sorry - Google Closure Compiler :P) and Bash.
PS. That error should not be thrown when unknown element is inserted, so I reported http://dev.ckeditor.com/ticket/10339 and to solve this inconvenience http://dev.ckeditor.com/ticket/10340.
I worked around this issue with a combination of createFromHtml() and insertElement()
CKEDITOR.replace('summary', { ... });
var editor = CKEDITOR.instances.summary;
editor.on('key', function(ev) {
if (ev.data.keyCode == 9) { // TAB
var tabHtml = '<span style="white-space:pre"> </span>';
var tabElement = CKEDITOR.dom.element.createFromHtml(tabHtml, editor.document);
editor.insertElement(tabElement);
}
}

How to set link font for TTStyledTextLabel

So, I'm fairly new to Three20, but so far the benefits have outweighed the pains in my ass that it's taken to get things working.
I'm using some TTStyledTextLabels, and I need to use a particular font for links. I've overridden TTDefaultStyleSheet and added a new style, like so:
- (TTStyle*)futuraStyle {
return [TTTextStyle styleWithFont:[UIFont fontWithName:#"Futura-CondensedMedium" size:20] color:kColorTextLink next:nil];
}
I can use tags to apply this style to normal text, but it doesn't seem to affect links.
I found that if I add the style class directly to the links, as in
link!
then the links do appear in the proper font. However, they are then no longer tappable! WTF?
Got it!
set the name in the link with a double dash and than the link style will be called with the UIConstrolState parameter, and all will work fine:
- (TTStyle*)futuraStyle:(UIControlState)state{
if(state==UIControlStateNormal){
return [TTTextStyle styleWithFont:[UIFont fontWithName:#"Futura-CondensedMedium" size:20] color:kColorTextLink next:nil];
}else{
return [TTTextStyle styleWithFont:[UIFont fontWithName:#"Futura-CondensedMedium" size:20] color:kColorTextLinkHiglighted next:nil];
}
}
and in your text:
link!

Resources