Comments (8)
The "Overriding Chart Redrawing" code in the README doesn't work anymore (it worked before this commit: adba001). Instead, try overriding the didReceiveAttrs
method. Let me know if that works for you.
from ember-highcharts.
With the following code I get "cannot read property 'redraw' of null":
export default EmberHighChartsComponent.extend({
didReceiveAttrs() {
this._super(...arguments);
let chart = this.get('chart');
chart.redraw();
}
});
What I need to do is redraw the chart when the model changes, because the categories along the x-axis change in chartOptions.
from ember-highcharts.
I think there is a use case where chart
is null with didReceiveAttrs()
so we have this check in place (perhaps on initial render): https://github.com/ahmadsoe/ember-highcharts/blob/master/addon/components/high-charts.js#L53.
Also, have you seen the examples in the dummy app? Check out the interactive charts in the dummy app (https://ahmadsoe.github.io/ember-highcharts/). Does the "Update Series Data" button code help solve your use case? https://github.com/ahmadsoe/ember-highcharts/blob/master/tests/dummy/app/components/chart-line-interactive.js#L32. This code does not override anything. Just want to make sure you've seen this example before continuing down the override redraw path.
from ember-highcharts.
I don't think the example helps me. I'll try to explain my use case:
Template:
{{high-charts chartOptions=chartOptions content=chartData}}
Controller:
chartData: Ember.computed('model', function() {
return this.get('model.series');
}),
chartOptions: Ember.computed('model', function() {
return {
<snip>
xAxis: {
categories: this.get('model.categories')
}
<snip>
}),
The categories in this case are months: [jan, feb, mar, etc]. The user can click a dropdown to select a number of months of data to view, which sets a queryparam ?months=3 or ?months=6 etc which refreshes the model.
If months starts at 3, categories is [jan, feb, mar]
. if 6 categories is [jan, feb, mar, apr, may, jun]
etc.
The problem is if the chart starts with 3 months, and then the user selects 6 months, the data in the chart updates correctly, but the x-axis now looks like
jan | feb | mar | 3 | 4 | 5
instead of
jan | feb | mar | apr | may | jun
because the new categories in chartOptions aren't being included.
Any idea how I could fix this?
from ember-highcharts.
I recommend managing your categories in chartData, not chartOptions. Highcharts is flexible and allows you to setup the category data either way. Here's an example:
Categories in chartOptions:
chartOptions: {
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
allowDecimals: false,
title: {
text: 'Fruit eaten'
}
}
},
chartData: [
{
name: 'Jane',
data: [5, 0, 20]
},
{
name: 'John',
data: [25, 30, 15]
}
]
Categories in chartData:
chartOptions: {
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
type: 'category'
},
yAxis: {
allowDecimals: false,
title: {
text: 'Fruit eaten'
}
}
},
chartData: [
{
name: 'Jane',
data: [
['Apples', 5],
['Bananas', 0],
['Oranges', 20]
]
},
{
name: 'John',
data: [
['Apples', 25],
['Bananas', 30],
['Oranges', 15]
]
}
]
ChartData updates are dynamic so try moving your categories there. Hope this helps.
from ember-highcharts.
Nice, I think that's exactly what I need. I won't be able to try it until next week but it looks like it will work. Thanks so much for taking the time to help me.
from ember-highcharts.
That worked perfectly, thank you!
from ember-highcharts.
@gregjopa Looks like we should use content
property specifically for chart series. Could you emphasize this point in docs? I think many people miss it although I've mentioned it:
The content argument matches up with the series option in the Highcharts/Highstock/Highmaps API. Use this option to set the series data for your chart.
It would be great if you show 2 different configs in docs: first one is original highcharts config and second one is properties for ember-highcharts This would be much more clear
from ember-highcharts.
Related Issues (20)
- How write integration/acceptance tests with ember-highcharts? HOT 1
- Upgrade Hightcharts to get fix for getDistanceBetweenCirclesByOverlap logic HOT 1
- Cannot read property "forExport" of undefined HOT 3
- Build error with highcharts v7.1.2 in styled mode HOT 1
- Upgrade bootstrap to fix cross-site scripting vulnerability
- How to add support to accessibility? HOT 1
- How to pass an object to Highcharts.setOptions HOT 1
- Series with the same name (`series.name`) are "mysteriously" dropped when chart is re-rendered. HOT 1
- Changing Series changes order HOT 1
- ‘Cannot read property "forExport" of undefined’ when transitioning to a new route. HOT 1
- Replacing xAxis, and yAxis HOT 2
- [Octane] Glimmer component refactor HOT 1
- Modifier manager capabilities deprecating warning HOT 8
- I think v3.2.0 should have been a major version HOT 5
- How can one use Annotation module of highchart using ember-highcharts? HOT 1
- Getting https://assets.highcharts.com/errors/16/ error on EmberJS application HOT 1
- Replace `ember-holy-futuristic-template-namespacing-batman` with `ember-template-imports` HOT 2
- Using custom components in a chart
- Question: Can we use highchart version: 8.0.0 with ember-highchart version: 3.1.0 ? HOT 1
- Release v3.2.2 for assign polyfill deprecation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-highcharts.