Dynamically adding scale markers? - zingchart

I was wondering if there was any way to dynamically add scale-x markers AFTER the graph has been rendered, perhaps via a function like-so:
zingchart.exec('myChart', 'addscalexmarker', {
type: "line",
range: 14,
label: {
text: "label!! yay!"
}
}
I can't seem to figure out any other way to get this to work... Thanks in advance!

While ZingChart does have a large range of API methods to allow users to modify different pieces of a chart, not every attribute is accessible through a named method.
My suggestion would be to use the setdata method which is a catch-all API method to modify the chart's JSON. The management of the chart's state would be external to ZingChart, but updates would be handled with a single setdata method call.
zingchart.exec('myChart', 'setdata',{
data : myConfig
});
Working Demo : http://demos.zingchart.com/view/BG8SXI4W
I am on the ZingChart team -- let me know if you have any further questions.

Related

Display custom product association data in a new tab

I wrote an extension to add data to the ProductEntity in Shopware 6 and used the following tutorial:
https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities
I also used another tutorial (https://developer.shopware.com/docs/guides/plugins/plugins/administration/add-new-tab) to add a new tab to the product detail view. Everything works so far.
In the product detail view I added a text field in my custom tab. But my problem is: how to get my data into the view? I want to add my new association to the product when the detail view is loaded. Therefore I tried to override the component from Shopware as follows:
Shopware.Component.override('sw-product-detail', {
template,
mounted() {
const criteria = this.productCriteria;
criteria.addAssociation('myNewAssociation');
this.productCriteria =criteria;
},
});
This does not work because productCriteria has no setter (original component can be found here: https://github.com/shopware/platform/blob/6.4.1.0/src/Administration/Resources/app/administration/src/module/sw-product/page/sw-product-detail/index.js)
Does anyone know how I can add a custom association to an existing one in vue.js in Shopware 6? What's the correct way to inject a custom association to the product detail view so I can use data from that in my new custom tab? The documentation always stops when it becomes interesting...
I would suggest to overwrite the productCriteria method and call the parent to not need to fully copying the existing code, like this:
Shopware.Component.override('sw-product-detail', {
template,
computed: {
productCriteria() {
const criteria = this.$super('productCriteria');
criteria.addAssociation('myNewAssociation');
return criteria;
},
},
});
Let me know if it works.
I believe also you don't need to mention the template in the override (when I did this last time, the template was displayed twice)
EDIT: All good with the template.

Kentico 9 - Add content to an Editable Image Region (CMSEditableImage) programatically

We are looking for information on how to add content to an Editable Image programatically (with the Kentico C# API). Essentially, the equivalent of this Editable Region article for an Editable Image.
Any suggestions?
Thanks,
Victor
References:
CMSEditableImage Docs
Devnet Update EditableRegion Programatically
CMSEditableImage Class
You Sure Can
Each individual editable cms page control is stored in the document's DocumentContent field and can be accessed using an indexer field. For example:
TreeNode document = DocumentContext.CurrentDocument;
string editableImageControlId = "EditableImage1";
// get the field value
string editableImageContent = document.DocumentContent.EditableRegions[editableImageControlId];
// set it to something new
document.DocumentContent.EditableRegions[editableImageControlId] = newValue;
HOWEVER
If you look at the DocumentContent field in CMS_Document in the database you'll notice that all of the content is XML. That's because each control is serialized into XML and then nested inside this field. Thus, in this case, the value of the editableImageContent variable is an XML string:
<image>
<property name="imagepath">
~/Folder/ImageName.png
</property>
</image>
I wouldn't recommend trying to modify this directly since there's no telling if Kentico would ever change this code, or the individual control would ever change its serialization output.
But if you really must
You've got a couple of options:
1. Per #josh, you could create a new control that wraps the existing one and do some method override magic so that the control continues to do the serialization on your behalf and you just modify it after the fact. However this requires that the control is currently loading.
2. You could just hard code the beast and deal with it if it ever changes (which it likely will). Try:
// get the node from wherever you need to get the node
TreeNode document = DocumentHelper.GetDocuments().TopN(1).FirstObject;
var relativeMediaFilePath = "~/NewImage.png";
var xmlImage = string.Format("<image><property name=\"imagepath\">{0}</property></image>", relativeMediaFilePath);
var cmsControlId = "editableImage1";
if (document.DocumentContent.EditableRegions.ContainsKey(cmsControlId)) {
document.DocumentContent.EditableRegions[cmsControlId] = xmlImage;
}
else {
document.DocumentContent.EditableRegions.Add(cmsControlId, xmlImage);
}
// a little hack to get this field to be indicated as updated
document.SetValue("DocumentContent", document.DocumentContent.GetContentXml());
document.Update(true);
You could clone the editableimage webpart and then work in the prerender or change the override for the GetContent() method and add your own part of the string or do a string replace and add your code.
What is that you want to add to an Editable Image? - image path?! Not sure why you'd do that, but I'd take another direction: I'd add a field to a page type, which makes it much easier to work with through API. Having this field set up with API is should be quite easy to get it on the page... e.g. place editable image and use a macro to get field value.
Use
node.DocumentContent.EditableWebParts
and
node.DocumentContent.EditableRegions
collections to programmatically update editable content.
The best code example can be spotted at \CMS\CMSModules\Content\CMSDesk\Properties\Advanced\EditableContent\Main.aspx.cs
It's the dialog under Pages->General->Advanced->Edit regions & web parts.

Passing an object from a tabbarController to its subviews

I am trying to pass a simple core data objects info from a tabBarController to its subviews so that they each reference a different attribute of that object. As a newbie, I'm not sure even where to start. It doesn't seem to be as simple as passing the data from one tableView to another...
Thank you for any help.
If you are sharing the same object between (most of the) the view controllers of your tab bar controller, maybe the best architecture for this would be to have one central data object.
A typical pattern is a singleton, some kind of data manager that provides the object, but maybe that is overkill. Another is to keep references to all view controllers and update them one by one when something changes - also not very elegant.
What you really want is something like a global variable. You could (ab)use your app delegate (just give it a property that points to the object) or if you prefer even your tab bar controller (make a subclass, give it a property). In the latter case, every view controller could then get the object like this:
NSManagedObject *object = [(MyCustomTabBarController*)self.tabBarController object];
For example, you can check for changes and refresh your views in viewWillAppear.
A UITabBarController should be handling other view controllers, not handling data objects. How does the tab bar controller get the object reference in the first place? And what is the object you're sharing?
Let each of your subordinate VC's keep a pointer to the object, and then they can each follow the appropriate keypath to get to the entities they're designed to handle.
Tim Roadley's book Learning Core Data for iOS, in chapters 5 and 6, shows how to pass an object from one view controller (a table view) to a detail view. It doesn't sound like that's what you're asking, but just in case...
In response to comment:
I'm looking at a tableview, tap a cell, and then a tab bar controller slides in? That's not the usual visual metaphor for a tab bar; it's meant for changing modes for the entire program. See the Music app for a typical example: songs, playlists, artists.
But if you really need to do it that way, try this (I'm assuming you're using storyboards):
In prepareForSegue: in your tableview controller, tell the destination (tab bar controller) what object it's working with.
In the tab bar controller's -viewWillAppear, tell each of its tabs about the attribute: self.frobisherViewController.frobisher = self.myWidget.frobisher.
You could instead tell each of the component tabs about the top level object: self.frobisherViewController.widget = self.myWidget. But I like the first approach better because there is less linkage. The frobisherViewController now would need to know about both widgets and frobishers.
This ended up being very simple. I was trying to call the object in the child views initWithNibName which doesn't work. I ended up creating a setObject function and calling the properties I wanted in viewWillAppear.
Hope this helps someone.

YUI widgets - dynamic updates

I am new to web programming and of course to YUI.
I tried using the overlay, chart and node-menunav.
Wanted to know if there is any option of creating these widgets using dynamic data coming in JSON format and updating the widgets as the new data comes in?
For us all the properties will come in JSON data from server and then using that data we need to render menubars, charts, property browser. Now i am not finding how to proceed with this requirement.
Thanks.
There is no default way of syncing widgets via Ajax. The only widget that comes by default with ways of updating its data is the DataTable widget. For the rest, and even for DataTable's attributes, you need to do it yourself.
However, if the data and widgets are complicated enough, you should consider using the YUI App Framework. The combination of Models and Views will help you a lot for creating complex layouts with widgets. Model will give you a way to link attributes to a JSON backend easily, specially if you're using a RESTful API endpoint. And View will give you tools for setting up the markup and reacting to events.
The Model's load and change events will let you know when the data updates. So in your view you'll be able to react to these events and set the corresponding attributes in your widgets:
var MyView = Y.Base.create('myView', Y.View, [], {
initializer: function () {
this.get('model').on('change', this._updateWidgets, this);
},
_updateWidgets: function () {
var model = this.get('model');
this.someWidget.set('someAttr', mode.get('someAttr'));
}
});
But as I said there is no right way of doing this. You can use whatever technique you like. The App framework is just a set of basic components that you can use to structure you application. It's designed for flexibility so it can accommodate many ways of using it. Other ways could use IO directly or use DataSources combined with Widget Plugins. This is a question with many correct answers.

get the render name jade

I am trying to have the render name in my jade
I could do:
app.render('email', { render: 'email' }, function(err, html){
// ...
});
but I'd like to know if there is a solution to get it automaticly
Thanks
I have found it helpful to write a wrapper function around render that takes a response object, a view name, and any additional options. I then use this function exclusively instead of res.render. My implementation does things like automatically decorating the title, assigning a unique view id to all views, etc. I use it like:
render(res, 'user.new', {title: 'sign up'});
In this example, the function takes the view name 'user.new' and gives it a unique id: 'user_new_view' assigned to the body element. In your case you could simply pass the value to your template.
The benefit of this pattern is that a single function acts as an interface to all of your views (assuming you use it consistently), so if you need to change the information passed to your views you don't have to edit every endpoint in your application.

Resources