How to get a map of all series "type" names to parameters for HighCharts technical indicator series? - highcharts

In highcharts stock charts, different series types have different parameters for example the paramaters for macd can be seen here:
https://api.highcharts.com/highstock/series.macd.params
I would like to be able to get a map of type names, like "macd" or "sm", to parameters. Preferably an example using the typescript version of Highstock, or even better if it was in angular-highcharts.
For example:
{
"sm" => ["index" : 1 , "period": 2],
"macd" => ["index": 11, "longperiod":12 , "period":23, "shortperiod":22],
.
.
.
}
Edit:
To clarify, how would I create an object with the default params across all indicators as shown for MACD here on line 97:
https://github.com/highcharts/highcharts/blob/9b3c23b50892f96487593fd7e553d9432e60f635/ts/Stock/Indicators/MACD/MACDIndicator.ts#L97
I would like to get the params before adding the series to the chart if possible.

This is a path to find params options for MACD indicator
chart.series[2].options.params. Another indicators can be show as a series linkedto bind to the series.
Demo: https://jsfiddle.net/BlackLabel/wa83fhdb/

The params for each type are available through the Highcharts.Series.types variable:
import * as Highcharts from "highcharts/highstock";
import HC_exporting from 'highcharts/modules/exporting';
HC_exporting(Highcharts);
import {Dictionary, PlotMacdOptions, Series, SeriesOptions} from
"highcharts";
import IndicatorsAll from "highcharts/indicators/indicators-all";
IndicatorsAll(Highcharts);
const seriesType = "macd";
const types: any= Highcharts.Series.types;
console.log( types[seriesType].defaultOptions.params);

Related

How to create a tooltip showing multiple values of a field in Altair?

I have successfully created an interactive chart as the tutorial here and below is my result:
I want to create a tooltip as the image below:
But I cannot find any hint in Altair tutorial document.
Can anyone provide a suggestion about how to proceed?
You can create a single tooltip for multiple lines using the pivot transform. Here is an example using one of the vega datasets.
THe idea is that the tooltip is tied to the vertical rule mark, which represents a pivoted version of the data where each relevant value is in the same row:
import altair as alt
from vega_datasets import data
source = data.stocks()
base = alt.Chart(source).encode(x='date:T')
columns = sorted(source.symbol.unique())
selection = alt.selection_single(
fields=['date'], nearest=True, on='mouseover', empty='none', clear='mouseout'
)
lines = base.mark_line().encode(y='price:Q', color='symbol:N')
points = lines.mark_point().transform_filter(selection)
rule = base.transform_pivot(
'symbol', value='price', groupby=['date']
).mark_rule().encode(
opacity=alt.condition(selection, alt.value(0.3), alt.value(0)),
tooltip=[alt.Tooltip(c, type='quantitative') for c in columns]
).add_selection(selection)
lines + points + rule

HighChart xAxis and data discrepancy

There is some xAxis and data discrepancy, for example the second curve I need to be pictured as 2014-03 and 2014-04., but it drawn 2013-11; 2013-12
Is there exist some method where HighChart gets data in pairs, because in this case I have folowing json: [{"name":"xAxis","data":["2013-11","2013-12","2014-01","2014-02","2014-03","2014-04"]},{"name":"FIRSTname"","data":[81568256,93170615,92267597,97838553,103930539,103268030]},{"name":"SECONDname"","data":[20705697,23387653]}]
And I don't know how to inform HighChart "Hey, buddy, plz draw this curve from '2014-03' to '2014-04' for example.
Or something like "data": ['not draw this point', '1234', 'not draw this point', '1234']
So in this case he can easily understand that '1234' is for '2013-12', because it goes second.
Thanks
In the second serie data, points require to be pairs [x,y] instaed of y value. As a result use it: {"name":"SECONDname"","data":[[4,20705697],[5,23387653]]}]
Use null for data you don't want the chart to show
data: [null, 1234, null, 1234]
Here's an example: http://jsfiddle.net/ks22pgja/

Is it possible to use null datapoints with a datetime x-axis?

I'm trying to use the type:'datetime' for my x-axis, and am getting a graph on a vertical line and dates going all the way back to 1970. Is there any way to circumvent this error?
Here's my use case: I'm tracking my page performance at regular intervals. if the server goes down for any reason or the metric was unable to be tracked, then we end up with a gap in the line. the requirement is to show this as datetime, but if i populate the series with any null datapoints, Highcharts throws an error 15.
series: [{
data: [
{x:1389254400000,y:10},
{x:1389554400000,y:9},
null,
{x:1389854400000,y:12}]
}]
Here's the fiddle: http://jsfiddle.net/agjZB/23/
If i remove the null datapoint, everything works fine. Thanks for the extra eyes!
You have to make the NULL point the same format as your other points.
Or, don't include it. If you have no data for timestamp x why include it or if you have no data at all why include it?
Example of option 1:
series: [{
data: [
{x:1389254400000,y:10},
{x:1389554400000,y:9},
{x:1389554400000,y:null},
{x:1389854400000,y:12}]
}]
For line chart you shouldn't use points with the same x value, becasue a few feateaures like tooltip will not work correct. You need to set scatter type and lineWidth as 2.

Specify xAxis values with columnRange chart in Highchart

I am using highchart, trying to make a chart that shows high and low values for the number of people occupying various rooms. So I have a data like this:
[[roomName, low, high], [roomName, low, high] ...]
For example:
["XRay", 12, 45], ["Waiting Room", 8, 22], ["Admitting", 22, 56]]
What I want to have happen is for the x Axis to use the room names as the values on the category axis. But I can't see to get this to happen. It uses them as the names of the points instead.
If I am just doing a column chart, I can set x and y properties for the points:
[x:"XRay", y:12], [x:"Waiting Room", y:8], [x:"Admitting", y:56]]
But I don't know how I can do this with column ranges.
I can of course manually parse the data and set the categories of the xAxis myself, but I am wondering if there is a better way.
Thanks!
It could be done in two ways, as suggested categories, or using label formatter, both are here: http://jsbin.com/oyudan/17/edit
Formats:
[ {x: 'string' } ... ]
are not proper.

Variable in valueSuffix?

Is it possible reference a point from a series within the valueSuffix parameter?
I want to include a percentage value within the Suffix by dividing the height of the series 1 column by the height of the series 2 column.
So something like the following:
valueSuffix: ( series[1].max / series[2].max ) + ' %'
Is this possible?
Thanks in advance!
Armin
The API states this : valueSuffix: String
Which means the valueSuffix can only be a String. If you want something more complex than a string, consider using tooltip.formatter instead
Inside the formatter you will have access to the chart as this.series.chart and from the chart you can then access any series or any point you may wish to

Resources