Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend not showing up after setting LabelConfig #8

Open
bwong199 opened this issue Jan 30, 2024 · 4 comments
Open

Legend not showing up after setting LabelConfig #8

bwong199 opened this issue Jan 30, 2024 · 4 comments
Assignees
Projects

Comments

@bwong199
Copy link

Hi,

I was able to get what I want to see show up for legend config, but I tried change the font and font size, using labelConfig and set the legendConfig's labels properties to labelConfig, but then the legend would not show up after. Thanks!

let options = Options()
let plugins = Plugin()
let legendConfig = LegendConfig()

let font = Font()
font.Size <- 1000

let labelConfig = LabelConfig()
labelConfig.Font <- font
labelConfig.Color <- Union1Of2 1
labelConfig.BoxHeight <- 200
labelConfig.BoxWidth <- 200
labelConfig.Padding <- 30
labelConfig.UsePointStyle <- true
labelConfig.GenerateLabels

legendConfig.Display <- true
legendConfig.Position <- PositionString.Top
legendConfig.Align <- AlignString.Center
legendConfig.FullSize <- true
legendConfig.MaxHeight <- 1000
legendConfig.MaxWidth <- 1000
legendConfig.Labels <- [|labelConfig|] <<<<< legend doesn't show up after adding this.

plugins.Legend <- legendConfig

@Jooseppi12 Jooseppi12 self-assigned this Jan 30, 2024
@Jooseppi12
Copy link
Member

Hey @bwong199!

Indeed this seems like an issue with the binding, will do a fix for this soon.

In the meantime, you can use the following as a workaround:

Instead of:

legendConfig.Labels <- [|labelConfig|]

use this:

legendConfig?labels <- labelConfig.

@bwong199
Copy link
Author

Hi @Jooseppi12 ,

Thanks for getting back. The legend now shows up but the font label doesn't seem to be changed. All I changed was that line ^^^, were you able to get it to work? Thanks!

@Jooseppi12
Copy link
Member

Jooseppi12 commented Jan 30, 2024

@bwong199 Using the following code:

      let bdColor = [|
            "rgba(255, 99, 132, 1)"
            "rgba(54, 162, 235, 1)"
            "rgba(255, 206, 86, 1)"
            "rgba(75, 192, 192, 1)"
            "rgba(153, 102, 255, 1)"
            "rgba(255, 159, 64, 1)"
        |] 

      let options = Options()
      let plugins = Plugin()
      let legendConfig = LegendConfig()

      let font = Font()
      font.Size <- 30
      font.Family <- "'Helvetica Neue'"
      font.Style <- FontStyle.Italic

      let labelConfig = LabelConfig()
      labelConfig.Font <- font
      labelConfig.Color <- Union1Of2 1
      labelConfig.BoxHeight <- 200
      labelConfig.BoxWidth <- 200
      labelConfig.Padding <- 30
      labelConfig.UsePointStyle <- true

      legendConfig.Display <- true
      legendConfig.Position <- PositionString.Top
      legendConfig.Align <- AlignString.Center
      legendConfig.FullSize <- true
      legendConfig.MaxHeight <- 1000
      legendConfig.MaxWidth <- 1000
      legendConfig?labels <- labelConfig

      plugins.Legend <- legendConfig
      options.Plugins <- plugins

      let lineDataSet = LineChartDataSet()
      lineDataSet.Label <- "# of Votes"
      lineDataSet.Data <- [|12;19;3;5;2;3|]
      lineDataSet.BorderColor <- Union2Of2 bdColor  
      lineDataSet.BorderWidth <- 6

      let lineData = ChartData()
      lineData.Datasets <- [|lineDataSet|]
      lineData.Labels <- [|"red";"blue";"yellow";"green";"purple";"orange"|]

      let linearChart = ChartCreate(lineData, options)
      let linear () = Chart("chartjs", linearChart)
      linear()

(Uses a canvas in the dom with the id of chartjs)
All three settings on the font object were applied to the legend config and changing those values were applied.

If you have a sample project/repo I can take a look at a specific example, but the above worked for me

@Jooseppi12
Copy link
Member

7.0.5.406-beta4 Now contains the fix for this available from our feed.

@granicz granicz added this to v7.0 in Releases Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants