feat: implement error bars in bar and line charts#104
Open
TymekDev wants to merge 1 commit intoardata-fr:masterfrom
Open
feat: implement error bars in bar and line charts#104TymekDev wants to merge 1 commit intoardata-fr:masterfrom
TymekDev wants to merge 1 commit intoardata-fr:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch implements vertical (Y-axis) error bars support for both bar and line charts. The error bars can be added by providing the
error_y_lowerand/orerror_y_upperarguments to thems_barchartandms_linechartfunctions. Those arguments expect a column name present in the provideddatawith absolute values for the error bars to display at. The new arguments default toNULLwhich shouldn't change the current function behavior.For this implementation I considered another approach: using a function to modify the chart object. However, I decided against it, because the underlying
ms_chartconstructor handles data transformations and writing the underlying Excel sheet. Making the user provide an already-transformed error bars data would be quite cumbersome when working with multiple series.The way this implementation works is adding a new field to the chart object—
error_bar_colnames. This is a list withyfield (xsupport can be added later on) which is eitherNULLor a list containing either or bothlowerandupperfields that store the column name provided by the user. Additionally, the data has a new column mutated which is the offset to be used by the error bars (the arguments expect the columns to have absolute values). Those columns related to error bars are also included inyargument during pivoting the data to write to the underlying Excel. Finally,as_seriesuses the calculated offset columns to create anms_error_barsobject which then gets converted with itsto_pml.ms_error_barsimplementation during theto_pmlconversion (in both bar and line charts).Additionally, I slightly refactored the
as_seriesfunction, because it got noisy while being quite repetitive.Closes #92
Examples
Setup
Single series line chart with lower error bars
Two series line chart with lower and upper error bars
Two series bar chart with lower and upper error bars