Coder Social home page Coder Social logo

Comments (6)

gregjopa avatar gregjopa commented on July 18, 2024

You can use this addon to render several chart gauges on the same page. I think the .on('init') method is over complicating things. Instead, you just need to define separate chartOptions and content for each chart gauge. For example, in your controller/component your setup would something look like this:

export default Ember.Controller.extend({

  chartOptions1: {
    chart: {
      type: 'solidgauge'
    },
    // add content
  },

  chartData1: [
    // add content
  ],


  chartOptions2: {
    chart: {
      type: 'solidgauge'
    },
    // add content
  },

  chartData2: [
    // add content
  ],


  chartOptions2: {
    chart: {
      type: 'solidgauge'
    },
    // add content
  },

  chartData2: [
    // add content
  ],

  // add chartOptions3, chartOptions4, etc

});
{{chart-solid-gauge content=chartData1 chartOptions=chartOptions1}}
{{chart-solid-gauge content=chartData2 chartOptions=chartOptions2}}
{{chart-solid-gauge content=chartData3 chartOptions=chartOptions3}}

First try and get things working with this approach. Then after that, you can dry things up. For example. if your chartOptions are very similar for all 8 chart gauges than they can all share the same chartOptions and you can make certain attributes of those configurable. You can do this by making chartOptions a computed property:

export default Ember.Component.extend({

  chartOptions: Ember.computed(function () {

    return {
      chart: {
        type: 'solidgauge'
      },
      title: {
        text: this.get('title')
      },
      ...
    }

  })

  ...

});
{{chart-solid-gauge content=chartData1 chartOptions=chartOptions title="custom title 1"}}

from ember-highcharts.

zion avatar zion commented on July 18, 2024

Thanks @gregjopa!

I was getting frustrated with getting this to work. I really like the approach of the computed properties, thats essentially exactly what I wanted to do! I got it working now!

from ember-highcharts.

gregjopa avatar gregjopa commented on July 18, 2024

Happy to help!

from ember-highcharts.

zion avatar zion commented on July 18, 2024

I'm noticing that when the value for the gauge changes, the gauge resets to 0 then goes back up to the newly changed value. Is there a way to adjust the gauge at its current value and animate it to the new value, rather than going back to 0 first?

from ember-highcharts.

gregjopa avatar gregjopa commented on July 18, 2024

We currently call redraw when updating chart data: https://github.com/ahmadsoe/ember-highcharts/blob/master/addon/components/high-charts.js#L96. This is probably causing the gauge to redraw from 0 everytime. The tricky thing with updating chart data with highcharts is every chart type has different updating logic. This addon currently does not support every use case.

You can extend this component and override the didReceiveAttrs() method to have custom updating logic. I think you will need to call point.update(num) similar to this demo: http://www.highcharts.com/demo/gauge-solid

from ember-highcharts.

zion avatar zion commented on July 18, 2024

Its not the end of the world, would just be nice, I'll give that approach a try. Thanks again!

from ember-highcharts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.