No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    ApexCharts: Dynamically set annotation

    Help
    2
    2
    751
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      philipp last edited by

      Hi guys,
      I am using Apex Charts for Vue to display some line charts and have a little problem:

      There is a component which holds a measurementType string provided via prop and shows a line chart:

      <SingleLineMeasurementGraph :measurementType="getMachineReadableType" :measurementData="data.getAllMeasurements" />
      

      Inside of the component template section looks like this:

      <template>
        <div class="chart">
          <div class="chart-line">
            <apexchart
              type="line"
              height="300"
              :options="chartOptions"
              :series="this.getMeasurementDataTransformed"
            ></apexchart>
          </div>
        </div>
      </template>
      

      Within chartOptions config I would like to set y-axis annotation dynamically in dependency of the given measurementType prop. Unfortunately it only shows an annotation with values 62 and 105, but never 3 and 11.

      data () {
          return {
            chartOptions: {
              annotations: {
                yaxis: [
                  {
                    y: this.measurementType === 'GLUCOSE' ? 3 : 62,
                    y2: this.measurementType === 'GLUCOSE' ? 11 : 105,
                    borderColor: '#000',
                    fillColor: '#00ff00',
                    opacity: 0.15,
                    label: {
                      text: ' '
                    }
                  }
                ]
      ...
      

      I already tried to put the condition in a computed property instead and exchanged the prop with a local boolean variable, but it did not work either. There seems to be a problem with reactiveness. Do I have to force the chart to re-render after changing the value maybe?

      Any help is highly appreciated.

      Kind regards
      Philipp

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        The question is, does Vue-ApexCharts (which I am assuming you are using) make its chartOptions reactive or allow for it. This seems to be an answer to that question.

        https://github.com/apexcharts/vue-apexcharts/issues/87

        Scott

        1 Reply Last reply Reply Quote 0
        • First post
          Last post