You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be really useful if XPlot had a more intellisense-friendly way of discovering a chart's capabilities, and making incremental updates to the properties of a chart or chart element.
It would also be useful if this way of working with charts were uniform across the different backends (Plotly and GoogleCharts) which allowed you to switch between without necessarily learning the differences in API's.
Solution
Would this API change / addition be of interest?
Rather than specifying all upfront, as in:
lettrace1=
Scatter(
x =[0.;1.;2.;3.],
y =[0.;2.;1.;4.],
line = Line(
color="rgb(22, 94, 184)",
width=3))lettrace2=
Scatter(
x =[0.;1.;2.;3.],
y =[1.;3.;2.5;6.])letchart=[trace1; trace2]|> Chart.Plot
You could do something like:
lettrace1=
Scatter(
x =[0.;1.;2.;3.],
y =[0.;2.;1.;4.])lettrace2=
Scatter(
x =[0.;1.;2.;3.],
y =[1.;3.;2.5;6.])letchart=[trace1; trace2]|> Chart.Plot
|> Chart.With (chart.traces.[0].asScatter.line.width 3)|> Chart.With (chart.traces.[0].asScatter.line.color "rgb(22, 94, 184)")
This way you could dot into the chart object and get intellisense to find all the statically typed properties available to you.
Such an approach would also feel similar no matter the plotting library used to render the charts.
The Chart.With function (used in the F# version) would need the following signature:
Func<Chart,Chart>-> Chart -> Chart
where the Func is a function which, given a chart, makes a copy and sets a property value in this chart before returning it. Therefore, the Withfunction is taking this function, and also a chart object to apply it to, and returning a new updated chart by applying the function the the chart object it is passed.
A C# version would better suit an instance method approach:
Chart Chart.With(Func<Chart,Chart>applyPropFun)
Final
I do have a proof of concept (using reflection) which suggests this approach could work really well, but wanted to sound it out before going any deeper.
Any suggestions, improvements?
This would really bloat the generated codebase, as properties (classes) would need to be defined for every chart element that could be set, at any point in the hierarchy. Understandably therefore, it may not be the direction that the current contributors wish to take it..
The text was updated successfully, but these errors were encountered:
Very bare bones right now. Ideally I wouldn't want to make an entirely new library for this change, and would love to contribute to XPlot development instead! However:
I'm not certain this is the direction that the current maintainers wish for XPlot, and
I actually generated some of the code in C# for a few (probably silly) reasons
Nonetheless, if anyone is interested I'd be very happy to discuss ways of incorporating this work into XPlot.
Thanks for the wonderful work done on this library!
It would be really useful if XPlot had a more intellisense-friendly way of discovering a chart's capabilities, and making incremental updates to the properties of a chart or chart element.
It would also be useful if this way of working with charts were uniform across the different backends (Plotly and GoogleCharts) which allowed you to switch between without necessarily learning the differences in API's.
Solution
Would this API change / addition be of interest?
Rather than specifying all upfront, as in:
You could do something like:
This way you could dot into the chart object and get intellisense to find all the statically typed properties available to you.
Such an approach would also feel similar no matter the plotting library used to render the charts.
It would work in C# like this:
Implementation
The Chart.With function (used in the F# version) would need the following signature:
where the
Func
is a function which, given a chart, makes a copy and sets a property value in this chart before returning it. Therefore, theWith
function is taking this function, and also a chart object to apply it to, and returning a new updated chart by applying the function the the chart object it is passed.A C# version would better suit an instance method approach:
Final
I do have a proof of concept (using reflection) which suggests this approach could work really well, but wanted to sound it out before going any deeper.
Any suggestions, improvements?
This would really bloat the generated codebase, as properties (classes) would need to be defined for every chart element that could be set, at any point in the hierarchy. Understandably therefore, it may not be the direction that the current contributors wish to take it..
The text was updated successfully, but these errors were encountered: