highcharts / highcharts-ios

iOS wrapper for Highcharts.
Other
127 stars 39 forks source link

Not getting word inside wordcloud on tap event in highchart ios #409

Closed rohitrmane closed 1 year ago

rohitrmane commented 1 year ago

I have tried using below code but not getting clicked word from word cloud instead it give blank in name property

   wordCloudChartView.plugins = ["wordcloud"]
    let title = HITitle()
    title.text = "Word Cloud"

    let wordcloud = HIWordcloud()
    wordcloud.name = "Occurances"
    wordcloud.minFontSize = 3.0
    wordcloud.data = cloudDataArray
    wordcloud.allowPointSelect = true

    let animation = HIAnimation()
    animation.duration = 0

    let exportings = HIExporting()
    exportings.enabled = false

    let credit = HICredits()
    credit.enabled = false

    let clickFunction = HIFunction(closure: { context in
        guard let context = context else { return }
        print("Word Printed : \(self.word)" )
    }, properties: ["name"])

    let plotOptions = HIPlotOptions()
    plotOptions.wordcloud = HIWordcloud()
    plotOptions.wordcloud.point = HIPoint()
    plotOptions.wordcloud.point.events = HIEvents()
    plotOptions.wordcloud.point.events.click = clickFunction
    plotOptions.wordcloud.placementStrategy = "center"
    plotOptions.wordcloud.rotation = cloudOrientation

    let options = HIOptions()
    options.title = title
    options.plotOptions = plotOptions
    options.exporting = exportings
    options.credits = credit
    options.series = [wordcloud]
    wordCloudChartView.options = options
ihnatmoisieiev commented 1 year ago

Hello @rohitrmane, could you please share how are you adding data to the wordcloud series?

wordcloud.data = ...

In the meantime you can try the following clickFunction:

let clickFunction = HIFunction(closure: { context in
  guard
    let context = context,
    let word = context.getProperty("this.name") as? String
  else { return }
  print("Word Printed : \(word)" )
 }, properties: ["this.name"])
ihnatmoisieiev commented 1 year ago

Closing due to inactivity