microcharts-dotnet / Microcharts

Create cross-platform (Xamarin, Windows, ...) simple charts.
MIT License
2.02k stars 361 forks source link

[Spec][Draft] Stepped series (DateSerie, TimeSerie, FloatSerie) #250

Closed Seuleuzeuh closed 3 years ago

Seuleuzeuh commented 3 years ago

The feature Be able to declare series for Chart with an auto generation of the labels part, accordingly to a range and step size.

API [ class abstract BaseChartSerie ]

Property Type Description
Entries IEnumerable Get (only) the Entries
Name string Gets or sets the name of the serie
Color SkColor? Gets or sets the color of the fill
[class ChartSerie] Inherit from BaseChartSerie Property Type Description
Entries IEnumerable Overided for Get and set the Entries
[class abstract BaseChartEntry] Generic BaseChartEntry with Typed Label value Property Type Description
Value float Get the value
Label TLabel Gets or sets the caption label
ValueLabel string Gets or sets the label associated to the value.
Color SkColor Gets or sets the color of the fill.
TextColor SkColor Gets or sets the color of the text (for the caption label).
ValueLabelColor SkColor Gets or sets the color of the value label

[class ChartEntry] Inherit from BaseChartEntry. Equivalient of the actual ChartEntry

[class DateTimeChartEntry] Inherit from BaseChartEntry.

[enum StepDateType] Name Description
Day .
Week .
Month .
Year .
[class DateSerie] Inherit from BaseChartSerie Property Type Description
Entries IEnumerable Overided - generate Entries on get
StartDate DateTime Gets or sets the start date of the range of labels
EndDate DateTime Gets or sets the end date of the range of labels
StepType DateStepType Gets or sets the DateStepType for generating the labels
StepValueInterval int Gets or sets the number of StepType between each value
StepLabelInterval int Gets or sets the number of StepType between the drawing of label
LabelFormat string Gets or sets the datetime label formats
Values IEnumerable Gets or sets the values entries with DateTime labels

Scenario All the 'magic' will be made during the first Get of DateSerie.Entries, and the entries will be generated accordingly to the others option of the class. The same type of class can be applied for TimeSeries, FloatSeries, and others. With this API Model, no change will be made of the core charts.

Additional context Feedback required.

Seuleuzeuh commented 3 years ago

I've split the value generation (StepValueInterval) and the label generation (StepLabelInterval). For example : That allow user to draw a chart with daily value, but with label draw every 7 days.

I think an other update is required to manage monthly label generation (the first of every month for example). I don't know if it's a needed feature. I need some feedback.

eman1986 commented 3 years ago

this looks pretty good, I like the direction you're going with this.