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

Show empty Chart when there are no data #975

Closed
cepages opened this issue Apr 25, 2016 · 6 comments
Closed

Show empty Chart when there are no data #975

cepages opened this issue Apr 25, 2016 · 6 comments

Comments

@cepages
Copy link

cepages commented Apr 25, 2016

Hi I'm working with LineChartData and I would like to show the axis even when there are not data in the chart, in my case:

po listOfLineChart
<__NSArrayM 0x7faf5dcb9340>(
ChartDataSet, label: Weight, 0 entries:
)

I don't want to show the message: You need to provide data for the chart. No chart data available

Thanks

@dxclancy
Copy link

I am not one of the authors of the library, but in the demo, I see that there is this setting:
_chartView.noDataTextDescription = @"You need to provide data for the chart.";
So it seems like you could turn off this text by setting it to @"";

Perhaps if you detect the chart is empty, you could set an empty value to get the chart to draw.

@cepages
Copy link
Author

cepages commented Apr 25, 2016

The problem is I don't want to paint 0's, because currently I'm adding
empty values, if I add 0's the graph will paint them.

Maybe I taking the fact of empty values wrong, what do you mean exactly
with empty values?

Thanks
On 25 Apr 2016 11:27 p.m., "dxclancy" notifications@github.com wrote:

I am not one of the authors of the library, but in the demo, I see that
there is this setting:
_chartView.noDataTextDescription = @"You need to provide data for the
chart.";
So it seems like you could turn off this text by setting it to @"";

Perhaps if you detect the chart is empty, you could set an empty value to
get the chart to draw.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#975 (comment)

@dxclancy
Copy link

dxclancy commented Apr 25, 2016

I actually meant adding just one value of 0 (and configure all other things so that it won't draw things.)

However, I just tried this:
If you replace this line in the Demo LineChart1ViewContoller:
LineChartData *data = [[LineChartData alloc] initWithXVals:xVals dataSets:dataSets];
with
LineChartData *data = [[LineChartData alloc] init];
it seems to behave as you want.

@liuxuan30
Copy link
Member

liuxuan30 commented Apr 26, 2016

If you don't have any data, the axis range will be displayed as 0-1, which may be meanless. Currently, there is a check to make sure you have data before calculation. If you really want the axis displayed, you have to delete those checks, starting from data setter and drawRect

@cepages
Copy link
Author

cepages commented Apr 27, 2016

Hi @liuxuan30 when you mean there is a check could you point me what exactly should I change?

I was checking here but I'm not really sure.

@dxclancy I tried with the demo and to change that you commented, as you said it's showing the chart. I tried in my one but shows the message instead of the char:

screen shot 2016-04-27 at 18 05 21

I will try to know what is different. Thanks

@cepages
Copy link
Author

cepages commented Apr 28, 2016

Thanks both, in the end I could check the new version of the library is not showing the message. I wasn't using the new version due to a (problem with translations in XCode 7.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants