Release-2.0.0 | the release that should've been 1.0
The library is now in a stable state and ready for production use. More features will be added over time.
We highly recommend everyone to upgrade to Version 2.0.
There are a lot of changes but the migration won't take long and you can find a migration guide below.
Important:
Due to an unfortunate situation, the new 2.0 release is only available in an alternative NuGet package for the time being.
In order to get to this stable state, a lot of parts were reworked. The highlights are:
- Completely rewritten datasets. They're fully generic and implement the default
IList<T>
. - A single
Chart
component which can work with any supplied chart config. The config is serialized and passed to Chart.js. - Typesafe callbacks for easy C#-interop. Some callbacks which return values (e.g. filter callbacks) are now also supported but only on client-side Blazor.
- Simplified namespaces by reducing
ChartJs.Blazor.ChartJS
toChartJs.Blazor
. - Make every option nullable. This means that Chart.js will choose their default if you don't specify a value. This has several benefits like respecting changes in the global defaults (in JavaScript
Chart.defaults
). - Lots of missing properties have now been added to better leverage the potential of Chart.js 2.9.
- Lots of bugs have been fixed (e.g. colors work on all cultures now).
As part of the 2.0 release, we've also completely redone the samples to reflect the official Chart.js samples. However, we're not done yet and many samples are missing. If you'd like to help, please check out this issue.
Changes
The changelog for this release is quite big. I tried my best to include everything (in no particular order) but I might've missed some things.
- Simplified namespaces by reducing
ChartJs.Blazor.ChartJS
toChartJs.Blazor
(ee7c460) - Remove
ChartJs.Blazor.Charts
andChartJs.Blazor.Common.Properties
namespaces (merged withChartJs.Blazor
andChartJs.Blazor.Common
) (ee7c460) - Remove the Chart.js and moment.js scripts (#95)
- Merge chart data classes into single
ChartData
class (c6a3df6) - Merge all chart components into single
Chart
component (fb6e678) - Add
JavaScriptHandler<T>
which allows interop with your own JavaScript functions (#70) - Add
DelegateHandler<T>
which allows interop with your own C# methods (actually any delegate will work now) (#70) - Add support for the
Clip
option - Make every option nullable to make use of Chart.js' (adjustable) defaults (6c45391)
- Simplify creation of horizontal bar charts by changing the constructor to
BarConfig(bool horizontal = false)
(6a9d58e) - Rework every dataset (#96, #112, #133)
- One of the biggest changes in this is the large amount of new properties that just weren't supported before. I won't list them all here.
- Datasets now implement
IList<T>
and don't have any generic constraints. - All the value-type wrappers were removed (
DoubleWrapper
, etc.)
- Add support for floating bars (#100)
- Add
SetupCompletedCallback
toChart
which makes registering plugins and manipulating the JavaScript object easier since you don't have do fiddle around with life cycle methods - Went through all the chart configs/options and added the appropriate properties for Chart.js 2.9. There are simply too many to list here but you'll find that the library is more complete now (but there will still be things missing).
- Allow settings the step size in radar charts (#110)
- Add support for plugin options (#63)
- Fix bug preventing the use of
System.Drawing.Color
with a custom alpha value (#118) - Fix bug preventing the use of some
ColorUtil
methods in specific cultures (#147) - Add custom Ticks Format callback (#62)
- Add typesafe filling mode (#56)
- Remove specific classes for mixed charts as every chart is mixable, you just have to add a dataset with a different type (e.g.
LineDataset
inBarConfig
) (56b5436) - Hide internal classes like
ChartJsInterop
andExpandoObjectExtensions
- Remove out of scope classes like
MomentJsInterop
andPointUtil
- Remove the unnecessary
DateTime
-wrapperMoment
- Remove unnecessary divs around canvas (54f317f)
- Avoid swallowing exceptions when setting up/updating the chart. These will now bubble up and need to be handled instead of just being printed to the console.
- Add
AxisDirection
string enum - Add
BrowserEvent
string enum - Make
GridLines.LineWidth
indexable - Seal
DelegateHandler<T>
Point
,TimePoint
,BubblePoint
andFloatingBarPoint
are now structsLineOptionsHover
was renamed toHover
Migrate from Version 1.x to 2.0
- Reference the Chart.js (and moment.js) scripts from some other source like a CDN or download and include it in your application
- Reference
_content/ChartJs.Blazor.Fork/ChartJsBlazorInterop.js
instead of_content/ChartJs.Blazor/ChartJsBlazorInterop.js
(this is only required when referencing the alternative NuGet package) - Remove imports of
ChartJs.Blazor.Charts
andChartJs.Blazor.Common.Properties
- Search and replace
ChartJs.Blazor.ChartJS
withChartJs.Blazor
- Search and replace
LegendLabelConfiguration
withLegendLabels
- Search and replace
xAxes
withXAxes
andyAxes
withYAxes
- Search and replace
LineOptionsHover
withHover
- Search and replace (regex)
ChartJs[a-zA-Z]+Chart
withChart
- Search and replace (regex)
TimeTuple<[a-zA-Z]+>
withTimePoint
(which now always usesdouble
) - If you were passing
true
to thePieOptions
constructor, passtrue
to thePieConfig
constructor instead - Replace
JsHoverHandler
,JsClickHandler
etc. withJavaScriptHandler<T>
whereT
is the appropriate delegate (hover over the property you're assigning it to) - Replace
DotNetInstanceClickHandler
,DotNetInstanceHoverHandler
,DotNetStaticClickHandler
, etc. withDelegateHandler<T>
(just like above) - Replace all references to the number wrappers and replace them with the actual types. E.g.
DoubleWrapper
->double
- Remove all mentions of
Moment
and just use yourDateTime
objects - If you're using horizontal bar charts, simply pass
true
to the constructors of yourBarConfig
andBarDataset
s
If you have trouble migrating to version 2.0, please open an issue.