Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Yield Curve and Options Chart Types, Up/Down Markers Plugin #1674

Draft
wants to merge 15 commits into
base: v5-candidate
Choose a base branch
from

Conversation

SlicedSilver
Copy link
Contributor

Type of PR: new features

PR checklist:

  • Addresses an existing issue: fixes #
  • Includes tests
  • Documentation update

Overview of change:

Add Yield Curve and Options Chart Types, Up/Down Markers Plugin, and Documentation Updates

New Features:

  1. Yield Curve Chart:

    • Added a new chart type specifically designed for displaying yield curves.
    • Introduced the createYieldCurveChart function.
    • Implemented specialized horizontal scale behavior for yield curves, including linear spacing and whitespace handling.
  2. Options Chart:

    • Added a new chart type that uses price values on the horizontal scale.
    • Introduced the createOptionsChart function.
    • Implemented horizontal scale behavior for price-based charts.
  3. Up/Down Markers Plugin:

    • Added the UpDownMarkersPrimitive plugin to display markers indicating price changes.
    • Implemented marker management with automatic expiration and update handling.
  4. Codebase Improvements / API additions:

    • Added the ignoreWhitespaceIndices option to the time scale configuration.
    • Enhanced the updateSeriesData function to support historical updates.
  5. Documentation:

    • Updated the documentation to include new chart types and their usage.
    • Added a new page for chart types, detailing the creation and use cases for standard time-based, yield curve, and options charts.

@SlicedSilver SlicedSilver added enhancement Feature requests, and general improvements. documentation Improvements or additions to the documentation plugin This feature request should/could be implemented as a Plugin. labels Aug 13, 2024
@SlicedSilver SlicedSilver added this to the 5.0 milestone Aug 13, 2024
@SlicedSilver SlicedSilver self-assigned this Aug 13, 2024
Copy link

github-actions bot commented Aug 13, 2024

size-limit report 📦

Path Size
ESM 45.01 KB (+4.57% 🔺)
ESM createChart 42.16 KB (+0.86% 🔺)
ESM createChartEx 40.94 KB (+0.97% 🔺)
ESM Standalone 0 B (-100% 🔽)
Standalone 46.4 KB (+4.37% 🔺)
Plugin: Text Watermark 1.79 KB (+0.11% 🔺)
Plugin: Image Watermark 1.63 KB (+0.73% 🔺)
ESM createYieldCurveChart 41.54 KB (+100% 🔺)
ESM createOptionsChart 41.1 KB (+100% 🔺)
Standalone-ESM 46.49 KB (+100% 🔺)
Plugin: UpDownMarkersPrimitive 2.25 KB (+100% 🔺)

/**
* Defines the supported series types for markers.
*/
export type SupportedSeriesTypes = 'Line' | 'Area';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is exported and thus included in the generated d.ts file lets give it a more explicit name

});
const priceChangeMarkers = new UpDownMarkersPrimitive();
series1.attachPrimitive(priceChangeMarkers);
priceChangeMarkers.setData(curve1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a review, just a question. Did you consider creating it using a custom series? From my point of view, managing the series via the series' primitive seems unintuitive. Since it’s a core plugin, we have access to all the source code, so we could potentially wrap the line and area series and add the up/down indicator logic on update. I haven’t thought much about it, so there might be other limitations with the custom series approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with most things it is a trade-off. In many ways it makes sense to create a custom series but there are some benefits to using a Primitive. The drawing of markers fits better into a primitive (conceptually), and the main reason for using a primitive is that it can be used on multiple types of series (and custom series) so we are not limiting this plugin to only working with one or two series which are copies of existing series types.
Finally, the up down markers plugin can be used without needing to use the setData / update passthrough methods if you use the manual setMarkers method. So my thinking is that using as a Primitive is a more flexible and lower level implementation which can make it useful in more use-cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to the documentation enhancement Feature requests, and general improvements. plugin This feature request should/could be implemented as a Plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants