diff --git a/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs b/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs index b2a59d6e8..8bebbb778 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs @@ -971,5 +971,317 @@ public static GenericChart.GenericChart PointDensity( ShowScale: ShowScale.ToOption(), UseDefaults: UseDefaults.ToOption() ); + + /// + /// Creates an OHLC chart. + /// + /// The ohlc (short for Open-High-Low-Close) is a style of financial chart describing open, high, low and close for a given `x` coordinate (most likely time). The tip of the lines represent the `low` and `high` values and the horizontal segments represent the `open` and `close` values. Sample points where the close value is higher (lower) then the open value are called increasing (decreasing). By default, increasing items are drawn in green whereas decreasing are drawn in red. + /// + /// Sets the open values. + /// Sets the high values. + /// Sets the low values. + /// Sets the close values. + /// Sets the x coordinates. If absent, linear coordinate will be generated. + /// Sets the trace name. The trace name appear as the legend item and on hover. + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the Opacity otf the trace. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the line of this trace. + /// Sets the color of increasing values + /// Sets the style options of increasing values (use this for more finegrained control than the other increasing-associated arguments). + /// Sets the color of decreasing values + /// Sets the style options of decreasing values (use this for more finegrained control than the other increasing-associated arguments). + /// Sets the width of the open/close tick marks relative to the "x" minimal interval. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart OHLC( + IEnumerable open, + IEnumerable high, + IEnumerable low, + IEnumerable close, + IEnumerable x, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional Line = default, + Optional IncreasingColor = default, + Optional Increasing = default, + Optional DecreasingColor = default, + Optional Decreasing = default, + Optional TickWidth = default, + Optional UseDefaults = default + ) + where OHLCType : IConvertible + where XType : IConvertible + where TextType : IConvertible + => + Plotly.NET.Chart2D.Chart.OHLC( + open: open, + high: high, + low: low, + close: close, + x: x, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + Line: Line.ToOption(), + IncreasingColor: IncreasingColor.ToOption(), + Increasing : Increasing.ToOption(), + DecreasingColor: DecreasingColor.ToOption(), + Decreasing: Decreasing.ToOption(), + TickWidth: TickWidth.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Creates a candlestick chart. + /// + /// The candlestick is a style of financial chart describing open, high, low and close for a given `x` coordinate (most likely time). The boxes represent the spread between the `open` and `close` values and the lines represent the spread between the `low` and `high` values Sample points where the close value is higher (lower) then the open value are called increasing (decreasing). By default, increasing candles are drawn in green whereas decreasing are drawn in red. + /// + /// Sets the open values. + /// Sets the high values. + /// Sets the low values. + /// Sets the close values. + /// Sets the x coordinates. If absent, linear coordinate will be generated. + /// Sets the trace name. The trace name appear as the legend item and on hover. + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the Opacity otf the trace. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the line of this trace. + /// Sets the color of increasing values + /// Sets the style options of increasing values (use this for more finegrained control than the other increasing-associated arguments). + /// Sets the color of decreasing values + /// Sets the style options of decreasing values (use this for more finegrained control than the other increasing-associated arguments). + /// Sets the width of the whiskers relative to the box' width. For example, with 1, the whiskers are as wide as the box(es). + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart Candlestick( + IEnumerable open, + IEnumerable high, + IEnumerable low, + IEnumerable close, + IEnumerable x, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional Line = default, + Optional IncreasingColor = default, + Optional Increasing = default, + Optional DecreasingColor = default, + Optional Decreasing = default, + Optional WhiskerWidth = default, + Optional UseDefaults = default + ) + where OHLCType : IConvertible + where XType : IConvertible + where TextType : IConvertible + => + Plotly.NET.Chart2D.Chart.Candlestick( + open: open, + high: high, + low: low, + close: close, + x: x, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + Line: Line.ToOption(), + IncreasingColor: IncreasingColor.ToOption(), + Increasing: Increasing.ToOption(), + DecreasingColor: DecreasingColor.ToOption(), + Decreasing: Decreasing.ToOption(), + WhiskerWidth: WhiskerWidth.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// + /// Creates a waterfall chart. + /// + /// Waterfall charts are special bar charts that help visualizing the cumulative effect of sequentially introduced positive or negative values + /// + /// Sets the x coordinates of the plotted data. + /// Sets the y coordinates of the plotted data. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the color of increasing values + /// Sets the style options of increasing values (use this for more finegrained control than the other increasing-associated arguments). + /// Sets the color of decreasing values + /// Sets the style options of decreasing values (use this for more finegrained control than the other increasing-associated arguments). + /// Sets the color of total values + /// Sets the style options of total values (use this for more finegrained control than the other increasing-associated arguments). + /// Sets where the bar base is drawn (in position axis units). + /// Sets the bar width (in position axis units). + /// Sets the individual bar width of each datum (in position axis units). + /// Sets the opacity of the trace. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the font used for `text`. + /// Sets the waterfall connector of this trace + /// An array containing types of measures. By default the values are considered as 'relative'. However; it is possible to use 'total' to compute the sums. Also 'absolute' could be applied to reset the computed total or to declare an initial value where needed. + /// Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently. + /// Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up. + /// Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used - including if `visible` is "legendonly" but not if it is `false`. Sets the stacking direction. With "v" ("h"), the y (x) values of subsequent traces are added. Also affects the default value of `fill`. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart Waterfall( + IEnumerable x, + IEnumerable y, + Optional Name = default, + Optional ShowLegend = default, + Optional IncreasingColor = default, + Optional Increasing = default, + Optional DecreasingColor = default, + Optional Decreasing = default, + Optional TotalsColor = default, + Optional Totals = default, + Optional Base = default, + Optional Width = default, + Optional> MultiWidth = default, + Optional Opacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional TextFont = default, + Optional Connector = default, + Optional> Measure = default, + Optional AlignmentGroup = default, + Optional OffsetGroup = default, + Optional Orientation = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + where TextType : IConvertible + => + Plotly.NET.Chart2D.Chart.Waterfall( + x: x, + y: y, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + IncreasingColor: IncreasingColor.ToOption(), + Increasing: Increasing.ToOption(), + DecreasingColor: DecreasingColor.ToOption(), + Decreasing: Decreasing.ToOption(), + TotalsColor: TotalsColor.ToOption(), + Totals: Totals.ToOption(), + Base: Base.ToOption(), + Width: Width.ToOption(), + MultiWidth: MultiWidth.ToOption(), + Opacity: Opacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + TextFont: TextFont.ToOption(), + Connector: Connector.ToOption(), + Measure: Measure.ToOption(), + AlignmentGroup: AlignmentGroup.ToOption(), + OffsetGroup: OffsetGroup.ToOption(), + Orientation: Orientation.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Creates a Funnel chart. + /// + /// Funnel charts visualize stages in a process using length-encoded bars. This trace can be used to show data in either a part-to-whole representation wherein each item appears in a single stage, or in a "drop-off" representation wherein each item appears in each stage it traversed. See also the "funnelarea" trace type for a different approach to visualizing funnel data. + /// + /// Sets the x coordinates of the plotted data. + /// Sets the y coordinates of the plotted data. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the Opacity of the trace. + /// Sets the bar width (in position axis units). + /// Shifts the position where the bar is drawn (in position axis units). In "group" barmode, traces that set "offset" will be excluded and drawn in "overlay" mode instead. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used - including if `visible` is "legendonly" but not if it is `false`. Sets the stacking direction. With "v" ("h"), the y (x) values of subsequent traces are added. Also affects the default value of `fill`. + /// Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently. + /// Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up. + /// Sets the color of the bars. + /// Sets the color of the bar outline. + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Determines which trace information appear on the graph. In the case of having multiple funnels, percentages and totals are computed separately (per trace). + /// Sets the line color of the funnel connector + /// Sets the line style of the funnel connector + /// Sets the fill color of the funnel connector + /// Sets the line of the funnel connector (use this for more finegrained control than the other connector line associated arguments). + /// Sets the funnel connector (use this for more finegrained control than the other connector-associated arguments). + /// Sets the font used for `text` lying inside the bar. + /// Sets the font used for `text` lying outside the bar. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart Funnel( + IEnumerable x, + IEnumerable y, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional Width = default, + Optional Offset = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional Orientation = default, + Optional AlignmentGroup = default, + Optional OffsetGroup = default, + Optional MarkerColor = default, + Optional MarkerOutline = default, + Optional Marker = default, + Optional TextInfo = default, + Optional ConnectorLineColor = default, + Optional ConnectorLineStyle = default, + Optional ConnectorFillColor = default, + Optional ConnectorLine = default, + Optional Connector = default, + Optional InsideTextFont = default, + Optional OutsideTextFont = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + where TextType : IConvertible + => + Plotly.NET.Chart2D.Chart.Funnel( + x: x, + y: y, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + Width: Width.ToOption(), + Offset: Offset.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + Orientation: Orientation.ToOption(), + AlignmentGroup: AlignmentGroup.ToOption(), + OffsetGroup: OffsetGroup.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + Marker: Marker.ToOption(), + TextInfo: TextInfo.ToOption(), + ConnectorLineColor: ConnectorLineColor.ToOption(), + ConnectorLineStyle: ConnectorLineStyle.ToOption(), + ConnectorFillColor: ConnectorFillColor.ToOption(), + ConnectorLine: ConnectorLine.ToOption(), + Connector: Connector.ToOption(), + InsideTextFont: InsideTextFont.ToOption(), + OutsideTextFont: OutsideTextFont.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + }; + } diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs index 6dab41b58..cc2f537fe 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs @@ -94,6 +94,139 @@ public static GenericChart.GenericChart Pie( Sort: Sort.ToOption(), UseDefaults: UseDefaults.ToOption() ); + /// + /// Creates a FunnelArea chart. + /// + /// FunnelArea charts visualize stages in a process using area-encoded trapezoids, which can be used to show data in a part-to-whole representation similar to a piechart, + /// wherein each item appears in a single stage. See also the "funnel" chart for a different approach to visualizing funnel data. + /// + /// Sets the values of the sectors + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets the sector labels. If `labels` entries are duplicated, the associated `values` are summed. + /// Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace `hoverinfo` contains a "text" flag and "hovertext" is not set, these elements will be seen in the hover labels. + /// Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace `hoverinfo` contains a "text" flag and "hovertext" is not set, these elements will be seen in the hover labels. + /// Sets the positions of the `text` elements with respects to the (x,y) coordinates. + /// Sets the positions of the `text` elements with respects to the (x,y) coordinates. + /// Sets the colors associated with each section. + /// Sets the color of the section outline. + /// Sets the width of the section outline. + /// Sets the width of each individual section outline. + /// Sets the section outline (use this for more finegrained control than the other section outline-associated arguments). + /// Sets the marker of this trace. + /// Determines which trace information appear on the graph. + /// + /// + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart FunnelArea( + IEnumerable values, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional> Labels = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional> SectionColors = default, + Optional SectionOutlineColor = default, + Optional SectionOutlineWidth = default, + Optional> SectionOutlineMultiWidth = default, + Optional SectionOutline = default, + Optional Marker = default, + Optional TextInfo = default, + Optional AspectRatio = default, + Optional BaseRatio = default, + Optional UseDefaults = default + ) + where ValuesType : IConvertible + where LabelsType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartDomain.Chart.FunnelArea( + values: values, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Labels: Labels.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + SectionColors: SectionColors.ToOption(), + SectionOutlineColor: SectionOutlineColor.ToOption(), + SectionOutlineWidth: SectionOutlineWidth.ToOption(), + SectionOutlineMultiWidth: SectionOutlineMultiWidth.ToOption(), + SectionOutline: SectionOutline.ToOption(), + Marker: Marker.ToOption(), + TextInfo: TextInfo.ToOption(), + AspectRatio: AspectRatio.ToOption(), + BaseRatio: BaseRatio.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Creates an Indicator chart. + /// + /// An indicator is used to visualize a single `value` along with some contextual information such as `steps` or a `threshold`, using a combination of three visual elements: a number, a delta, and/or a gauge. + /// Deltas are taken with respect to a `reference`. + /// Gauges can be either angular or bullet (aka linear) gauges. + /// + /// Sets the number to be displayed. + /// Determines how the value is displayed on the graph. `number` displays the value numerically in text. `delta` displays the difference to a reference value in text. Finally, `gauge` displays the value graphically on an axis. + /// Sets the Range of the Gauge axis + /// Sets the trace name. The trace name appear as the legend item and on hover. + /// Sets the title of this trace. + /// Sets the domain of this trace. + /// Sets the horizontal alignment of the `text` within the box. Note that this attribute has no effect if an angular gauge is displayed: in this case, it is always centered + /// + /// Sets how the delta to the delta reference is displayed + /// Sets the styles of the displayed number + /// Sets the shape of the gauge + /// Sets the styles of the gauge + /// Wether or not to show the gauge axis + /// Sets the gauge axis + /// + public static GenericChart.GenericChart Indicator( + ValueType value, + StyleParam.IndicatorMode mode, + Optional Range = default, + Optional Name = default, + Optional Title = default, + Optional Domain = default, + Optional Align = default, + Optional DeltaReference = default, + Optional Delta = default, + Optional Number = default, + Optional GaugeShape = default, + Optional Gauge = default, + Optional ShowGaugeAxis = default, + Optional GaugeAxis = default, + Optional UseDefaults = default + ) + where ValueType : IConvertible + => + Plotly.NET.ChartDomain.Chart.Indicator( + value: value, + mode: mode, + Range: Range.ToOption(), + Name: Name.ToOption(), + Title: Title.ToOption(), + Domain: Domain.ToOption(), + Align: Align.ToOption(), + DeltaReference: DeltaReference.ToOption(), + Delta: Delta.ToOption(), + Number: Number.ToOption(), + GaugeShape: GaugeShape.ToOption(), + Gauge: Gauge.ToOption(), + ShowGaugeAxis: ShowGaugeAxis.ToOption(), + GaugeAxis: GaugeAxis.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); } } diff --git a/src/Plotly.NET.CSharp/GenericChartExtensions.cs b/src/Plotly.NET.CSharp/GenericChartExtensions.cs index a60a36aff..033e82b40 100644 --- a/src/Plotly.NET.CSharp/GenericChartExtensions.cs +++ b/src/Plotly.NET.CSharp/GenericChartExtensions.cs @@ -347,6 +347,23 @@ public static GenericChart.GenericChart WithMaboxStyle( Layers: Layers.ToOption(), Id: Id.ToOption() ).Invoke(gChart); - } + /// + /// Sets the range slider for the xAxis + /// + /// The chart for which to set the x axis range slider + /// The rangeslider to set + /// The id of the respective x axis + /// + public static GenericChart.GenericChart WithXAxisRangeSlider( + this GenericChart.GenericChart gChart, + RangeSlider rangeSlider, + Optional Id = default + ) + => + Plotly.NET.Chart.WithXAxisRangeSlider( + rangeSlider: rangeSlider, + Id: Id.ToOption() + ).Invoke(gChart); + } } \ No newline at end of file diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 7798741b3..bddebbf98 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -10,7 +10,7 @@ class Program static void Main(string[] args) { Chart.Grid( - nRows: 9, + nRows: 10, nCols: 6, gCharts: new GenericChart[] @@ -68,6 +68,53 @@ static void Main(string[] args) ShowScale: false ), + //2D Finance traces + Chart.OHLC( + open: new double [] {1.2, 2.7}, + high: new double [] {1.8, 8.5}, + low: new double [] {0.5, 0.1}, + close: new double [] {1.1, 2.9}, + x: new DateTime [] {DateTime.Parse("07/07/2021"), DateTime.Parse("07/07/2022") } + ).WithXAxisRangeSlider( + rangeSlider: Plotly.NET.LayoutObjects.RangeSlider.init( + Visible: false + )), + Chart.Candlestick( + open: new double [] {1.2, 2.7}, + high: new double [] {1.8, 8.5}, + low: new double [] {0.5, 0.1}, + close: new double [] {1.1, 2.9}, + x: new DateTime [] {DateTime.Parse("07/07/2021"), DateTime.Parse("07/07/2022") } + ).WithXAxisRangeSlider( + rangeSlider: Plotly.NET.LayoutObjects.RangeSlider.init( + Visible: false + )), + Chart.Waterfall( + x: new string [] {"A", "B", "Net", "Purch", "Other", "Profit"}, + y: new int [] {60, 80, 0, -40, -20, 0}, + Measure: new Plotly.NET.StyleParam.WaterfallMeasure [] { + Plotly.NET.StyleParam.WaterfallMeasure.Relative, + Plotly.NET.StyleParam.WaterfallMeasure.Relative, + Plotly.NET.StyleParam.WaterfallMeasure.Total, + Plotly.NET.StyleParam.WaterfallMeasure.Relative, + Plotly.NET.StyleParam.WaterfallMeasure.Relative, + Plotly.NET.StyleParam.WaterfallMeasure.Total + } + ), + Chart.Funnel( + x: new double [] { 1200, 909.4, 600.6, 300, 80 }, + y: new string[] { "A", "B", "C", "D", "E"} + ), + Chart.FunnelArea( + values: new int [] { 5, 4, 3, 2, 1 }, + MultiText: new string[] { "A", "B", "C", "D", "E"} + ), + Chart.Indicator( + value: 200, + mode: Plotly.NET.StyleParam.IndicatorMode.NumberDeltaGauge, + DeltaReference: 160 + ), + //3D traces Chart.Scatter3D( x: new int[] { 12, 13 }, @@ -175,17 +222,11 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), - Chart.Invisible(), + Chart.Invisible() } ) - .WithSize(1000, 1800) - .Show(); - Chart.Column( - values: new int[] { 3, 4 }, - Keys: new string[] { "first", "second" }, - Width: 1, - Base: 4 - ).Show(); + .WithSize(1200, 2000) + .Show(); } } }