Coder Social home page Coder Social logo

Comments (4)

Blake-Madden avatar Blake-Madden commented on May 28, 2024

Please refer to here:

https://github.com/Blake-Madden/Wisteria-Dataviz/blob/main/BuildingData.md

Does this help?

from wisteria-dataviz.

LEOcab avatar LEOcab commented on May 28, 2024

Please refer to here:

https://github.com/Blake-Madden/Wisteria-Dataviz/blob/main/BuildingData.md

Does this help?

No... That's the guide I followed initially before putting my project aside to try and understand how the demo works. Look, this is what I have so far. Where did I screw up?

		double *data = ... data points ...
		time_t *times = ... timestamps ...
		
		auto yData = make_shared<Data::Dataset>();
		
		yData->AddContinuousColumn(L"AVG_GRADE");
		yData->AddCategoricalColumn(L"WEEK_NAME");
	 
		for (int p = 0; p < size; p++)
			yData->AddRow(Data::RowInfo().Continuous({ data[p] }).Categoricals({ 0 }));
		
		for (int p = 0; p < size; p++)
			yData->AddRow(Data::RowInfo().Dates({ wxDateTime(times[p]) }));
			
		// set the string labels for the codes in the grouping column
		yData->GetCategoricalColumn(L"WEEK_NAME")->GetStringTable() =
			{ { 0, L"Week" } };
		
		Canvas *canvas = new Canvas(m_panel1, wxID_ANY, wxDefaultPosition, m_panel1->GetSize(), wxALL | wxEXPAND);
		
		auto linePlot = std::make_shared<Graphs::LinePlot>(canvas,
			// use a different color scheme
			std::make_shared<Colors::Schemes::Decade1960s>(),
			// or create your own scheme
			// std::make_shared<Colors::Schemes::ColorScheme>
			//     (Colors::Schemes::ColorScheme{
			//         ColorBrewer::GetColor(Colors::Color::Auburn),
			//         ColorBrewer::GetColor(Colors::Color::OctoberMist) }),

			// turn off markers by using a shape scheme filled with blank icons
			// (having just one icon in this scheme will get recycled for each line)
			std::make_shared<Icons::Schemes::IconScheme>(Icons::Schemes::IconScheme{ Icons::IconShape::Blank }));
		// add padding around the plot
		linePlot->SetCanvasMargins(5, 5, 5, 5);

		// Set the data and use the grouping column from the dataset to create separate lines.
		// Also, use a categorical column for the X axis.
		linePlot->SetData(linePlotData, L"AVG_GRADE", L"WEEK_NAME");

		// add some titles
		linePlot->GetTitle().SetText(_(L"Average Grades"));
		linePlot->GetSubtitle().SetText(_(L"Average grades taken from\n"
										   "last 5 weeks' spelling tests."));
		linePlot->GetCaption().SetText(_(L"Note: not all grades have been\n"
										  "entered yet for last week."));
		// remove default titles
		linePlot->GetBottomXAxis().GetTitle().SetText(L"");
		linePlot->GetLeftYAxis().GetTitle().SetText(L"");

		// add the line plot and its legend to the canvas
		canvas->SetFixedObject(0, 0, linePlot);
		canvas->SetFixedObject(0, 1,
			linePlot->CreateLegend(
				Graphs::LegendOptions().
					IncludeHeader(true).
					PlacementHint(LegendCanvasPlacementHint::RightOfGraph)) );

This code throws an exception about the Y column not existing.

from wisteria-dataviz.

Blake-Madden avatar Blake-Madden commented on May 28, 2024

You should combine the loops into one like this:

for (int p = 0; p < size; p++)
    yData->AddRow(Data::RowInfo().Continuous({ data[p] }).Categoricals({ 0 }).Dates({ wxDateTime(times[p]) }));

You need to fill a row in one call.

That's at least part of the problem, I'll look into this further this evening.

from wisteria-dataviz.

Blake-Madden avatar Blake-Madden commented on May 28, 2024

You are not passing the dataset that you filled with data to the line plot. You're passing the wrong dataset. The dataset being filled from your arrays is yData, but here is what you are sending to the graph:

linePlot->SetData(linePlotData, L"AVG_GRADE", L"WEEK_NAME");

Try passing yData instead of linePlotData.

from wisteria-dataviz.

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.