Skip to content

Commit

Permalink
Added suport for custom tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
joadan committed Sep 7, 2021
1 parent d923a01 commit 119da0d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
15 changes: 10 additions & 5 deletions samples/DemoCharts/Pages/DateTimeChart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@

options.Subtitle = new Subtitle { OffsetY = 15, Text = "DateTime sample with options" };

options.Tooltip = new Tooltip {
Enabled = true,
Y = new TooltipY {
Title = new TooltipYTitle {Formatter = @"function(name) { return name + ':' }" },
Formatter = @"function(value, { series, seriesIndex, dataPointIndex, w }) { return '$' + value }" },
//options.Tooltip = new Tooltip { Custom = "function({series, seriesIndex, dataPointIndex, w}) { return '<div> <span>' + series[seriesIndex][dataPointIndex] + '-Test </span></div>' }" };

options.Tooltip = new Tooltip
{
Y = new TooltipY
{
Title = new TooltipYTitle { Formatter = @"function(name) { return name + ':' }" },
Formatter = @"function(value, { series, seriesIndex, dataPointIndex, w }) { return '$' + value }"
},
};


Expand Down
6 changes: 5 additions & 1 deletion samples/DemoCharts/Pages/RadialBarChart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
{
options.Chart = new Chart { Sparkline = new ChartSparkline() };


options.PlotOptions = new PlotOptions
{
RadialBar = new PlotOptionsRadialBar
{
DataLabels = new RadialBarDataLabels
{
Name = new RadialBarDataLabelsName { FontSize = "26px", OffsetY = -20 },
Value = new RadialBarDataLabelsValue { FontSize = "36px", FontWeight = "bold", Color = "lightgray" }
Value = new RadialBarDataLabelsValue {
Formatter = @"function (val) { return val + '%'}",
FontSize = "36px", FontWeight = "bold",
Color = "lightgray" }
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor-ApexCharts/Models/ApexChartOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ public class StickyStyle
/// </summary>
public class Tooltip
{
//public Custom? Custom { get; set; }
public string Custom { get; set; }
public bool Enabled { get; set; } = true;
public List<double> EnabledOnSeries { get; set; }
public bool? FillSeriesColor { get; set; }
Expand Down
6 changes: 2 additions & 4 deletions src/Blazor-ApexCharts/wwwroot/js/blazor-apex-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
}

var options = JSON.parse(options, (key, value) =>
key === 'formatter' && value.length !== 0 ? eval("(" + value + ")") : value

);
(key === 'formatter' || key === 'custom') && value.length !== 0 ? eval("(" + value + ")") : value
);



if (options.debug == true) {
console.log(options);
Expand Down

0 comments on commit 119da0d

Please sign in to comment.