Unable to create custom indicator - javascript

Checked all the samples in here: https://www.anychart.com/products/anystock/gallery/Stock_Technical_Indicators/?theme=darkEarth All are calculated by any chart functions. indicatorPlot is getting members like .adl etc..
Also checked the sample here with setCalculationFunction: https://www.anychart.com/blog/2018/03/14/custom-technical-indicators-javascript-stock-charts/
Is there a way to "map indicatorPlot" with a csv values like drawing the main graph? Or is datatable can store indicator values to show underneath the chart like oscilators.
The main question is: Is there a way to display a custom oscillator under the chart feeded with values from csv, json etc.. ?

Yes, in this case, the indicator is a usual series that is based on your data. Simply create a series from your data, provide the desired name and that's it.

Related

ChartJS re-rendering bug

So I'm building a trading tool and am using chartJS for the charts. This is how my charts look now on the page:
So my problem is that when I change the time period of the chart, the chart shows randomly the old data mixed with the new one.
You can see the behaviour here: https://gifyu.com/image/vda5
For now I can't use the Big chart together with the small one on the same page because the big chart which has the timing period has also multiple AJAX calls so every time I click on "1W" for example, a new call is being made and the chart is drawn over.
Things I tried:
I know that for dynamic charts in chartJS I have to destroy the chart, so I'm using
if (window.chart !== undefined) window.chart.destroy();
and for the small charts I use an empty array and push the elements inside. Here is how I do it:
if ($(quoteDisplayEl).hasClass('quoteDisplay-light')) {
chartHandel.push(quoteChart);
} else {
window.chart = quoteChart;
}
so for the big chart I assign it to a global variable and the small one I push it to the empty array - that allows me to have multiple charts on one page.
But in order for the big chart to be destroyed I should destroy and re-render all charts from scratch (I guess) and I tried multiple was of achieving that with now luck.
Unfortunately the code is over 500 lines and has lots of variable data coming from APIs and DB thus I can't make a fiddle demo.
I prefer chart.update() over chart.destroy().
Here's a small, simple example how I usually update data.
I make one object per chart with labels (empty array) and data (empty array) and colors and all the stuff you need.
I fill these arrays with data I get (AJAX).
Optional: If I get all the data and need to filter it to show less data, I copy my object to keep all the data I got and have all the data I need now for my chart in another object
Make an updateChart() function which alters your displayed data or saved data from your backup object or use new data from a new AJAX request.
End your updateChart() with chart.update() (or whatever your chart is called).
Multiple charts shouldn't be a problem and you shouldn't have to destroy your chart.

Cannot read property 'info' of undefined

I am having an issue where I get the error in the title of this question when I create a chart like the one in this fiddle http://jsfiddle.net/w43m47hL/.
I get this problem when selecting a point.
this.select();
The problem occurs when performing these steps.
create the chart
click on a point to select it
destroy the chart
create the chart again
The size of the data set seems to have something to do with the problem. If you change 1500 to 15 you will see that you don't get this problem any more. However the data point that was selected is still selected after the chart is destroyed and created again. I would have thought that the point would not be selected since the chart was destroyed. How is the data point remembering that it was selected?
The issue is caused by keeping reference to "old" data array. During chart initialisation, you set the reference to data array, which is modified. So when you destroy chart, reference still exists. Use the copy of data ($.extend([],data)) in Highcharts objects.
series: [{
data: $.extend([], data)
}],
Example:
http://jsfiddle.net/nazr3det/

D3 - Best way to format data for multi-series column chart

I have 8 categories of data per facility and have created an interface to compare multiple facilities against each other for 'scoring'. The categories are not related to each other in any sort of fashion. The last element to add is a graph with the facility scores graphed against the other selected facilities. When looking at the examples online, most data is in a CSV format but I will be swapping out values triggered by a drop-down list.
Example of data...
facility_score = {
"a":20,
"b":30,
"c":1,
"d":55, ...
}
I have a finished "single" facility done and want to expand upon it.

Dependent Controls with more than 1 data series - Google Chart Tools

I'm trying to create a google chart with dependency controls that will contain multiple data series. What I want to do is, in effect, generate this: http://code.google.com/apis/ajax/playground/?type=visualization#column_chart BUT with a dependency control like here: http://code.google.com/apis/ajax/playground/?type=visualization#dependent_controls
This is my data structure:
Year (options 2008,2009,2010,2011)
Variable (options Age Category)
Category (options 18-24,25-34,35-49,50+)
Population Proportion (options proportion1, proportion2, proportion3, proportion4)
I know I need to create arrays to be able to get this done, however, I'm not by any means a javascript person and I've gotten as far as creating ONE data series, but can't seem to find a way to be able to plot multiple data series on the same graph.
Any help would be much appreciated!

Stacked Bar And Scatter Alignment

I have a chart here: http://jsfiddle.net/wergeld/bx82z/
What I need is for the stacked bars and the scatter points to line up on each other based on the data X-element (county name in this case).
Getting the bars to stack was simple. But as you can see in the example the scatter points show up in the middle of the chart - not on the same x-value as the others.
I suppose I could create a category list (using the county names) but there may be cases where I do not have all 3 data elements for all counties - how to handle that scenario?
I did great the category axis and it is still doing the same thing: http://jsfiddle.net/wergeld/YckwW/
You were not defining the series correctly to achieve what you were wanting. See updated jsfiddle for what I think you are looking for.
In the cases where you are missing a piece of data for one of the countries you could always use null, which simply means there is nothing to display for that data point. See Missing Data Sample for an example. It is case sensitive so make sure that null is all lower case.

Categories

Resources